8 #include "mock_prefs_common_get_use_shred.h"
9 #include "mock_prefs_common_get_flush_metadata.h"
11 struct td_get_uri_part
{
17 struct td_get_uri_part td_get_uri_basic
= {
18 "http://www.example.com", TRUE
, 22
20 struct td_get_uri_part td_get_uri_slash
= {
21 "http://www.example.com/", TRUE
, 23
23 struct td_get_uri_part td_get_uri_question
= {
24 "http://www.example.com/foo?", TRUE
, 27
26 struct td_get_uri_part td_get_uri_parenthesis
= {
27 "http://www.example.com/f(o)o", TRUE
, 28
29 struct td_get_uri_part td_get_uri_brace
= {
30 "http://www.example.com/f[oo", TRUE
, 24
32 struct td_get_uri_part td_get_uri_umlaut
= {
33 "http://www.examöple.com", TRUE
, 24
35 struct td_get_uri_part td_get_uri_kanji
= {
36 "http://www.漢字.com", TRUE
, 21
38 struct td_get_uri_part td_get_uri_nonprintable
= {
39 "http://www.exam\x01ple.com", TRUE
, 15
42 #define URI "http://www.example.com"
44 test_utils_get_uri_part_nowhitespace()
47 gchar
*str
= g_strdup("Nowhitespace"URI
"nowhitespace");
50 ret
= get_uri_part(str
, str
+ 12, &bp
, &ep
, FALSE
);
53 g_assert_true(ep
== str
+ strlen(str
));
59 test_utils_get_uri_part_whitespace()
62 gchar
*str
= g_strdup("Whitespace "URI
" whitespace");
65 ret
= get_uri_part(str
, str
+ 11, &bp
, &ep
, FALSE
);
68 g_assert_true(ep
== bp
+ strlen(URI
));
75 test_utils_get_uri_part(gconstpointer user_data
)
77 const struct td_get_uri_part
*data
= (struct td_get_uri_part
*)user_data
;
81 ret
= get_uri_part(data
->str
, data
->str
, &bp
, &ep
, FALSE
);
86 g_assert_true(ret
== data
->ret
);
87 g_assert_true(ep
>= bp
);
88 g_assert_true(bp
+ data
->uri_length
== ep
);
92 main(int argc
, char *argv
[])
94 g_test_init(&argc
, &argv
, NULL
);
96 g_test_add_func("/common/utils/get_uri_part/nowhitespace",
97 test_utils_get_uri_part_nowhitespace
);
98 g_test_add_func("/common/utils/get_uri_part/whitespace",
99 test_utils_get_uri_part_whitespace
);
101 g_test_add_data_func("/common/utils/get_uri_part/basic",
103 test_utils_get_uri_part
);
104 g_test_add_data_func("/common/utils/get_uri_part/slash",
106 test_utils_get_uri_part
);
107 g_test_add_data_func("/common/utils/get_uri_part/question",
108 &td_get_uri_question
,
109 test_utils_get_uri_part
);
110 g_test_add_data_func("/common/utils/get_uri_part/parenthesis",
111 &td_get_uri_parenthesis
,
112 test_utils_get_uri_part
);
113 g_test_add_data_func("/common/utils/get_uri_part/brace",
115 test_utils_get_uri_part
);
116 g_test_add_data_func("/common/utils/get_uri_part/umlaut",
118 test_utils_get_uri_part
);
119 g_test_add_data_func("/common/utils/get_uri_part/kanji",
121 test_utils_get_uri_part
);
122 g_test_add_data_func("/common/utils/get_uri_part/nonprintable",
123 &td_get_uri_nonprintable
,
124 test_utils_get_uri_part
);