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 #include "lib/charsets.h"
30
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
38
39
40 static void
41 setup (void)
42 {
43 str_init_strings ("UTF-8");
44
45 vfs_init ();
46 vfs_init_localfs ();
47 vfs_setup_work_dir ();
48
49 mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
50 load_codepages_list ();
51 }
52
53
54
55
56 static void
57 teardown (void)
58 {
59 free_codepages_list ();
60 vfs_shut ();
61 str_uninit_strings ();
62 }
63
64
65
66 static const struct test_path_length_ds
67 {
68 const char *input_path;
69 const size_t expected_length_element_encoding;
70 const size_t expected_length_terminal_encoding;
71 } test_path_length_ds[] = {
72 {
73
74 NULL,
75 0,
76 0,
77 },
78 {
79
80 "/",
81 1,
82 1,
83 },
84 {
85
86 "/тестовый/путь",
87 26,
88 26,
89 },
90 {
91
92 "/#enc:KOI8-R/тестовый/путь",
93 14,
94 38,
95 },
96 };
97
98
99 START_PARAMETRIZED_TEST (test_path_length, test_path_length_ds)
100 {
101
102 vfs_path_t *vpath;
103 char *path;
104 size_t actual_length_terminal_encoding, actual_length_element_encoding;
105
106 vpath = vfs_path_from_str (data->input_path);
107 path = vpath != NULL ? vfs_path_get_by_index (vpath, 0)->path : NULL;
108
109
110 actual_length_terminal_encoding = vfs_path_len (vpath);
111 actual_length_element_encoding = path != NULL ? strlen (path) : 0;
112
113
114 ck_assert_int_eq (actual_length_terminal_encoding, data->expected_length_terminal_encoding);
115 ck_assert_int_eq (actual_length_element_encoding, data->expected_length_element_encoding);
116
117 vfs_path_free (vpath, TRUE);
118 }
119 END_PARAMETRIZED_TEST
120
121
122
123 int
124 main (void)
125 {
126 TCase *tc_core;
127
128 tc_core = tcase_create ("Core");
129
130 tcase_add_checked_fixture (tc_core, setup, teardown);
131
132
133 mctest_add_parameterized_test (tc_core, test_path_length, test_path_length_ds);
134
135
136 return mctest_run_all (tc_core);
137 }
138
139