This source file includes following definitions.
- run_mc_build_filename
- 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/util"
27
28 #include "tests/mctest.h"
29
30 #include "lib/strutil.h"
31 #include "lib/util.h"
32
33
34
35 static char *
36 run_mc_build_filename (int iteration)
37 {
38 switch (iteration)
39 {
40 case 0:
41 return mc_build_filename ("test", "path", (char *) NULL);
42 case 1:
43 return mc_build_filename ("/test", "path/", (char *) NULL);
44 case 2:
45 return mc_build_filename ("/test", "pa/th", (char *) NULL);
46 case 3:
47 return mc_build_filename ("/test", "#vfsprefix:", "path ", (char *) NULL);
48 case 4:
49 return mc_build_filename ("/test", "vfsprefix://", "path ", (char *) NULL);
50 case 5:
51 return mc_build_filename ("/test", "vfs/../prefix:///", "p\\///ath", (char *) NULL);
52 case 6:
53 return mc_build_filename ("/test", "path", "..", "/test", "path/", (char *) NULL);
54 case 7:
55 return mc_build_filename ("", "path", (char *) NULL);
56 case 8:
57 return mc_build_filename ("", "/path", (char *) NULL);
58 case 9:
59 return mc_build_filename ("path", "", (char *) NULL);
60 case 10:
61 return mc_build_filename ("/path", "", (char *) NULL);
62 case 11:
63 return mc_build_filename ("pa", "", "th", (char *) NULL);
64 case 12:
65 return mc_build_filename ("/pa", "", "/th", (char *) NULL);
66 default:
67 return NULL;
68 }
69 }
70
71
72 static const struct test_mc_build_filename_ds
73 {
74 const char *expected_result;
75 } test_mc_build_filename_ds[] = {
76 { "test/path" },
77 { "/test/path" },
78 { "/test/pa/th" },
79 { "/test/#vfsprefix:/path " },
80 { "/test/vfsprefix://path " },
81 { "/test/prefix://p\\/ath" },
82 { "/test/test/path" },
83 { "path" },
84 { "path" },
85 { "path" },
86 { "/path" },
87 { "pa/th" },
88 { "/pa/th" },
89 };
90
91
92 START_PARAMETRIZED_TEST (test_mc_build_filename, test_mc_build_filename_ds)
93 {
94
95 char *actual_result;
96
97
98 actual_result = run_mc_build_filename (_i);
99
100
101 mctest_assert_str_eq (actual_result, data->expected_result);
102
103 g_free (actual_result);
104 }
105 END_PARAMETRIZED_TEST
106
107
108
109 int
110 main (void)
111 {
112 TCase *tc_core;
113
114 tc_core = tcase_create ("Core");
115
116
117 mctest_add_parameterized_test (tc_core, test_mc_build_filename, test_mc_build_filename_ds);
118
119
120 return mctest_run_all (tc_core);
121 }
122
123