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 #define TEST_SUITE_NAME "lib/search/regex"
27
28 #include "tests/mctest.h"
29
30 #include "regex.c"
31
32
33
34
35 static const struct test_regex_process_escape_sequence_ds
36 {
37 const char *input_from;
38 const replace_transform_type_t input_initial_flags;
39 const gboolean input_use_utf;
40 const char *expected_string;
41 } test_regex_process_escape_sequence_ds[] = {
42 {
43
44 "{101}",
45 REPLACE_T_NO_TRANSFORM,
46 FALSE,
47 "A",
48 },
49 {
50
51 "x42",
52 REPLACE_T_NO_TRANSFORM,
53 FALSE,
54 "B",
55 },
56 {
57
58 "x{444}",
59 REPLACE_T_NO_TRANSFORM,
60 FALSE,
61 "D",
62 },
63 {
64
65 "x{444}",
66 REPLACE_T_NO_TRANSFORM,
67 TRUE,
68 "ф",
69 },
70 {
71
72 "n",
73 REPLACE_T_NO_TRANSFORM,
74 FALSE,
75 "\n",
76 },
77 {
78
79 "t",
80 REPLACE_T_NO_TRANSFORM,
81 FALSE,
82 "\t",
83 },
84 {
85
86 "v",
87 REPLACE_T_NO_TRANSFORM,
88 FALSE,
89 "\v",
90 },
91 {
92
93 "b",
94 REPLACE_T_NO_TRANSFORM,
95 FALSE,
96 "\b",
97 },
98 {
99
100 "r",
101 REPLACE_T_NO_TRANSFORM,
102 FALSE,
103 "\r",
104 },
105 {
106
107 "f",
108 REPLACE_T_NO_TRANSFORM,
109 FALSE,
110 "\f",
111 },
112 {
113
114 "a",
115 REPLACE_T_NO_TRANSFORM,
116 FALSE,
117 "\a",
118 },
119 };
120
121
122 START_PARAMETRIZED_TEST (test_regex_process_escape_sequence, test_regex_process_escape_sequence_ds)
123 {
124
125 GString *actual_string;
126 replace_transform_type_t replace_flags = REPLACE_T_NO_TRANSFORM;
127
128 replace_flags = data->input_initial_flags;
129 actual_string = g_string_new ("");
130
131
132 mc_search_regex__process_escape_sequence (actual_string, data->input_from, -1, &replace_flags,
133 data->input_use_utf);
134
135
136 mctest_assert_str_eq (actual_string->str, data->expected_string);
137
138 g_string_free (actual_string, TRUE);
139 }
140 END_PARAMETRIZED_TEST
141
142
143
144 int
145 main (void)
146 {
147 TCase *tc_core;
148
149 tc_core = tcase_create ("Core");
150
151
152 mctest_add_parameterized_test (tc_core, test_regex_process_escape_sequence,
153 test_regex_process_escape_sequence_ds);
154
155
156 return mctest_run_all (tc_core);
157 }
158
159