This source file includes following definitions.
- setup
- 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 #define TEST_SUITE_NAME "/lib"
27
28 #include "tests/mctest.h"
29 #include "lib/global.h"
30 #include "lib/vfs/path.h"
31 #include "src/vfs/local/local.h"
32 #include "lib/strutil.h"
33 #include "src/filemanager/panel.h"
34
35 extern char buffer[BUF_1K];
36
37 MC_TESTABLE GString *exec_make_shell_string (const char *lc_data, const vfs_path_t *filename_vpath);
38
39
40
41 static struct test_paths
42 {
43 const char *lc_data;
44 const char *path;
45 const char *expected_buffer;
46 const char *expected_ret;
47 } test_paths[] = { { "/foo/bar/hello_world.c", "/does_not_appear", "", "/foo/bar/hello_world.c" },
48 { "%cd /tmp/file/with/a/longer/path/name/xyz.sock", "/never/used",
49 "/tmp/file/with/a/longer/path/name/xyz.sock", "" },
50 { "%f/utar://", "/path/to/foo.tar", "", "/path/to/foo.tar/utar://" },
51 { "%cd %f", "/path/to/directory", "/path/to/directory", "" },
52 { "%f%cd /dev", "/etc/mc", "/dev", "/etc/mc" },
53 { "%cd %f%view{ascii}/some/subdir", "/tmp", "/tmp/some/subdir", "" }
54
55 };
56
57
58
59 static void
60 setup (void)
61 {
62 str_init_strings (NULL);
63 vfs_init ();
64 vfs_init_localfs ();
65 }
66
67
68
69 START_PARAMETRIZED_TEST (shell_str_test, test_paths)
70 {
71 vfs_path_t *vpath;
72 GString *gs;
73
74 vpath = vfs_path_from_str (data->path);
75 gs = exec_make_shell_string (data->lc_data, vpath);
76 vfs_path_free (vpath, FALSE);
77
78 mctest_assert_str_eq (buffer, data->expected_buffer);
79 mctest_assert_str_eq (gs->str, data->expected_ret);
80
81 g_string_free (gs, TRUE);
82 }
83 END_PARAMETRIZED_TEST
84
85
86
87 int
88 main (void)
89 {
90 TCase *tc_core;
91
92 tc_core = tcase_create ("Core");
93 tcase_add_checked_fixture (tc_core, setup, NULL);
94
95
96 mctest_add_parameterized_test (tc_core, shell_str_test, test_paths);
97
98
99 return mctest_run_all (tc_core);
100 }
101
102