Skip to content

Commit c9c1589

Browse files
committed
testParameterDefinition
1 parent 8f24888 commit c9c1589

File tree

6 files changed

+62
-75
lines changed

6 files changed

+62
-75
lines changed

test/TestCanonical.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
TestTags = {'impure'}) ...
33
TestCanonical < matlab.unittest.TestCase
44

5-
properties(TestParameter)
5+
properties (TestParameter)
66
p = {{'', ""}, ...
77
{"", ""}, ...
88
{"not-exist", "not-exist"}, ...
@@ -13,14 +13,14 @@
1313
};
1414
end
1515

16-
methods(TestClassSetup)
16+
methods (TestClassSetup)
1717
function test_dirs(tc)
1818
tc.applyFixture(matlab.unittest.fixtures.WorkingFolderFixture())
1919
end
2020
end
2121

2222

23-
methods(Test, TestTags={'R2019b'})
23+
methods (Test, TestTags={'R2019b'})
2424
function test_canonical(tc, p)
2525
c = stdlib.canonical(p{1}, false);
2626
tc.verifyEqual(c, p{2})

test/TestExists.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
TestTags = {'impure'}) ...
33
TestExists < matlab.unittest.TestCase
44

5-
properties(TestParameter)
5+
properties (TestParameter)
66
Ps
77
B_is_char_device
88
end

test/TestExpanduser.m

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture("..")}, ...
2-
TestTags = {'R2019b', 'impure'}) ...
2+
TestTags = {'R2021a', 'impure'}) ...
33
TestExpanduser < matlab.unittest.TestCase
44

5-
properties(TestParameter)
6-
p = init_exp()
7-
end
8-
9-
methods(Test)
10-
11-
function test_expanduser(tc, p)
12-
tc.verifyEqual(stdlib.expanduser(p{1}), p{2})
13-
end
14-
15-
end
16-
5+
properties (TestParameter)
6+
p
177
end
188

199

10+
methods (TestParameterDefinition, Static)
2011
function p = init_exp()
2112

2213
if ispc
@@ -36,3 +27,14 @@ function test_expanduser(tc, p)
3627
{"~" + filesep() + "c", fullfile(h, "c")}};
3728

3829
end
30+
end
31+
32+
methods (Test)
33+
34+
function test_expanduser(tc, p)
35+
tc.verifyEqual(stdlib.expanduser(p{1}), p{2})
36+
end
37+
38+
end
39+
40+
end

test/TestFileImpure.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
TestTags = {'R2019b', 'impure'}) ...
33
TestFileImpure < matlab.unittest.TestCase
44

5-
properties(TestParameter)
5+
properties (TestParameter)
66
ph = {{0, '"stdin"'}, {1, '"stdout"'}, {2, '"stderr"'}, {fopen(tempname()), ''}}
77

88
p_file_size = {mfilename("fullpath") + ".m"}

test/TestJoin.m

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,6 @@
33
TestJoin < matlab.unittest.TestCase
44

55
properties (TestParameter)
6-
p = init_join()
7-
end
8-
9-
10-
methods (Test)
11-
function test_join(tc, p)
12-
tc.verifyEqual(stdlib.join(p{1}, p{2}), p{3})
13-
end
14-
end
15-
16-
end
17-
18-
19-
function p = init_join()
20-
216
p = {{"", "", ""}, ...
227
{"a", "", "a"}, ...
238
{"", "a", "a"}, ...
@@ -31,6 +16,13 @@ function test_join(tc, p)
3116
{"ab/cd", "/ef", "/ef"}, ...
3217
{matlabroot, "bin", matlabroot + "/bin"}
3318
};
19+
end
20+
3421

22+
methods (Test)
23+
function test_join(tc, p)
24+
tc.verifyEqual(stdlib.join(p{1}, p{2}), p{3})
25+
end
26+
end
3527

3628
end

test/TestRoot.m

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,16 @@
11
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture("..")}, ...
2-
TestTags = {'R2019b', 'pure'}) ...
2+
TestTags = {'R2021a', 'pure'}) ...
33
TestRoot < matlab.unittest.TestCase
44

55
properties (TestParameter)
6-
p = init_root()
7-
rn = init_root_name()
8-
rd = init_root_dir()
6+
p
7+
rn
8+
rd
99
end
1010

1111

12-
methods (Test)
13-
14-
function test_root(tc, p)
15-
r = stdlib.root(p{1});
16-
tc.assertClass(r, 'string')
17-
tc.verifyEqual(r, p{2})
18-
end
19-
20-
function test_root_dir(tc, rd)
21-
r = stdlib.root_dir(rd{1});
22-
tc.assertClass(r, 'string')
23-
tc.verifyEqual(r, rd{2}, "root_dir(" + rd{1} + ")")
24-
end
25-
26-
function test_root_name(tc, rn)
27-
r = stdlib.root_name(rn{1});
28-
tc.assertClass(r, 'string')
29-
tc.verifyEqual(r, rn{2})
30-
end
31-
32-
end
33-
34-
end % class
35-
36-
37-
function p = init_root()
12+
methods (TestParameterDefinition, Static)
13+
function [p, rn, rd] = init_root()
3814

3915
p = {{"", ""}, ...
4016
{"a/b", ""}, ...
@@ -51,12 +27,7 @@ function test_root_name(tc, rn)
5127
p{8}{2} = "c:\";
5228
end
5329

54-
end
55-
56-
57-
function rn = init_root_name()
58-
59-
rn = init_root();
30+
rn = p;
6031

6132
rn{4}{2} = "";
6233
rn{5}{2} = "";
@@ -67,12 +38,7 @@ function test_root_name(tc, rn)
6738
rn{8}{2} = "c:";
6839
end
6940

70-
end
71-
72-
73-
function rd = init_root_dir()
74-
75-
rd = init_root();
41+
rd = p;
7642

7743
if ispc()
7844
rd{6}{2} = "";
@@ -81,3 +47,30 @@ function test_root_name(tc, rn)
8147
end
8248

8349
end
50+
51+
end
52+
53+
54+
methods (Test)
55+
56+
function test_root(tc, p)
57+
r = stdlib.root(p{1});
58+
tc.assertClass(r, 'string')
59+
tc.verifyEqual(r, p{2})
60+
end
61+
62+
function test_root_dir(tc, rd)
63+
r = stdlib.root_dir(rd{1});
64+
tc.assertClass(r, 'string')
65+
tc.verifyEqual(r, rd{2}, "root_dir(" + rd{1} + ")")
66+
end
67+
68+
function test_root_name(tc, rn)
69+
r = stdlib.root_name(rn{1});
70+
tc.assertClass(r, 'string')
71+
tc.verifyEqual(r, rn{2})
72+
end
73+
74+
end
75+
76+
end

0 commit comments

Comments
 (0)