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