6 #include "mock_prefs_common_get_use_shred.h"
7 #include "mock_prefs_common_get_flush_metadata.h"
9 struct td_get_uri_part {
15 struct td_get_uri_part td_get_uri_basic = {
16 "http://www.example.com", TRUE, 22
18 struct td_get_uri_part td_get_uri_slash = {
19 "http://www.example.com/", TRUE, 23
21 struct td_get_uri_part td_get_uri_question = {
22 "http://www.example.com/foo?", TRUE, 27
24 struct td_get_uri_part td_get_uri_parenthesis = {
25 "http://www.example.com/f(o)o", TRUE, 28
27 struct td_get_uri_part td_get_uri_brace = {
28 "http://www.example.com/f[oo", TRUE, 24
30 struct td_get_uri_part td_get_uri_umlaut = {
31 "http://www.examöple.com", TRUE, 24
33 struct td_get_uri_part td_get_uri_kanji = {
34 "http://www.漢字.com", TRUE, 21
36 struct td_get_uri_part td_get_uri_nonprintable = {
37 "http://www.exam\x01ple.com", TRUE, 15
40 #define URI "http://www.example.com"
42 test_utils_get_uri_part_nowhitespace()
45 gchar *str = g_strdup("Nowhitespace"URI"nowhitespace");
48 ret = get_uri_part(str, str + 12, &bp, &ep, FALSE);
51 g_assert_true(ep == str + strlen(str));
57 test_utils_get_uri_part_whitespace()
60 gchar *str = g_strdup("Whitespace "URI" whitespace");
63 ret = get_uri_part(str, str + 11, &bp, &ep, FALSE);
66 g_assert_true(ep == bp + strlen(URI));
73 test_utils_get_uri_part(gconstpointer user_data)
75 const struct td_get_uri_part *data = (struct td_get_uri_part *)user_data;
79 ret = get_uri_part(data->str, data->str, &bp, &ep, FALSE);
84 g_assert_true(ret == data->ret);
85 g_assert_true(ep >= bp);
86 g_assert_true(bp + data->uri_length == ep);
90 main(int argc, char *argv[])
92 g_test_init(&argc, &argv, NULL);
94 g_test_add_func("/common/utils/get_uri_part/nowhitespace",
95 test_utils_get_uri_part_nowhitespace);
96 g_test_add_func("/common/utils/get_uri_part/whitespace",
97 test_utils_get_uri_part_whitespace);
99 g_test_add_data_func("/common/utils/get_uri_part/basic",
101 test_utils_get_uri_part);
102 g_test_add_data_func("/common/utils/get_uri_part/slash",
104 test_utils_get_uri_part);
105 g_test_add_data_func("/common/utils/get_uri_part/question",
106 &td_get_uri_question,
107 test_utils_get_uri_part);
108 g_test_add_data_func("/common/utils/get_uri_part/parenthesis",
109 &td_get_uri_parenthesis,
110 test_utils_get_uri_part);
111 g_test_add_data_func("/common/utils/get_uri_part/brace",
113 test_utils_get_uri_part);
114 g_test_add_data_func("/common/utils/get_uri_part/umlaut",
116 test_utils_get_uri_part);
117 g_test_add_data_func("/common/utils/get_uri_part/kanji",
119 test_utils_get_uri_part);
120 g_test_add_data_func("/common/utils/get_uri_part/nonprintable",
121 &td_get_uri_nonprintable,
122 test_utils_get_uri_part);