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 static const struct test_empty_mean_home_ds
109 {
110 const char *command;
111 } test_empty_mean_home_ds[] = {
112 { "" },
113 { " " },
114 { "\t\t\t\t\t\t\t\t\t\t\t" },
115 { " \t \t \t\t \t " },
116 };
117
118
119 START_PARAMETRIZED_TEST (test_empty_mean_home, test_empty_mean_home_ds)
120 {
121
122 get_current_type__return_value = view_listing;
123 do_cd__return_value = TRUE;
124 mc_config_get_home_dir__return_value = "/home/test";
125
126
127 {
128 char *input_command;
129
130 input_command = g_strdup (data->command);
131 cd_to (input_command);
132 g_free (input_command);
133 }
134
135 mctest_assert_str_eq (mc_config_get_home_dir__return_value,
136 vfs_path_as_str (do_cd__new_dir_vpath__captured));
137 ck_assert_int_eq (do_cd__cd_type__captured, cd_parse_command);
138 }
139 END_PARAMETRIZED_TEST
140
141
142
143 int
144 main (void)
145 {
146 TCase *tc_core;
147
148 tc_core = tcase_create ("Core");
149
150 tcase_add_checked_fixture (tc_core, setup, teardown);
151
152
153 mctest_add_parameterized_test (tc_core, test_empty_mean_home, test_empty_mean_home_ds);
154
155
156 return mctest_run_all (tc_core);
157 }
158
159