This source file includes following definitions.
- setup
- teardown
- START_TEST
- START_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/charsets.h"
31 #include "lib/strutil.h"
32 #include "lib/vfs/xdirentry.h"
33 #include "lib/vfs/path.h"
34
35 #include "src/vfs/local/local.c"
36
37 static struct vfs_class vfs_test_ops1, vfs_test_ops2, vfs_test_ops3;
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 vfs_init_class (&vfs_test_ops1, "testfs1", VFSF_NOLINKS | VFSF_REMOTE, "test1");
52 vfs_register_class (&vfs_test_ops1);
53
54 vfs_init_class (&vfs_test_ops2, "testfs2", VFSF_UNKNOWN, "test2");
55 vfs_register_class (&vfs_test_ops2);
56
57 vfs_init_class (&vfs_test_ops3, "testfs3", VFSF_UNKNOWN, "test3");
58 vfs_register_class (&vfs_test_ops3);
59
60 mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
61 load_codepages_list ();
62 }
63
64
65
66
67 static void
68 teardown (void)
69 {
70 free_codepages_list ();
71 vfs_shut ();
72 str_uninit_strings ();
73 }
74
75
76
77 #define ETALON_PATH_STR \
78 "/local/path/#test1:user:pass@some.host:12345/bla-bla/some/path/#test2/#enc:KOI8-R/" \
79 "bla-bla/some/path#test3/111/22/33"
80 #define ETALON_PATH_URL_STR \
81 "/local/path/test1://user:pass@some.host:12345/bla-bla/some/path/test2://#enc:KOI8-R/" \
82 "bla-bla/some/path/test3://111/22/33"
83 #define ETALON_SERIALIZED_PATH \
84 "g14:path-element-0" \
85 "p4:pathv12:/local/path/" \
86 "p10:class-namev7:localfs" \
87 "g14:path-element-1" \
88 "p4:pathv18:bla-bla/some/path/" \
89 "p10:class-namev7:testfs1" \
90 "p10:vfs_prefixv5:test1" \
91 "p4:userv4:user" \
92 "p8:passwordv4:pass" \
93 "p4:hostv9:some.host" \
94 "p4:portv5:12345" \
95 "g14:path-element-2" \
96 "p4:pathv17:bla-bla/some/path" \
97 "p10:class-namev7:testfs2" \
98 "p8:encodingv6:KOI8-R" \
99 "p10:vfs_prefixv5:test2" \
100 "g14:path-element-3" \
101 "p4:pathv9:111/22/33" \
102 "p10:class-namev7:testfs3" \
103 "p10:vfs_prefixv5:test3"
104
105 START_TEST (test_path_serialize)
106 {
107
108 vfs_path_t *vpath;
109 char *serialized_vpath;
110 GError *error = NULL;
111
112
113 vpath = vfs_path_from_str_flags (ETALON_PATH_STR, VPF_USE_DEPRECATED_PARSER);
114 serialized_vpath = vfs_path_serialize (vpath, &error);
115
116 vfs_path_free (vpath, TRUE);
117
118 if (error != NULL)
119 g_error_free (error);
120
121
122 mctest_assert_ptr_ne (serialized_vpath, NULL);
123 mctest_assert_str_eq (serialized_vpath, ETALON_SERIALIZED_PATH);
124 }
125 END_TEST
126
127
128
129 START_TEST (test_path_deserialize)
130 {
131
132 vfs_path_t *vpath;
133 GError *error = NULL;
134
135
136 vpath = vfs_path_deserialize (ETALON_SERIALIZED_PATH, &error);
137
138
139 mctest_assert_ptr_ne (vpath, NULL);
140 mctest_assert_str_eq (vfs_path_as_str (vpath), ETALON_PATH_URL_STR);
141
142 vfs_path_free (vpath, TRUE);
143 }
144 END_TEST
145
146
147
148 int
149 main (void)
150 {
151 TCase *tc_core;
152
153 tc_core = tcase_create ("Core");
154
155 tcase_add_checked_fixture (tc_core, setup, teardown);
156
157
158 tcase_add_test (tc_core, test_path_serialize);
159 tcase_add_test (tc_core, test_path_deserialize);
160
161
162 return mctest_run_all (tc_core);
163 }
164
165