This source file includes following definitions.
- setup
- teardown
- START_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 #define TEST_SUITE_NAME "/src/filemanager"
27
28 #include "tests/mctest.h"
29
30 #include "lib/file-entry.h"
31
32 #include "src/vfs/local/local.c"
33
34 #include "src/filemanager/filemanager.c"
35
36 #include "src/filemanager/ext.c"
37
38
39
40
41
42
43
44 static void
45 setup (void)
46 {
47 str_init_strings (NULL);
48
49 vfs_init ();
50 vfs_init_localfs ();
51 vfs_setup_work_dir ();
52
53 mc_global.mc_run_mode = MC_RUN_FULL;
54 current_panel = g_new0 (WPanel, 1);
55 current_panel->cwd_vpath = vfs_path_from_str ("/home");
56 current_panel->dir.size = DIR_LIST_MIN_SIZE;
57 current_panel->dir.list = g_new0 (file_entry_t, current_panel->dir.size);
58 current_panel->dir.len = 0;
59 }
60
61 static void
62 teardown (void)
63 {
64 vfs_shut ();
65 str_uninit_strings ();
66 }
67
68
69
70
71 START_TEST (sanitize_variables)
72
73 {
74
75 vfs_path_t *filename_vpath;
76 GString *actual_string;
77 const char *expected_string;
78
79 current_panel->current = 0;
80 current_panel->dir.len = 3;
81 current_panel->dir.list[0].fname = g_string_new ("selected file.txt");
82 current_panel->dir.list[1].fname = g_string_new ("tagged file1.txt");
83 current_panel->dir.list[1].f.marked = 1;
84 current_panel->dir.list[2].fname = g_string_new ("tagged file2.txt");
85 current_panel->dir.list[2].f.marked = 1;
86
87
88 filename_vpath = vfs_path_from_str ("/tmp/blabla.txt");
89 actual_string = exec_get_export_variables (filename_vpath);
90 vfs_path_free (filename_vpath, TRUE);
91
92
93 expected_string = "\
94 MC_EXT_FILENAME=/tmp/blabla.txt\n\
95 export MC_EXT_FILENAME\n\
96 MC_EXT_BASENAME=selected\\ file.txt\n\
97 export MC_EXT_BASENAME\n\
98 MC_EXT_CURRENTDIR=/home\n\
99 export MC_EXT_CURRENTDIR\n\
100 MC_EXT_SELECTED=\"selected\\ file.txt\"\n\
101 export MC_EXT_SELECTED\n\
102 MC_EXT_ONLYTAGGED=\"tagged\\ file1.txt tagged\\ file2.txt \"\n\
103 export MC_EXT_ONLYTAGGED\n";
104
105 mctest_assert_str_eq (actual_string->str, expected_string);
106
107 g_string_free (actual_string, TRUE);
108 g_string_free (current_panel->dir.list[0].fname, TRUE);
109 g_string_free (current_panel->dir.list[1].fname, TRUE);
110 g_string_free (current_panel->dir.list[2].fname, TRUE);
111 }
112
113 END_TEST
114
115
116
117
118 int
119 main (void)
120 {
121 TCase *tc_core;
122
123 tc_core = tcase_create ("Core");
124
125 tcase_add_checked_fixture (tc_core, setup, teardown);
126
127
128 tcase_add_test (tc_core, sanitize_variables);
129
130
131 return mctest_run_all (tc_core);
132 }
133
134