use crate::UriTemplate;
#[test]
pub fn debug() {
print_ok("");
print_ok("{var}");
print_ok("'{var}'");
print_ok("{+var}");
print_ok("{+path}/here");
print_ok("map?{x,hello,y}");
print_ok("map?{+x,hello,y}");
print_ok("map?{#x,hello,y}/here");
print_ok("?fixed=yes{.x,y}/here");
print_ok("?fixed=yes{.a*}/here");
print_ok("你好%25fixed=yes{.var1:30,var2,var3}/here");
print_ok("%2F%25fixed=yes{+var1:3000,var2*,var3}/here");
print_ok("%2F%25fixed=yes{+var1*}/here");
print_ok("%FF%25fixed=yes{+var1*}/here");
print_ok("https://example.com/api/users/{user_id}{/action}{?query}");
print_ok("%7Bvar%7D");
print_ok("%7B{var}");
print_ok("你好{var}");
}
fn print_ok(s: &'static str) {
let template = UriTemplate::new(s);
assert!(
template.is_ok(),
"expected Ok but got error {}",
template.unwrap_err()
);
let template = template.unwrap();
let template_vars = template.variables();
let template_literals = template.literals();
println!("{template:#?}\nVariables: {template_vars:?}\nLiterals: {template_literals:?}\n");
println!("--------------------------------------------------------------------------------\n")
}