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/mcconfig"
27
28 #include "tests/mctest.h"
29
30 #include "lib/strutil.h"
31 #include "lib/vfs/vfs.h"
32 #include "lib/fileloc.h"
33
34 #include "lib/mcconfig.h"
35 #include "src/vfs/local/local.c"
36
37 #define HOME_DIR "/home/testuser"
38
39 #define CONF_MAIN HOME_DIR PATH_SEP_STR ".config"
40 #define CONF_DATA HOME_DIR PATH_SEP_STR ".local" PATH_SEP_STR "share"
41 #define CONF_CACHE HOME_DIR PATH_SEP_STR ".cache"
42
43
44
45
46 static void
47 setup (void)
48 {
49 g_setenv ("HOME", HOME_DIR, TRUE);
50 g_setenv ("XDG_CONFIG_HOME", CONF_MAIN, TRUE);
51 g_setenv ("XDG_DATA_HOME", CONF_DATA, TRUE);
52 g_setenv ("XDG_CACHE_HOME", CONF_CACHE, TRUE);
53 str_init_strings ("UTF-8");
54 vfs_init ();
55 vfs_init_localfs ();
56 }
57
58
59
60
61 static void
62 teardown (void)
63 {
64 vfs_shut ();
65 str_uninit_strings ();
66 }
67
68
69
70
71
72 static const struct test_user_config_paths_ds
73 {
74 const char *input_base_dir;
75 const char *input_file_name;
76 } test_user_config_paths_ds[] =
77 {
78 {
79 CONF_MAIN,
80 MC_CONFIG_FILE
81 },
82 {
83 CONF_MAIN,
84 MC_FHL_INI_FILE
85 },
86 {
87 CONF_MAIN,
88 MC_HOTLIST_FILE
89 },
90 {
91 CONF_MAIN,
92 GLOBAL_KEYMAP_FILE
93 },
94 {
95 CONF_MAIN,
96 MC_USERMENU_FILE
97 },
98 {
99 CONF_DATA,
100 EDIT_SYNTAX_FILE
101 },
102 {
103 CONF_MAIN,
104 EDIT_HOME_MENU
105 },
106 {
107 CONF_MAIN,
108 MC_PANELS_FILE
109 },
110 {
111 CONF_MAIN,
112 MC_EXT_FILE
113 },
114 {
115 CONF_DATA,
116 MC_SKINS_DIR
117 },
118 {
119 CONF_DATA,
120 VFS_SHELL_PREFIX
121 },
122 {
123 CONF_DATA,
124 MC_ASHRC_FILE
125 },
126 {
127 CONF_DATA,
128 MC_BASHRC_FILE
129 },
130 {
131 CONF_DATA,
132 MC_INPUTRC_FILE
133 },
134 {
135 CONF_DATA,
136 MC_ZSHRC_FILE
137 },
138 {
139 CONF_DATA,
140 MC_EXTFS_DIR
141 },
142 {
143 CONF_DATA,
144 MC_HISTORY_FILE
145 },
146 {
147 CONF_DATA,
148 MC_FILEPOS_FILE
149 },
150 {
151 CONF_DATA,
152 EDIT_HOME_CLIP_FILE
153 },
154 {
155 CONF_DATA,
156 MC_MACRO_FILE
157 },
158 {
159 CONF_CACHE,
160 "mc.log"
161 },
162 {
163 CONF_CACHE,
164 MC_TREESTORE_FILE
165 },
166 {
167 CONF_CACHE,
168 EDIT_HOME_TEMP_FILE
169 },
170 {
171 CONF_CACHE,
172 EDIT_HOME_BLOCK_FILE
173 },
174 };
175
176
177
178
179 START_PARAMETRIZED_TEST (test_user_config_paths, test_user_config_paths_ds)
180
181 {
182
183 char *actual_result;
184
185
186 actual_result = mc_config_get_full_path (data->input_file_name);
187
188
189 {
190 char *expected_file_path;
191
192 expected_file_path =
193 g_build_filename (data->input_base_dir, MC_USERCONF_DIR, data->input_file_name,
194 (char *) NULL);
195 mctest_assert_str_eq (actual_result, expected_file_path);
196 g_free (expected_file_path);
197 }
198 g_free (actual_result);
199 }
200
201 END_PARAMETRIZED_TEST
202
203
204
205
206 int
207 main (void)
208 {
209 TCase *tc_core;
210
211 tc_core = tcase_create ("Core");
212
213 tcase_add_checked_fixture (tc_core, setup, teardown);
214
215
216 mctest_add_parameterized_test (tc_core, test_user_config_paths, test_user_config_paths_ds);
217
218
219 return mctest_run_all (tc_core);
220 }
221
222