|
1 | 1 | classdef TestFilePure < matlab.unittest.TestCase
|
2 | 2 |
|
3 | 3 | properties (ClassSetupParameter)
|
4 |
| - classToTest = {"TestFilePure"}; |
| 4 | +classToTest = {"TestFilePure"}; |
5 | 5 | end
|
6 | 6 |
|
7 | 7 | properties (TestParameter)
|
8 |
| -p_relative_to |
9 |
| -p_proximate_to |
| 8 | + |
10 | 9 | p_is_absolute
|
11 | 10 | in_filename = {"", "/a/b/c", "/a/b/c/", "a/b/c.txt", "a/b/c.txt.gz"}
|
12 | 11 | ref_filename = {"", "c", "", "c.txt", "c.txt.gz"}
|
13 | 12 |
|
14 |
| -p_is_subdir |
15 | 13 | p_parent
|
16 | 14 |
|
17 | 15 | p_join = {{"", "", ""}, ...
|
|
44 | 42 | tobj
|
45 | 43 | end
|
46 | 44 |
|
| 45 | + |
47 | 46 | methods (TestParameterDefinition, Static)
|
48 |
| -function [p_relative_to, p_proximate_to, p_root, p_root_name, p_parent] = init_relative_to(classToTest) %#ok<INUSD> |
| 47 | + |
| 48 | +function [p_root, p_root_name, p_parent] = init_relative_to(classToTest) %#ok<INUSD> |
49 | 49 |
|
50 | 50 | p_root = {{"", ""}, ...
|
51 | 51 | {"a/b", ""}, ...
|
|
77 | 77 | {"c:\a/b", "c:\a"}
|
78 | 78 | };
|
79 | 79 |
|
80 |
| -p_relative_to = {{"", "", "."}, ... |
81 |
| -{"Hello", "Hello", "."}, ... |
82 |
| -{"Hello", "Hello/", "."}, ... |
83 |
| -{"a/./b", "a/b", "."}, ... |
84 |
| -{"a/b", "a/./b", "."}, ... |
85 |
| -{"./this/one", "./this/two", "../two"}, ... |
86 |
| -{"/path/same", "/path/same/hi/..", "hi/.."}, ... |
87 |
| -{"", "/", ""}, ... |
88 |
| -{"/", "", ""}, ... |
89 |
| -{"/", "/", "."}, ... |
90 |
| -{"/dev/null", "/dev/null", "."}, ... |
91 |
| -{"/a/b", "c", ""}, ... |
92 |
| -{"c", "/a/b", ""}, ... |
93 |
| -{"/a/b", "/a/b", "."}, ... |
94 |
| -{"/a/b", "/a", ".."}, ... |
95 |
| -{"/a/b/c/d", "/a/b", "../.."}, ... |
96 |
| -{"this/one", "this/two", "../two"}}; |
97 |
| -% NOTE: ".." in relative_to(base) is ambiguous including for python.pathlib, C++ <filesystem>, etc. |
98 |
| - |
99 |
| -p_proximate_to = p_relative_to; |
100 |
| - |
101 |
| -p_proximate_to{6}{3} = "/"; |
102 |
| -p_proximate_to{10}{3} = "c"; |
103 |
| -p_proximate_to{11}{3} = "/a/b"; |
104 |
| - |
105 |
| -if ispc |
106 |
| - |
107 |
| -p_relative_to = [p_relative_to, ... |
108 |
| -{{"c:\a\b", "c:/", "../.."}, ... |
109 |
| -{"c:\", "c:/a/b", "a/b"}, ... |
110 |
| -{"c:/a/b", "c:/a/b", "."}, ... |
111 |
| -{"c:/a/b", "c:/a", ".."}, ... |
112 |
| -{"c:\a/b\c/d", "c:/a\b", "../.."}, ... |
113 |
| -{"c:/path", "d:/path", ""}}]; |
114 |
| - |
115 |
| -p_proximate_to = p_relative_to; |
116 |
| -% NOTE: ".." in proximate_to(base) is ambiguous including for python.pathlib, C++ <filesystem>, etc |
117 |
| - |
118 |
| -p_proximate_to{8}{3} = "/"; |
119 |
| -p_proximate_to{12}{3} = "c"; |
120 |
| -p_proximate_to{13}{3} = "/a/b"; |
121 |
| - |
122 |
| -p_proximate_to{end}{3} = "d:/path"; |
123 |
| - |
124 | 80 | p_parent{12}{2} = "c:/";
|
125 | 81 | p_parent{13}{2} = "c:/";
|
126 | 82 | p_parent{14}{2} = "c:/a";
|
|
133 | 89 |
|
134 | 90 | p_root_name{4}{2} = "c:";
|
135 | 91 |
|
136 |
| -end % if ispc |
137 |
| - |
138 | 92 | end
|
139 | 93 |
|
140 | 94 |
|
|
149 | 103 |
|
150 | 104 | end
|
151 | 105 |
|
152 |
| - |
153 |
| -function [p_is_subdir] = init_is_subdir(classToTest) %#ok<INUSD> |
154 |
| - |
155 |
| -p_is_subdir = { |
156 |
| - {"a/b", "a/b", false}, ... |
157 |
| - {"a//b/c", "a/b", false}, ... |
158 |
| - {"a/b", "a//b", false}, ... |
159 |
| - {"a/./b/c", "a/b", false}, ... |
160 |
| - {"a/b/c", "a/./b", true}, ... |
161 |
| - {"a/b", "a/b/", false}, ... |
162 |
| - {"a/b", "a", true}, ... |
163 |
| - {"a/.c", "a", true} |
164 |
| -}; |
165 |
| -% NOTE: ".." in is_subdir (either argument) is ambiguous |
166 |
| - |
167 |
| -if ispc |
168 |
| - p_is_subdir{end+1} = {"c:\", "c:/", false}; |
169 |
| -else |
170 |
| - p_is_subdir{end+1} = {"/", "/", false}; |
171 |
| -end |
172 |
| - |
173 | 106 | end
|
174 | 107 |
|
175 |
| -end |
176 | 108 |
|
177 | 109 |
|
178 | 110 | methods (TestClassSetup)
|
@@ -271,23 +203,5 @@ function test_with_suffix(tc)
|
271 | 203 | end
|
272 | 204 |
|
273 | 205 |
|
274 |
| -function test_relative_to(tc, p_relative_to) |
275 |
| -tc.assumeTrue(stdlib.has_java) |
276 |
| -tc.verifyEqual(stdlib.relative_to(p_relative_to{1}, p_relative_to{2}), p_relative_to{3}, "relative_to(" + p_relative_to{1} + "," + p_relative_to{2}+")") |
277 |
| -end |
278 |
| - |
279 |
| - |
280 |
| -function test_proximate_to(tc, p_proximate_to) |
281 |
| -tc.assumeTrue(stdlib.has_java) |
282 |
| -tc.verifyEqual(stdlib.proximate_to(p_proximate_to{1}, p_proximate_to{2}), p_proximate_to{3}, "proximate_to(" + p_proximate_to{1} + "," + p_proximate_to{2}+")") |
283 |
| -end |
284 |
| - |
285 |
| - |
286 |
| -function test_is_subdir(tc, p_is_subdir) |
287 |
| -tc.assumeTrue(stdlib.has_java) |
288 |
| -tc.verifyEqual(stdlib.is_subdir(p_is_subdir{1}, p_is_subdir{2}), p_is_subdir{3}, "subdir(" + p_is_subdir{1} + "," + p_is_subdir{2} + ")") |
289 |
| -end |
290 |
| - |
291 |
| - |
292 | 206 | end
|
293 | 207 | end
|
0 commit comments