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 #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 (NULL);
46
47 vfs_init ();
48 vfs_init_localfs ();
49 vfs_setup_work_dir ();
50
51 mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
52 #ifdef HAVE_CHARSET
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 static const struct test_path_length_ds
75 {
76 const char *input_path;
77 const size_t expected_length;
78 } test_path_length_ds[] =
79 {
80 {
81 NULL,
82 0
83 },
84 {
85 "/",
86 1
87 },
88 {
89 "/тестовый/путь",
90 26
91 },
92 #ifdef HAVE_CHARSET
93 {
94 "/#enc:KOI8-R/тестовый/путь",
95 38
96 },
97 #endif
98 };
99
100
101
102
103 START_PARAMETRIZED_TEST (test_path_length, test_path_length_ds)
104
105 {
106
107 vfs_path_t *vpath;
108 size_t actual_length;
109
110 vpath = vfs_path_from_str (data->input_path);
111
112
113 actual_length = vfs_path_len (vpath);
114
115
116 ck_assert_int_eq (actual_length, data->expected_length);
117
118 vfs_path_free (vpath, TRUE);
119 }
120
121 END_PARAMETRIZED_TEST
122
123
124
125
126 int
127 main (void)
128 {
129 TCase *tc_core;
130
131 tc_core = tcase_create ("Core");
132
133 tcase_add_checked_fixture (tc_core, setup, teardown);
134
135
136 mctest_add_parameterized_test (tc_core, test_path_length, test_path_length_ds);
137
138
139 return mctest_run_all (tc_core);
140 }
141
142