Fixed exec_get_export_variables_ext test
[midnight-commander.git] / tests / src / filemanager / examine_cd.c
blob0ebf1ca2e8f2fbe3c79f1420862344158bc19bfd
1 /*
2 src/filemanager - examine_cd() function testing
4 Copyright (C) 2012
5 The Free Software Foundation, Inc.
7 Written by:
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"
28 #include <config.h>
30 #include <check.h>
32 #include <stdio.h>
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 */
51 int quit = 0;
52 WPanel *current_panel = NULL;
54 panel_view_mode_t
55 get_current_type (void)
57 return view_listing;
60 gboolean
61 do_cd (const vfs_path_t * new_dir_vpath, enum cd_enum cd_type)
63 (void) new_dir_vpath;
64 (void) cd_type;
66 return TRUE;
69 gboolean
70 quiet_quit_cmd (void)
72 return FALSE;
75 char *
76 expand_format (struct WEdit *edit_widget, char c, gboolean do_quote)
78 (void) edit_widget;
79 (void) c;
80 (void) do_quote;
82 return NULL;
85 #ifdef ENABLE_SUBSHELL
86 void
87 init_subshell (void)
91 gboolean
92 do_load_prompt (void)
94 return TRUE;
96 #endif /* ENABLE_SUBSHELL */
98 void
99 shell_execute (const char *command, int flags)
101 (void) command;
102 (void) flags;
105 void
106 sync_tree (const char *pathname)
108 (void) pathname;
111 /* --------------------------------------------------------------------------------------------- */
113 static void
114 setup (void)
118 static void
119 teardown (void)
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); \
129 g_free (result); \
132 START_TEST (test_examine_cd)
134 char *result;
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");
159 END_TEST
161 /* --------------------------------------------------------------------------------------------- */
164 main (void)
166 int number_failed;
168 Suite *s = suite_create (TEST_SUITE_NAME);
169 TCase *tc_core = tcase_create ("Core");
170 SRunner *sr;
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);
183 srunner_free (sr);
185 return (number_failed == 0) ? 0 : 1;
188 /* --------------------------------------------------------------------------------------------- */