Skip to content

Commit cabc0e2

Browse files
committed
test: individual files
1 parent 1f8e138 commit cabc0e2

File tree

3 files changed

+55
-44
lines changed

3 files changed

+55
-44
lines changed

test/TestIsSubdir.m

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
classdef TestIsSubdir < matlab.unittest.TestCase
2+
3+
properties (TestParameter)
4+
p_is_prefix
5+
p_is_subdir
6+
end
7+
8+
methods (TestParameterDefinition, Static)
9+
10+
function [p_is_subdir, p_is_prefix] = init_is_subdir()
11+
12+
p_is_subdir = {
13+
{"a/b", "a/b", false}, ...
14+
{"a//b/c", "a/b", true}, ...
15+
{"a/b", "a//b", false}, ...
16+
{"a/./b/c", "a/b", false}, ...
17+
{"a/b/c", "a/./b", false}, ...
18+
{"a/b", "a/b/", false}, ...
19+
{"a/b", "a", true}, ...
20+
{"a/.c", "a", true}
21+
};
22+
% NOTE: ".." in is_subdir (either argument) is ambiguous
23+
24+
if ispc
25+
p_is_subdir{end+1} = {"c:\", "c:/", false};
26+
else
27+
p_is_subdir{end+1} = {"/", "/", false};
28+
end
29+
30+
p_is_prefix = p_is_subdir;
31+
p_is_prefix{1}{3} = true;
32+
p_is_prefix{2}{3} = false;
33+
p_is_prefix{3}{3} = true;
34+
p_is_prefix{6}{3} = true;
35+
p_is_prefix{7}{3} = false;
36+
p_is_prefix{8}{3} = false;
37+
p_is_prefix{9}{3} = true;
38+
39+
end
40+
41+
end
42+
43+
methods (Test)
44+
45+
function test_is_subdir(tc, p_is_subdir)
46+
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} + ")")
47+
end
48+
49+
function test_is_prefix(tc, p_is_prefix)
50+
tc.verifyEqual(stdlib.is_prefix(p_is_prefix{1}, p_is_prefix{2}), p_is_prefix{3}, "prefix(" + p_is_prefix{1} + "," + p_is_prefix{2} + ")")
51+
end
52+
53+
end
54+
55+
end

test/TestRelative.m

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
properties (TestParameter)
44
p_relative_to
55
p_proximate_to
6-
p_is_subdir
7-
p_is_prefix
86
end
97

108

@@ -59,44 +57,12 @@
5957

6058
end
6159

62-
63-
function [p_is_subdir, p_is_prefix] = init_is_subdir()
64-
65-
p_is_subdir = {
66-
{"a/b", "a/b", false}, ...
67-
{"a//b/c", "a/b", true}, ...
68-
{"a/b", "a//b", false}, ...
69-
{"a/./b/c", "a/b", false}, ...
70-
{"a/b/c", "a/./b", false}, ...
71-
{"a/b", "a/b/", false}, ...
72-
{"a/b", "a", true}, ...
73-
{"a/.c", "a", true}
74-
};
75-
% NOTE: ".." in is_subdir (either argument) is ambiguous
76-
77-
if ispc
78-
p_is_subdir{end+1} = {"c:\", "c:/", false};
79-
else
80-
p_is_subdir{end+1} = {"/", "/", false};
81-
end
82-
83-
p_is_prefix = p_is_subdir;
84-
p_is_prefix{1}{3} = true;
85-
p_is_prefix{2}{3} = false;
86-
p_is_prefix{3}{3} = true;
87-
p_is_prefix{6}{3} = true;
88-
p_is_prefix{7}{3} = false;
89-
p_is_prefix{8}{3} = false;
90-
p_is_prefix{9}{3} = true;
91-
9260
end
9361

94-
end
9562

9663

9764
methods (Test)
9865

99-
10066
function test_relative_to(tc, p_relative_to)
10167
tc.assumeTrue(stdlib.has_java)
10268
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}+")")
@@ -108,15 +74,6 @@ function test_proximate_to(tc, p_proximate_to)
10874
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}+")")
10975
end
11076

111-
112-
function test_is_subdir(tc, p_is_subdir)
113-
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} + ")")
114-
end
115-
116-
function test_is_prefix(tc, p_is_prefix)
117-
tc.verifyEqual(stdlib.is_prefix(p_is_prefix{1}, p_is_prefix{2}), p_is_prefix{3}, "prefix(" + p_is_prefix{1} + "," + p_is_prefix{2} + ")")
118-
end
119-
12077
end
12178

12279
end

test/TestWindowsCOM.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
function test_not(tc)
77
tc.verifyEmpty(stdlib.windows_shortname("not-exist"))
8-
98
end
109

1110
function test_short_folder(tc)

0 commit comments

Comments
 (0)