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
75 static const struct test_path_equal_ds
76 {
77 const char *input_path1;
78 const char *input_path2;
79 const gboolean expected_result;
80 } test_path_equal_ds[] =
81 {
82 {
83 NULL,
84 NULL,
85 FALSE
86 },
87 {
88 NULL,
89 "/test/path",
90 FALSE
91 },
92 {
93 "/test/path",
94 NULL,
95 FALSE
96 },
97 {
98 "/test/path",
99 "/test/path",
100 TRUE
101 },
102 #ifdef HAVE_CHARSET
103 {
104 "/#enc:KOI8-R/тестовый/путь",
105 "/тестовый/путь",
106 FALSE
107 },
108 {
109 "/тестовый/путь",
110 "/#enc:KOI8-R/тестовый/путь",
111 FALSE
112 },
113 {
114 "/#enc:KOI8-R/тестовый/путь",
115 "/#enc:KOI8-R/тестовый/путь",
116 TRUE
117 },
118 #endif
119 };
120
121
122
123
124 START_PARAMETRIZED_TEST (test_path_equal, test_path_equal_ds)
125
126 {
127
128 vfs_path_t *vpath1, *vpath2;
129 gboolean actual_result;
130
131 vpath1 = vfs_path_from_str (data->input_path1);
132 vpath2 = vfs_path_from_str (data->input_path2);
133
134
135 actual_result = vfs_path_equal (vpath1, vpath2);
136
137
138 ck_assert_int_eq (actual_result, data->expected_result);
139
140 vfs_path_free (vpath1, TRUE);
141 vfs_path_free (vpath2, TRUE);
142 }
143
144 END_PARAMETRIZED_TEST
145
146
147
148
149
150
151 static const struct test_path_equal_len_ds
152 {
153 const char *input_path1;
154 const char *input_path2;
155 const size_t input_length;
156 const gboolean expected_result;
157 } test_path_equal_len_ds[] =
158 {
159 {
160 NULL,
161 NULL,
162 0,
163 FALSE
164 },
165 {
166 NULL,
167 NULL,
168 100,
169 FALSE
170 },
171 {
172 NULL,
173 "/тестовый/путь",
174 10,
175 FALSE
176 },
177 {
178 "/тестовый/путь",
179 NULL,
180 10,
181 FALSE
182 },
183 {
184 "/тестовый/путь",
185 "/тестовый/путь",
186 10,
187 TRUE
188 },
189 {
190 "/тест/овый/путь",
191 "/тестовый/путь",
192 8,
193 TRUE
194 },
195 {
196 "/тест/овый/путь",
197 "/тестовый/путь",
198 10,
199 FALSE
200 },
201 {
202 "/тестовый/путь",
203 "/тест/овый/путь",
204 10,
205 FALSE
206 },
207 };
208
209
210
211
212 START_PARAMETRIZED_TEST (test_path_equal_len, test_path_equal_len_ds)
213
214 {
215
216 vfs_path_t *vpath1, *vpath2;
217 gboolean actual_result;
218
219 vpath1 = vfs_path_from_str (data->input_path1);
220 vpath2 = vfs_path_from_str (data->input_path2);
221
222
223 actual_result = vfs_path_equal_len (vpath1, vpath2, data->input_length);
224
225
226 ck_assert_int_eq (actual_result, data->expected_result);
227
228 vfs_path_free (vpath1, TRUE);
229 vfs_path_free (vpath2, TRUE);
230 }
231
232 END_PARAMETRIZED_TEST
233
234
235
236
237 int
238 main (void)
239 {
240 TCase *tc_core;
241
242 tc_core = tcase_create ("Core");
243
244 tcase_add_checked_fixture (tc_core, setup, teardown);
245
246
247 mctest_add_parameterized_test (tc_core, test_path_equal, test_path_equal_ds);
248 mctest_add_parameterized_test (tc_core, test_path_equal_len, test_path_equal_len_ds);
249
250
251 return mctest_run_all (tc_core);
252 }
253
254