This source file includes following definitions.
- get_current_type
- do_cd
- quiet_quit_cmd
- expand_format
- init_subshell
- do_load_prompt
- shell_execute
- sync_tree
- setup
- teardown
- 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
27 #define TEST_SUITE_NAME "/src/filemanager"
28
29 #include "tests/mctest.h"
30
31 #include <stdio.h>
32
33 #include "lib/vfs/path.h"
34 #include "src/filemanager/layout.h"
35 #include "src/filemanager/midnight.h"
36 #include "src/filemanager/tree.h"
37 #ifdef ENABLE_SUBSHELL
38 #include "src/subshell/subshell.h"
39 #endif
40
41 #include "src/filemanager/command.c"
42
43
44
45 gboolean command_prompt = FALSE;
46 #ifdef ENABLE_SUBSHELL
47 enum subshell_state_enum subshell_state = INACTIVE;
48 #endif
49 int quit = 0;
50 WPanel *current_panel = NULL;
51
52 panel_view_mode_t
53 get_current_type (void)
54 {
55 return view_listing;
56 }
57
58 gboolean
59 do_cd (const vfs_path_t * new_dir_vpath, enum cd_enum cd_type)
60 {
61 (void) new_dir_vpath;
62 (void) cd_type;
63
64 return TRUE;
65 }
66
67 gboolean
68 quiet_quit_cmd (void)
69 {
70 return FALSE;
71 }
72
73 char *
74 expand_format (const WEdit * edit_widget, char c, gboolean do_quote)
75 {
76 (void) edit_widget;
77 (void) c;
78 (void) do_quote;
79
80 return NULL;
81 }
82
83 #ifdef ENABLE_SUBSHELL
84 void
85 init_subshell (void)
86 {
87 }
88
89 gboolean
90 do_load_prompt (void)
91 {
92 return TRUE;
93 }
94 #endif
95
96 void
97 shell_execute (const char *command, int flags)
98 {
99 (void) command;
100 (void) flags;
101 }
102
103 void
104 sync_tree (const vfs_path_t * vpath)
105 {
106 (void) vpath;
107 }
108
109
110
111 static void
112 setup (void)
113 {
114 }
115
116 static void
117 teardown (void)
118 {
119 }
120
121
122 #define check_examine_cd(input, etalon) \
123 { \
124 result = examine_cd (input); \
125 fail_unless (strcmp (result, etalon) == 0, \
126 "\ninput (%s)\nactial (%s) not equal to\netalon (%s)", input, result, etalon); \
127 g_free (result); \
128 }
129
130
131 START_TEST (test_examine_cd)
132
133 {
134 char *result;
135
136 g_setenv ("AAA", "aaa", TRUE);
137
138 check_examine_cd ("/test/path", "/test/path");
139
140 check_examine_cd ("$AAA", "aaa");
141 check_examine_cd ("${AAA}", "aaa");
142 check_examine_cd ("$AAA/test", "aaa/test");
143 check_examine_cd ("${AAA}/test", "aaa/test");
144
145 check_examine_cd ("/$AAA", "/aaa");
146 check_examine_cd ("/${AAA}", "/aaa");
147 check_examine_cd ("/$AAA/test", "/aaa/test");
148 check_examine_cd ("/${AAA}/test", "/aaa/test");
149
150 check_examine_cd ("/test/path/$AAA", "/test/path/aaa");
151 check_examine_cd ("/test/path/$AAA/test2", "/test/path/aaa/test2");
152 check_examine_cd ("/test/path/test1$AAA/test2", "/test/path/test1aaa/test2");
153
154 check_examine_cd ("/test/path/${AAA}", "/test/path/aaa");
155 check_examine_cd ("/test/path/${AAA}/test2", "/test/path/aaa/test2");
156 check_examine_cd ("/test/path/${AAA}test2", "/test/path/aaatest2");
157 check_examine_cd ("/test/path/test1${AAA}", "/test/path/test1aaa");
158 check_examine_cd ("/test/path/test1${AAA}test2", "/test/path/test1aaatest2");
159
160 check_examine_cd ("/test/path/\\$AAA", "/test/path/$AAA");
161 check_examine_cd ("/test/path/\\$AAA/test2", "/test/path/$AAA/test2");
162 check_examine_cd ("/test/path/test1\\$AAA", "/test/path/test1$AAA");
163
164 check_examine_cd ("/test/path/\\${AAA}", "/test/path/${AAA}");
165 check_examine_cd ("/test/path/\\${AAA}/test2", "/test/path/${AAA}/test2");
166 check_examine_cd ("/test/path/\\${AAA}test2", "/test/path/${AAA}test2");
167 check_examine_cd ("/test/path/test1\\${AAA}test2", "/test/path/test1${AAA}test2");
168 }
169
170 END_TEST
171
172
173
174
175 int
176 main (void)
177 {
178 int number_failed;
179
180 Suite *s = suite_create (TEST_SUITE_NAME);
181 TCase *tc_core = tcase_create ("Core");
182 SRunner *sr;
183
184 tcase_add_checked_fixture (tc_core, setup, teardown);
185
186
187 tcase_add_test (tc_core, test_examine_cd);
188
189
190 suite_add_tcase (s, tc_core);
191 sr = srunner_create (s);
192 srunner_set_log (sr, "examine_cd.log");
193 srunner_run_all (sr, CK_ENV);
194 number_failed = srunner_ntests_failed (sr);
195 srunner_free (sr);
196
197 return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
198 }
199
200