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/vfs/path.h"
31
32
33
34
35 static void
36 setup (void)
37 {
38 }
39
40
41
42
43 static void
44 teardown (void)
45 {
46 }
47
48
49
50
51 static const struct test_vfs_get_encoding_ds
52 {
53 const char *path;
54 const char *expected_encoding;
55 } test_vfs_get_encoding_ds[] = {
56 {
57
58 "",
59 NULL,
60 },
61 {
62
63 "aaaa",
64 NULL,
65 },
66 {
67
68 "/aaaa",
69 NULL,
70 },
71 {
72
73 "aaaa/bbbb",
74 NULL,
75 },
76 {
77
78 "/aaaa/bbbb",
79 NULL,
80 },
81 {
82
83 "#enc:UTF-8/aaaa",
84 "UTF-8",
85 },
86 {
87
88 "/#enc:UTF-8/aaaa",
89 "UTF-8",
90 },
91 {
92
93 "/aaaa/#enc:UTF-8/bbbb",
94 "UTF-8",
95 },
96 {
97
98 "/aaaa/#enc:UTF-8/bbbb/#enc:KOI8-R",
99 "KOI8-R",
100 },
101 {
102
103 "/aaaa/#enc:UTF-8/bbbb/#enc:KOI8-R/cccc",
104 "KOI8-R",
105 },
106 {
107
108 "/aaaa/#enc:UTF-8/bbbb/cccc#enc:KOI8-R/dddd",
109 "UTF-8",
110 },
111 {
112
113 "/#enc:UTF-8/bbbb/cccc#enc:KOI8-R/dddd",
114 "UTF-8",
115 },
116 {
117
118 "#enc:UTF-8/bbbb/cccc#enc:KOI8-R/dddd",
119 "UTF-8",
120 },
121 {
122
123 "aaaa#enc:UTF-8/bbbb/cccc#enc:KOI8-R/dddd",
124 NULL,
125 },
126 {
127
128 "/aaaa/#enc:UTF-8/bbbb/#enc:KOI8-R#enc:CP866/cccc",
129 "KOI8-R#enc:CP866",
130 },
131 };
132
133
134 START_PARAMETRIZED_TEST (test_vfs_get_encoding, test_vfs_get_encoding_ds)
135 {
136
137 char *actual_encoding;
138
139
140 actual_encoding = vfs_get_encoding (data->path, -1);
141
142
143 mctest_assert_str_eq (actual_encoding, data->expected_encoding);
144
145 g_free (actual_encoding);
146 }
147 END_PARAMETRIZED_TEST
148
149
150
151 int
152 main (void)
153 {
154 TCase *tc_core;
155
156 tc_core = tcase_create ("Core");
157
158 tcase_add_checked_fixture (tc_core, setup, teardown);
159
160
161 mctest_add_parameterized_test (tc_core, test_vfs_get_encoding, test_vfs_get_encoding_ds);
162
163
164 return mctest_run_all (tc_core);
165 }
166
167