This source file includes following definitions.
- setup
- teardown
- 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 #define TEST_SUITE_NAME "/lib/vfs"
26
27 #include "tests/mctest.h"
28
29 #ifdef HAVE_CHARSET
30 # include "lib/charsets.h"
31 #endif
32
33 #include "lib/strutil.h"
34 #include "lib/vfs/xdirentry.h"
35 #include "lib/vfs/path.h"
36
37 #include "src/vfs/local/local.c"
38
39
40
41
42 static void
43 setup (void)
44 {
45 str_init_strings ("UTF-8");
46
47 vfs_init ();
48 vfs_init_localfs ();
49 vfs_setup_work_dir ();
50
51 #ifdef HAVE_CHARSET
52 mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
53 load_codepages_list ();
54 #endif
55 }
56
57
58
59
60 static void
61 teardown (void)
62 {
63 #ifdef HAVE_CHARSET
64 free_codepages_list ();
65 #endif
66
67 vfs_shut ();
68 str_uninit_strings ();
69 }
70
71
72
73
74 static const struct test_path_equal_ds
75 {
76 const char *input_path1;
77 const char *input_path2;
78 const gboolean expected_result;
79 } test_path_equal_ds[] = {
80 {
81
82 NULL,
83 NULL,
84 FALSE,
85 },
86 {
87
88 NULL,
89 "/test/path",
90 FALSE,
91 },
92 {
93
94 "/test/path",
95 NULL,
96 FALSE,
97 },
98 {
99
100 "/test/path",
101 "/test/path",
102 TRUE,
103 },
104 #ifdef HAVE_CHARSET
105 {
106
107 "/#enc:KOI8-R/тестовый/путь",
108 "/тестовый/путь",
109 FALSE,
110 },
111 {
112
113 "/тестовый/путь",
114 "/#enc:KOI8-R/тестовый/путь",
115 FALSE,
116 },
117 {
118
119 "/#enc:KOI8-R/тестовый/путь",
120 "/#enc:KOI8-R/тестовый/путь",
121 TRUE,
122 },
123 #endif
124 };
125
126
127 START_PARAMETRIZED_TEST (test_path_equal, test_path_equal_ds)
128 {
129
130 vfs_path_t *vpath1, *vpath2;
131 gboolean actual_result;
132
133 vpath1 = vfs_path_from_str (data->input_path1);
134 vpath2 = vfs_path_from_str (data->input_path2);
135
136
137 actual_result = vfs_path_equal (vpath1, vpath2);
138
139
140 ck_assert_int_eq (actual_result, data->expected_result);
141
142 vfs_path_free (vpath1, TRUE);
143 vfs_path_free (vpath2, TRUE);
144 }
145 END_PARAMETRIZED_TEST
146
147
148
149
150 static const struct test_path_equal_len_ds
151 {
152 const char *input_path1;
153 const char *input_path2;
154 const size_t input_length;
155 const gboolean expected_result;
156 } test_path_equal_len_ds[] = {
157 {
158
159 NULL,
160 NULL,
161 0,
162 FALSE,
163 },
164 {
165
166 NULL,
167 NULL,
168 100,
169 FALSE,
170 },
171 {
172
173 NULL,
174 "/тестовый/путь",
175 10,
176 FALSE,
177 },
178 {
179
180 "/тестовый/путь",
181 NULL,
182 10,
183 FALSE,
184 },
185 {
186
187 "/тестовый/путь",
188 "/тестовый/путь",
189 10,
190 TRUE,
191 },
192 {
193
194 "/тест/овый/путь",
195 "/тестовый/путь",
196 8,
197 TRUE,
198 },
199 {
200
201 "/тест/овый/путь",
202 "/тестовый/путь",
203 10,
204 FALSE,
205 },
206 {
207
208 "/тестовый/путь",
209 "/тест/овый/путь",
210 10,
211 FALSE,
212 },
213 };
214
215
216 START_PARAMETRIZED_TEST (test_path_equal_len, test_path_equal_len_ds)
217 {
218
219 vfs_path_t *vpath1, *vpath2;
220 gboolean actual_result;
221
222 vpath1 = vfs_path_from_str (data->input_path1);
223 vpath2 = vfs_path_from_str (data->input_path2);
224
225
226 actual_result = vfs_path_equal_len (vpath1, vpath2, data->input_length);
227
228
229 ck_assert_int_eq (actual_result, data->expected_result);
230
231 vfs_path_free (vpath1, TRUE);
232 vfs_path_free (vpath2, TRUE);
233 }
234 END_PARAMETRIZED_TEST
235
236
237
238 int
239 main (void)
240 {
241 TCase *tc_core;
242
243 tc_core = tcase_create ("Core");
244
245 tcase_add_checked_fixture (tc_core, setup, teardown);
246
247
248 mctest_add_parameterized_test (tc_core, test_path_equal, test_path_equal_ds);
249 mctest_add_parameterized_test (tc_core, test_path_equal_len, test_path_equal_len_ds);
250
251
252 return mctest_run_all (tc_core);
253 }
254
255