This source file includes following definitions.
- get_current_type
- panel_cd
- mc_config_get_home_dir
- 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
27 #define TEST_SUITE_NAME "/src/filemanager"
28
29 #include "tests/mctest.h"
30
31 #include "src/vfs/local/local.c"
32
33 #include "src/filemanager/cd.c"
34 #include "src/filemanager/panel.h"
35
36
37
38
39 static panel_view_mode_t get_current_type__return_value;
40
41
42 panel_view_mode_t
43 get_current_type (void)
44 {
45 return get_current_type__return_value;
46 }
47
48
49
50
51 static vfs_path_t *do_cd__new_dir_vpath__captured;
52
53 static enum cd_enum do_cd__cd_type__captured;
54
55 static gboolean do_cd__return_value;
56
57
58 gboolean
59 panel_cd (WPanel *panel, const vfs_path_t *new_dir_vpath, enum cd_enum cd_type)
60 {
61 (void) panel;
62
63 do_cd__new_dir_vpath__captured = vfs_path_clone (new_dir_vpath);
64 do_cd__cd_type__captured = cd_type;
65 return do_cd__return_value;
66 }
67
68
69
70
71 static const char *mc_config_get_home_dir__return_value;
72
73
74 const char *
75 mc_config_get_home_dir (void)
76 {
77 return mc_config_get_home_dir__return_value;
78 }
79
80
81
82
83 static void
84 setup (void)
85 {
86 str_init_strings (NULL);
87
88 vfs_init ();
89 vfs_init_localfs ();
90 vfs_setup_work_dir ();
91 do_cd__new_dir_vpath__captured = NULL;
92 }
93
94
95
96
97 static void
98 teardown (void)
99 {
100 vfs_path_free (do_cd__new_dir_vpath__captured, TRUE);
101 vfs_shut ();
102 str_uninit_strings ();
103 }
104
105
106
107
108
109 static const struct test_empty_mean_home_ds
110 {
111 const char *command;
112 } test_empty_mean_home_ds[] =
113 {
114 {
115 ""
116 },
117 {
118 " "
119 },
120 {
121 "\t\t\t\t\t\t\t\t\t\t\t"
122 },
123 {
124 " \t \t \t\t \t "
125 },
126 };
127
128
129
130
131 START_PARAMETRIZED_TEST (test_empty_mean_home, test_empty_mean_home_ds)
132
133 {
134
135 get_current_type__return_value = view_listing;
136 do_cd__return_value = TRUE;
137 mc_config_get_home_dir__return_value = "/home/test";
138
139
140 {
141 char *input_command;
142
143 input_command = g_strdup (data->command);
144 cd_to (input_command);
145 g_free (input_command);
146 }
147
148 mctest_assert_str_eq (mc_config_get_home_dir__return_value,
149 vfs_path_as_str (do_cd__new_dir_vpath__captured));
150 ck_assert_int_eq (do_cd__cd_type__captured, cd_parse_command);
151 }
152
153 END_PARAMETRIZED_TEST
154
155
156
157
158 int
159 main (void)
160 {
161 TCase *tc_core;
162
163 tc_core = tcase_create ("Core");
164
165 tcase_add_checked_fixture (tc_core, setup, teardown);
166
167
168 mctest_add_parameterized_test (tc_core, test_empty_mean_home, test_empty_mean_home_ds);
169
170
171 return mctest_run_all (tc_core);
172 }
173
174