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