Skip to content

Commit 79c3227

Browse files
committed
test: simplify by removing R2021a TestParameterDefinition
1 parent c9e4158 commit 79c3227

File tree

10 files changed

+155
-180
lines changed

10 files changed

+155
-180
lines changed

test/TestAbsolute.m

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,36 @@
22

33
properties (TestParameter)
44
use_java = num2cell(unique([stdlib.has_java(), false]))
5-
p1
6-
p2
5+
p1 = init1arg()
6+
p2 = init2arg()
77
end
88

9-
methods (TestParameterDefinition, Static)
10-
function [p1, p2] = init()
119

12-
td = stdlib.posix(pwd());
13-
r = td + "/hi";
10+
methods(Test)
1411

15-
p1 = {{"", td}, {"hi", r}, {"./hi", td + "/./hi"}, {"../hi", td + "/../hi"}};
16-
p2 = {{"", "", td}, {"", "hi", r}, {"hi", "", r}, {"there", "hi", td + "/hi/there"}};
12+
function test_absolute1arg(tc, p1)
13+
tc.verifyEqual(stdlib.absolute(p1{1}), p1{2})
14+
end
1715

16+
function test_absolute2arg(tc, p2, use_java)
17+
tc.verifyEqual(stdlib.absolute(p2{1}, p2{2}, false, use_java), p2{3})
1818
end
19+
1920
end
2021

22+
end
2123

22-
methods(Test)
2324

24-
function test_absolute_onearg(tc, p1)
25-
tc.verifyEqual(stdlib.absolute(p1{1}), p1{2})
26-
end
25+
function p = init1arg()
26+
td = stdlib.posix(pwd());
27+
r = td + "/hi";
2728

28-
function test_absolute_twoarg(tc, p2, use_java)
29-
tc.verifyEqual(stdlib.absolute(p2{1}, p2{2}, false, use_java), p2{3})
29+
p = {{"", td}, {"hi", r}, {"./hi", td + "/./hi"}, {"../hi", td + "/../hi"}};
3030
end
3131

32-
end
32+
function p = init2arg()
33+
td = stdlib.posix(pwd());
34+
r = td + "/hi";
3335

36+
p = {{"", "", td}, {"", "hi", r}, {"hi", "", r}, {"there", "hi", td + "/hi/there"}};
3437
end

test/TestFilePure.m

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,7 @@
11
classdef TestFilePure < matlab.unittest.TestCase
22

33
properties (TestParameter)
4-
p
5-
end
6-
7-
8-
methods (TestParameterDefinition, Static)
9-
10-
function p = init()
11-
12-
p = {{"", ""}, ...
13-
{"a/b", ""}, ...
14-
{"/etc", ""}, ...
15-
{"c:/etc", ""}};
16-
17-
if ispc
18-
p{4}{2} = "c:";
19-
end
20-
21-
end
22-
4+
p = init_root_name()
235
end
246

257

@@ -41,3 +23,17 @@ function test_root_name(tc, p)
4123

4224
end
4325
end
26+
27+
28+
function p = init_root_name()
29+
30+
p = {{"", ""}, ...
31+
{"a/b", ""}, ...
32+
{"/etc", ""}, ...
33+
{"c:/etc", ""}};
34+
35+
if ispc
36+
p{4}{2} = "c:";
37+
end
38+
39+
end

test/TestIsAbsolute.m

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11
classdef TestIsAbsolute < matlab.unittest.TestCase
22

33
properties (TestParameter)
4-
p
4+
p = init_is_absolute()
55
use_java = num2cell(unique([stdlib.has_java(), false]))
66
end
77

8-
methods (TestParameterDefinition, Static)
9-
function p = init_is_absolute()
10-
p = {{"", false}, {"x", false}, {"x:", false}, {"x:/foo", false}, {"/foo", true}};
11-
if ispc
12-
p{4}{2} = true;
13-
p{5}{2} = false;
14-
end
15-
end
16-
17-
end
18-
198
methods (Test)
209
function test_is_absolute(tc, p, use_java)
2110
ok = stdlib.is_absolute(p{1}, use_java);
2211
tc.verifyEqual(ok, p{2}, p{1})
2312
end
2413
end
14+
end
15+
2516

17+
function p = init_is_absolute()
18+
p = {{"", false}, {"x", false}, {"x:", false}, {"x:/foo", false}, {"/foo", true}};
19+
if ispc
20+
p{4}{2} = true;
21+
p{5}{2} = false;
22+
end
2623
end

test/TestIsSubdir.m

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
classdef TestIsSubdir < matlab.unittest.TestCase
22

33
properties (TestParameter)
4-
p_is_prefix
5-
p_is_subdir
4+
p_is_prefix = init_is_prefix()
5+
p_is_subdir = init_is_subdir()
66
end
77

8-
methods (TestParameterDefinition, Static)
98

10-
function [p_is_subdir, p_is_prefix] = init_is_subdir()
9+
methods (Test)
10+
11+
function test_is_subdir(tc, p_is_subdir)
12+
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} + ")")
13+
end
14+
15+
function test_is_prefix(tc, p_is_prefix)
16+
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} + ")")
17+
end
18+
19+
end
20+
21+
end
22+
1123

12-
p_is_subdir = {
24+
function p = init_is_subdir()
25+
26+
p = {
1327
{"a/b", "a/b", false}, ...
1428
{"a//b/c", "a/b", true}, ...
1529
{"a/b", "a//b", false}, ...
@@ -22,34 +36,19 @@
2236
% NOTE: ".." in is_subdir (either argument) is ambiguous
2337

2438
if ispc
25-
p_is_subdir{end+1} = {"c:\", "c:/", false};
39+
p{end+1} = {"c:\", "c:/", false};
2640
else
27-
p_is_subdir{end+1} = {"/", "/", false};
41+
p{end+1} = {"/", "/", false};
2842
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-
5343
end
5444

45+
function p = init_is_prefix()
46+
p = init_is_subdir();
47+
p{1}{3} = true;
48+
p{2}{3} = false;
49+
p{3}{3} = true;
50+
p{6}{3} = true;
51+
p{7}{3} = false;
52+
p{8}{3} = false;
53+
p{9}{3} = true;
5554
end

test/TestNormalize.m

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22

33
properties (TestParameter)
44
use_java = num2cell(unique([stdlib.has_java(), false]))
5-
p
5+
p = init_norm()
66
end
77

8-
methods (TestParameterDefinition, Static)
9-
function p = init()
8+
methods (Test)
9+
function test_normalize(tc, p, use_java)
10+
tc.verifyEqual(stdlib.normalize(p{1}, use_java), p{2})
11+
end
12+
end
13+
14+
end
15+
16+
function p = init_norm()
17+
1018
p = {
1119
{"", "."}, ...
1220
{"a/..", "."}, ...
@@ -30,14 +38,4 @@
3038
if ispc
3139
p{3}{2} = "//a/b";
3240
end
33-
34-
end
35-
end
36-
37-
methods (Test)
38-
function test_normalize(tc, p, use_java)
39-
tc.verifyEqual(stdlib.normalize(p{1}, use_java), p{2})
40-
end
41-
end
42-
4341
end

test/TestParent.m

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22

33
properties (TestParameter)
44
use_java = num2cell(unique([stdlib.has_java(), false]))
5-
p
5+
p = init_parent()
6+
end
7+
8+
methods (Test)
9+
function test_parent(tc, p, use_java)
10+
tc.verifyEqual(stdlib.parent(p{1}, use_java), p{2}, p{1})
11+
end
12+
end
13+
614
end
715

8-
methods(TestParameterDefinition, Static)
916

1017
function p = init_parent()
1118

@@ -38,13 +45,3 @@
3845
end
3946

4047
end
41-
end
42-
43-
44-
methods (Test)
45-
function test_parent(tc, p, use_java)
46-
tc.verifyEqual(stdlib.parent(p{1}, use_java), p{2}, p{1})
47-
end
48-
end
49-
50-
end

test/TestRelative.m

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
11
classdef TestRelative < matlab.unittest.TestCase
22

33
properties (TestParameter)
4-
p_relative_to
5-
p_proximate_to
4+
p_relative_to = init_rel()
5+
p_proximate_to = init_prox()
66
end
77

88

9-
methods (TestParameterDefinition, Static)
9+
methods (Test)
10+
11+
function test_relative_to(tc, p_relative_to)
12+
tc.assumeTrue(stdlib.has_java())
13+
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}+")")
14+
end
1015

11-
function [p_relative_to, p_proximate_to] = init_relative_to()
16+
function test_proximate_to(tc, p_proximate_to)
17+
tc.assumeTrue(stdlib.has_java())
18+
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}+")")
19+
end
1220

13-
p_relative_to = {{"", "", "."}, ...
21+
end
22+
end
23+
24+
25+
function p = init_rel()
26+
27+
p = {{"", "", "."}, ...
1428
{"Hello", "Hello", "."}, ...
1529
{"Hello", "Hello/", "."}, ...
1630
{"a/./b", "a/b", "."}, ...
@@ -29,51 +43,32 @@
2943
{"this/one", "this/two", "../two"}};
3044
% NOTE: ".." in relative_to(base) is ambiguous including for python.pathlib, C++ <filesystem>, etc.
3145

32-
p_proximate_to = p_relative_to;
33-
34-
p_proximate_to{8}{3} = "/";
35-
p_proximate_to{12}{3} = "c";
36-
p_proximate_to{13}{3} = "/a/b";
37-
3846
if ispc
39-
40-
p_relative_to = [p_relative_to, ...
47+
p = [p, ...
4148
{{"c:\a\b", "c:/", "../.."}, ...
4249
{"c:\", "c:/a/b", "a/b"}, ...
4350
{"c:/a/b", "c:/a/b", "."}, ...
4451
{"c:/a/b", "c:/a", ".."}, ...
4552
{"c:\a/b\c/d", "c:/a\b", "../.."}, ...
4653
{"c:/path", "d:/path", ""}}];
47-
48-
p_proximate_to = p_relative_to;
49-
% NOTE: ".." in proximate_to(base) is ambiguous including for python.pathlib, C++ <filesystem>, etc
50-
51-
p_proximate_to{8}{3} = "/";
52-
p_proximate_to{12}{3} = "c";
53-
p_proximate_to{13}{3} = "/a/b";
54-
55-
p_proximate_to{end}{3} = "d:/path";
56-
end
57-
5854
end
5955

6056
end
6157

58+
function p = init_prox()
59+
% NOTE: ".." in proximate_to(base) is ambiguous including for python.pathlib, C++ <filesystem>, etc
6260

61+
p = init_rel();
6362

64-
methods (Test)
63+
p{8}{3} = "/";
64+
p{12}{3} = "c";
65+
p{13}{3} = "/a/b";
6566

66-
function test_relative_to(tc, p_relative_to)
67-
tc.assumeTrue(stdlib.has_java())
68-
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}+")")
69-
end
70-
71-
72-
function test_proximate_to(tc, p_proximate_to)
73-
tc.assumeTrue(stdlib.has_java())
74-
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}+")")
75-
end
67+
if ispc
68+
p{8}{3} = "/";
69+
p{12}{3} = "c";
70+
p{13}{3} = "/a/b";
7671

72+
p{end}{3} = "d:/path";
7773
end
78-
7974
end

0 commit comments

Comments
 (0)