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 "src/filemanager/layout.h"
35 #include "src/filemanager/midnight.h"
36 #include "src/filemanager/tree.h"
37 #ifdef HAVE_SUBSHELL_SUPPORT
38 #include "src/subshell.h"
39 #endif /* HAVE_SUBSHELL_SUPPORT */
41 #include "src/filemanager/command.c"
43 /* --------------------------------------------------------------------------------------------- */
45 gboolean command_prompt
= FALSE
;
46 #ifdef HAVE_SUBSHELL_SUPPORT
47 enum subshell_state_enum subshell_state
= INACTIVE
;
48 #endif /* HAVE_SUBSHELL_SUPPORT */
50 WPanel
*current_panel
= NULL
;
53 get_current_type (void)
59 do_cd (const char *new_dir
, enum cd_enum cd_type
)
74 expand_format (struct WEdit
*edit_widget
, char c
, gboolean do_quote
)
83 #ifdef HAVE_SUBSHELL_SUPPORT
94 #endif /* HAVE_SUBSHELL_SUPPORT */
97 shell_execute (const char *command
, int flags
)
104 sync_tree (const char *pathname
)
109 /* --------------------------------------------------------------------------------------------- */
121 /* --------------------------------------------------------------------------------------------- */
122 #define check_examine_cd(input, etalon) \
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); \
130 START_TEST (test_examine_cd
)
134 g_setenv ("AAA", "aaa", TRUE
);
136 check_examine_cd ("/test/path", "/test/path");
138 check_examine_cd ("/test/path/$AAA", "/test/path/aaa");
139 check_examine_cd ("/test/path/$AAA/test2", "/test/path/aaa/test2");
140 check_examine_cd ("/test/path/test1$AAA/test2", "/test/path/test1aaa/test2");
142 check_examine_cd ("/test/path/${AAA}", "/test/path/aaa");
143 check_examine_cd ("/test/path/${AAA}/test2", "/test/path/aaa/test2");
144 check_examine_cd ("/test/path/${AAA}test2", "/test/path/aaatest2");
145 check_examine_cd ("/test/path/test1${AAA}", "/test/path/test1aaa");
146 check_examine_cd ("/test/path/test1${AAA}test2", "/test/path/test1aaatest2");
148 check_examine_cd ("/test/path/\\$AAA", "/test/path/$AAA");
149 check_examine_cd ("/test/path/\\$AAA/test2", "/test/path/$AAA/test2");
150 check_examine_cd ("/test/path/test1\\$AAA", "/test/path/test1$AAA");
152 check_examine_cd ("/test/path/\\${AAA}", "/test/path/${AAA}");
153 check_examine_cd ("/test/path/\\${AAA}/test2", "/test/path/${AAA}/test2");
154 check_examine_cd ("/test/path/\\${AAA}test2", "/test/path/${AAA}test2");
155 check_examine_cd ("/test/path/test1\\${AAA}test2", "/test/path/test1${AAA}test2");
159 /* --------------------------------------------------------------------------------------------- */
166 Suite
*s
= suite_create (TEST_SUITE_NAME
);
167 TCase
*tc_core
= tcase_create ("Core");
170 tcase_add_checked_fixture (tc_core
, setup
, teardown
);
172 /* Add new tests here: *************** */
173 tcase_add_test (tc_core
, test_examine_cd
);
174 /* *********************************** */
176 suite_add_tcase (s
, tc_core
);
177 sr
= srunner_create (s
);
178 srunner_set_log (sr
, "examine_cd.log");
179 srunner_run_all (sr
, CK_NORMAL
);
180 number_failed
= srunner_ntests_failed (sr
);
183 return (number_failed
== 0) ? 0 : 1;
186 /* --------------------------------------------------------------------------------------------- */