2 src/filemanager - examine_cd() function testing
5 The Free Software Foundation, Inc.
8 Andrew Borodin <aborodin@vmail.ru>, 2012
10 This file is part of the Midnight Commander.
12 The Midnight Commander is free software: you can redistribute it
13 and/or modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation, either version 3 of the License,
15 or (at your option) any later version.
17 The Midnight Commander is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #define TEST_SUITE_NAME "/src/filemanager"
34 #include "lib/global.h"
35 #include "lib/vfs/path.h"
36 #include "src/filemanager/layout.h"
37 #include "src/filemanager/midnight.h"
38 #include "src/filemanager/tree.h"
39 #ifdef ENABLE_SUBSHELL
40 #include "src/subshell.h"
41 #endif /* ENABLE_SUBSHELL */
43 #include "src/filemanager/command.c"
45 /* --------------------------------------------------------------------------------------------- */
47 gboolean command_prompt
= FALSE
;
48 #ifdef ENABLE_SUBSHELL
49 enum subshell_state_enum subshell_state
= INACTIVE
;
50 #endif /* ENABLE_SUBSHELL */
52 WPanel
*current_panel
= NULL
;
55 get_current_type (void)
61 do_cd (const vfs_path_t
* new_dir_vpath
, enum cd_enum cd_type
)
76 expand_format (struct WEdit
*edit_widget
, char c
, gboolean do_quote
)
85 #ifdef ENABLE_SUBSHELL
96 #endif /* ENABLE_SUBSHELL */
99 shell_execute (const char *command
, int flags
)
106 sync_tree (const char *pathname
)
111 /* --------------------------------------------------------------------------------------------- */
123 /* --------------------------------------------------------------------------------------------- */
124 #define check_examine_cd(input, etalon) \
126 result = examine_cd (input); \
127 fail_unless (strcmp (result, etalon) == 0, \
128 "\ninput (%s)\nactial (%s) not equal to\netalon (%s)", input, result, etalon); \
132 START_TEST (test_examine_cd
)
136 g_setenv ("AAA", "aaa", TRUE
);
138 check_examine_cd ("/test/path", "/test/path");
140 check_examine_cd ("/test/path/$AAA", "/test/path/aaa");
141 check_examine_cd ("/test/path/$AAA/test2", "/test/path/aaa/test2");
142 check_examine_cd ("/test/path/test1$AAA/test2", "/test/path/test1aaa/test2");
144 check_examine_cd ("/test/path/${AAA}", "/test/path/aaa");
145 check_examine_cd ("/test/path/${AAA}/test2", "/test/path/aaa/test2");
146 check_examine_cd ("/test/path/${AAA}test2", "/test/path/aaatest2");
147 check_examine_cd ("/test/path/test1${AAA}", "/test/path/test1aaa");
148 check_examine_cd ("/test/path/test1${AAA}test2", "/test/path/test1aaatest2");
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", "/test/path/test1$AAA");
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/${AAA}test2");
157 check_examine_cd ("/test/path/test1\\${AAA}test2", "/test/path/test1${AAA}test2");
161 /* --------------------------------------------------------------------------------------------- */
168 Suite
*s
= suite_create (TEST_SUITE_NAME
);
169 TCase
*tc_core
= tcase_create ("Core");
172 tcase_add_checked_fixture (tc_core
, setup
, teardown
);
174 /* Add new tests here: *************** */
175 tcase_add_test (tc_core
, test_examine_cd
);
176 /* *********************************** */
178 suite_add_tcase (s
, tc_core
);
179 sr
= srunner_create (s
);
180 srunner_set_log (sr
, "examine_cd.log");
181 srunner_run_all (sr
, CK_NORMAL
);
182 number_failed
= srunner_ntests_failed (sr
);
185 return (number_failed
== 0) ? 0 : 1;
188 /* --------------------------------------------------------------------------------------------- */