This source file includes following definitions.
- 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
27 #define TEST_SUITE_NAME "lib/search/glob"
28
29 #include "tests/mctest.h"
30
31 #include "glob.c"
32
33
34
35
36
37 static const struct test_glob_translate_to_regex_ds
38 {
39 const char *input_value;
40 const char *expected_result;
41 } test_glob_translate_to_regex_ds[] =
42 {
43 {
44 "test*",
45 "test(.*)"
46 },
47 {
48 "t?es*t",
49 "t(.)es(.*)t"
50 },
51 {
52 "te{st}",
53 "te(st)"
54 },
55 {
56 "te{st|ts}",
57 "te(st|ts)"
58 },
59 {
60 "te{st,ts}",
61 "te(st|ts)"
62 },
63 {
64 "te[st]",
65 "te[st]"
66 },
67 {
68 "t,e.st",
69 "t,e\\.st"
70 },
71 {
72 "^t,e.+st+$",
73 "\\^t,e\\.\\+st\\+\\$"
74 },
75 {
76 "te!@#$%^&*()_+|\";:'{}:><?\\?\\*.,/[]|\\/st",
77 "te!@#\\$%\\^&(.*)\\(\\)_\\+|\";:'():><(.)\\?\\*\\.,/[]|\\/st"
78 },
79 };
80
81
82
83
84 START_PARAMETRIZED_TEST (test_glob_translate_to_regex, test_glob_translate_to_regex_ds)
85
86 {
87
88 GString *tmp = g_string_new (data->input_value);
89 GString *dest_str;
90
91
92 dest_str = mc_search__glob_translate_to_regex (tmp);
93
94
95 g_string_free (tmp, TRUE);
96
97 mctest_assert_str_eq (dest_str->str, data->expected_result);
98 g_string_free (dest_str, TRUE);
99 }
100
101 END_PARAMETRIZED_TEST
102
103
104
105
106 int
107 main (void)
108 {
109 TCase *tc_core;
110
111 tc_core = tcase_create ("Core");
112
113
114 mctest_add_parameterized_test (tc_core, test_glob_translate_to_regex,
115 test_glob_translate_to_regex_ds);
116
117
118 return mctest_run_all (tc_core);
119 }
120
121