This source file includes following definitions.
- setup
- teardown
- 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/vfs"
27
28 #include "tests/mctest.h"
29
30 #include "lib/strutil.h"
31 #include "lib/vfs/xdirentry.h"
32 #include "lib/vfs/path.c"
33
34 #include "src/vfs/local/local.c"
35
36 static struct vfs_class vfs_test_ops1, vfs_test_ops2, vfs_test_ops3;
37
38
39
40
41 static void
42 setup (void)
43 {
44 str_init_strings (NULL);
45
46 vfs_init ();
47 vfs_init_localfs ();
48 vfs_setup_work_dir ();
49
50 vfs_init_class (&vfs_test_ops1, "testfs1", VFSF_NOLINKS | VFSF_REMOTE, "test1");
51 vfs_register_class (&vfs_test_ops1);
52
53 vfs_init_class (&vfs_test_ops2, "testfs2", VFSF_UNKNOWN, "test2");
54 vfs_register_class (&vfs_test_ops2);
55
56 vfs_init_class (&vfs_test_ops3, "testfs3", VFSF_UNKNOWN, "test3");
57 vfs_register_class (&vfs_test_ops3);
58 }
59
60
61
62
63 static void
64 teardown (void)
65 {
66 vfs_shut ();
67 str_uninit_strings ();
68 }
69
70
71
72
73
74 static const struct test_vfs_split_ds
75 {
76 const char *input_string;
77 const char *expected_path;
78 const char *expected_local;
79 const char *expected_op;
80 const struct vfs_class *expected_result;
81 } test_vfs_split_ds[] =
82 {
83 {
84 "#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2/#test3:/qqq/www/eee.rr",
85 "#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2/",
86 "qqq/www/eee.rr",
87 "test3:",
88 &vfs_test_ops3
89 },
90 {
91 "#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2/",
92 "#test1:/bla-bla/some/path/",
93 "bla-bla/some/path2/",
94 "test2:",
95 &vfs_test_ops2
96 },
97 {
98 "#test1:/bla-bla/some/path/",
99 "",
100 "bla-bla/some/path/",
101 "test1:",
102 &vfs_test_ops1
103 },
104 {
105 "",
106 "",
107 NULL,
108 NULL,
109 NULL
110 },
111 {
112 "/local/path/#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2#test3:/qqq/www/eee.rr",
113 "/local/path/#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2",
114 "qqq/www/eee.rr",
115 "test3:",
116 &vfs_test_ops3
117 },
118 {
119 "/local/path/#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2",
120 "/local/path/#test1:/bla-bla/some/path/",
121 "bla-bla/some/path2",
122 "test2:",
123 &vfs_test_ops2
124 },
125 {
126 "/local/path/#test1:/bla-bla/some/path/",
127 "/local/path/",
128 "bla-bla/some/path/",
129 "test1:",
130 &vfs_test_ops1
131 },
132 {
133 "/local/path/",
134 "/local/path/",
135 NULL,
136 NULL,
137 NULL
138 },
139 {
140 "#test2:username:passwd@somehost.net/bla-bla/some/path2",
141 "",
142 "bla-bla/some/path2",
143 "test2:username:passwd@somehost.net",
144 &vfs_test_ops2
145 },
146 {
147 "/local/path/#test1:/bla-bla/some/path/#test2:username:p!a@s#s$w%d@somehost.net/bla-bla/some/path2",
148 "/local/path/#test1:/bla-bla/some/path/",
149 "bla-bla/some/path2",
150 "test2:username:p!a@s#s$w%d@somehost.net",
151 &vfs_test_ops2
152 },
153 {
154 "#test2:/bl#a-bl#a/so#me/pa#th2",
155 "",
156 "bl#a-bl#a/so#me/pa#th2",
157 "test2:",
158 &vfs_test_ops2
159 }
160 };
161
162
163
164
165 START_PARAMETRIZED_TEST (test_vfs_split, test_vfs_split_ds)
166
167 {
168
169 const char *local = NULL, *op = NULL;
170 struct vfs_class *actual_result;
171 char *path;
172
173 path = g_strdup (data->input_string);
174
175
176 actual_result = _vfs_split_with_semi_skip_count (path, &local, &op, 0);
177
178
179 mctest_assert_ptr_eq (actual_result, data->expected_result);
180 mctest_assert_str_eq (path, data->expected_path);
181 mctest_assert_str_eq (local, data->expected_local);
182 mctest_assert_str_eq (op, data->expected_op);
183 g_free (path);
184 }
185
186 END_PARAMETRIZED_TEST
187
188
189
190
191 int
192 main (void)
193 {
194 TCase *tc_core;
195
196 tc_core = tcase_create ("Core");
197
198 tcase_add_checked_fixture (tc_core, setup, teardown);
199
200
201 mctest_add_parameterized_test (tc_core, test_vfs_split, test_vfs_split_ds);
202
203
204 return mctest_run_all (tc_core);
205 }
206
207