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 MC_TESTABLE GString *exec_make_shell_string (const char *lc_data, const vfs_path_t *filename_vpath,
36 GString **buffer);
37
38
39
40 static struct test_paths
41 {
42 const char *lc_data;
43 const char *path;
44 const char *expected_buffer;
45 const char *expected_ret;
46 } test_paths[] = { { "/foo/bar/hello_world.c", "/does_not_appear", NULL, "/foo/bar/hello_world.c" },
47 { "%cd /tmp/file/with/a/longer/path/name/xyz.sock", "/never/used",
48 "/tmp/file/with/a/longer/path/name/xyz.sock", "" },
49 { "%f/utar://", "/path/to/foo.tar", NULL, "/path/to/foo.tar/utar://" },
50 { "%cd %f", "/path/to/directory", "/path/to/directory", "" },
51 { "%f%cd /dev", "/etc/mc", "/dev", "/etc/mc" },
52 { "%cd %f%view{ascii}/some/subdir", "/tmp", "/tmp/some/subdir", "" }
53
54 };
55
56
57
58 static void
59 setup (void)
60 {
61 str_init_strings (NULL);
62 vfs_init ();
63 vfs_init_localfs ();
64 }
65
66
67
68 START_PARAMETRIZED_TEST (shell_str_test, test_paths)
69 {
70 vfs_path_t *vpath;
71 GString *gs;
72 GString *buffer = NULL;
73
74 vpath = vfs_path_from_str (data->path);
75 gs = exec_make_shell_string (data->lc_data, vpath, &buffer);
76 vfs_path_free (vpath, FALSE);
77
78 if (buffer == NULL)
79 {
80 mctest_assert_null (data->expected_buffer);
81 }
82 else
83 {
84 mctest_assert_str_eq (buffer->str, data->expected_buffer);
85 }
86 mctest_assert_str_eq (gs->str, data->expected_ret);
87
88 if (buffer != NULL)
89 g_string_free (buffer, TRUE);
90 g_string_free (gs, TRUE);
91 }
92 END_PARAMETRIZED_TEST
93
94
95
96 int
97 main (void)
98 {
99 TCase *tc_core;
100
101 tc_core = tcase_create ("Core");
102 tcase_add_checked_fixture (tc_core, setup, NULL);
103
104
105 mctest_add_parameterized_test (tc_core, shell_str_test, test_paths);
106
107
108 return mctest_run_all (tc_core);
109 }
110
111