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