Line data Source code
1 : use bliki_percent_encoding::slugify;
2 :
3 : #[test]
4 0 : fn test_whitespace() {
5 0 : assert_eq!(slugify("hello world"), "hello%20world".to_string());
6 0 : assert_eq!(slugify("hello world"), "hello%20world".to_string());
7 0 : }
8 : #[test]
9 0 : fn test_question_mark() {
10 0 : assert_eq!(slugify("hello?"), "hello%3F".to_string());
11 0 : }
12 :
13 : // TODO: How to add test_slugify to the function name?
14 : macro_rules! slugify_test {
15 : ($name:ident, $in:expr, $out:expr) => {
16 : #[test]
17 0 : fn $name() {
18 0 : assert_eq!(slugify($in), $out.to_string())
19 0 : }
20 : };
21 : }
22 :
23 : slugify_test!(colon, ":", "%3A");
24 : slugify_test!(slash, "/", "%2F");
25 : slugify_test!(question_mark, "?", "%3F");
26 : slugify_test!(pound, "#", "%23");
27 : slugify_test!(open_square_bracket, "[", "%5B");
28 : slugify_test!(close_square_bracket, "]", "%5D");
29 : slugify_test!(at, "@", "%40");
30 : slugify_test!(bang, "!", "%21");
31 : slugify_test!(dollar, "$", "%24");
32 : slugify_test!(ampersand, "&", "%26");
33 : slugify_test!(backslash, "'", "%27");
34 : slugify_test!(open_paren, "(", "%28");
35 : slugify_test!(close_paren, ")", "%29");
36 : slugify_test!(asterkisk, "*", "%2A");
37 : slugify_test!(plus, "+", "%2B");
38 : slugify_test!(comma, ",", "%2C");
39 : slugify_test!(semicolon, ";", "%3B");
40 : slugify_test!(equal, "=", "%3D");
41 : slugify_test!(percentage, "%", "%25");
|