This source file includes following definitions.
- START_PARAMETRIZED_TEST
- START_PARAMETRIZED_TEST
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #define TEST_SUITE_NAME "/lib/util"
27
28 #include "tests/mctest.h"
29
30 #include "lib/util.h"
31
32
33
34
35 static const struct data_source1
36 {
37 gboolean input_quote_percent;
38 const char *input_string;
39
40 const char *expected_string;
41 } data_source1[] = {
42 { TRUE, "%%", "%%%%" },
43 { FALSE, "%%", "%%" },
44 };
45
46
47 START_PARAMETRIZED_TEST (quote_percent_test, data_source1)
48 {
49
50 char *actual_string;
51
52
53 actual_string = name_quote (data->input_string, data->input_quote_percent);
54
55
56 mctest_assert_str_eq (actual_string, data->expected_string);
57
58 g_free (actual_string);
59 }
60 END_PARAMETRIZED_TEST
61
62
63
64
65 static const struct data_source2
66 {
67 const char *input_string;
68
69 const char *expected_string;
70 } data_source2[] = {
71 { "", NULL },
72 { "-", "./-" },
73 { "blabla-", "blabla-" },
74 { "\r\n\t", "\\\r\\\n\\\t" },
75 { "'\\\";?|[]{}<>`!$&*()", "\\'\\\\\\\"\\;\\?\\|\\[\\]\\{\\}\\<\\>\\`\\!\\$\\&\\*\\(\\)" },
76 { "a b c ", "a\\ b\\ c\\ " },
77 { "#", "\\#" },
78 { "blabla#", "blabla#" },
79 { "~", "\\~" },
80 { "blabla~", "blabla~" },
81 {
82 NULL,
83 NULL,
84 },
85 };
86
87
88 START_PARAMETRIZED_TEST (name_quote_test, data_source2)
89 {
90
91 char *actual_string;
92
93
94 actual_string = name_quote (data->input_string, FALSE);
95
96
97 mctest_assert_str_eq (actual_string, data->expected_string);
98
99 g_free (actual_string);
100 }
101 END_PARAMETRIZED_TEST
102
103
104
105 int
106 main (void)
107 {
108 TCase *tc_core;
109
110 tc_core = tcase_create ("Core");
111
112
113 mctest_add_parameterized_test (tc_core, quote_percent_test, data_source1);
114 mctest_add_parameterized_test (tc_core, name_quote_test, data_source2);
115
116
117 return mctest_run_all (tc_core);
118 }
119
120