Skip to content

Commit b7c7364

Browse files
committed
test:simplify
1 parent c0c3a7c commit b7c7364

File tree

5 files changed

+18
-60
lines changed

5 files changed

+18
-60
lines changed

test/TestFileImpure.m

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
classdef TestFileImpure < matlab.unittest.TestCase
22

3-
properties (ClassSetupParameter)
4-
classToTest = {"TestFileImpure"};
5-
end
6-
73
properties(TestParameter)
84
p_exists = {{pwd(), true}, {mfilename("fullpath") + ".m", true}, {"TestFileImpure.m", true} {tempname, false}}
95
% on CI matlabroot can be writable!
@@ -17,16 +13,14 @@
1713
{tempname, tempname, false}, ...
1814
{"..", "./..", true}, ...
1915
{"..", pwd() + "/..", true}}
20-
end
2116

22-
properties
23-
tobj
17+
ph = {{0, '"stdin"'}, {1, '"stdout"'}, {2, '"stderr"'}, {fopen(tempname), string.empty}}
2418
end
2519

2620

2721
methods (TestParameterDefinition, Static)
2822

29-
function p_expand = init_expand(classToTest) %#ok<INUSD>
23+
function p_expand = init_expand()
3024
cwd = fileparts(mfilename("fullpath"));
3125
top = fullfile(cwd, "..");
3226
addpath(top)
@@ -42,14 +36,9 @@ function setup_path(tc)
4236
tc.applyFixture(matlab.unittest.fixtures.PathFixture(top))
4337
end
4438

45-
function classSetup(tc, classToTest)
46-
constructor = str2func(classToTest);
47-
tc.tobj = constructor();
48-
end
49-
5039
end
5140

52-
methods (Test, ParameterCombination = 'sequential')
41+
methods (Test)
5342

5443
function test_exists(tc, p_exists)
5544
tc.verifyEqual(stdlib.exists(p_exists{1}), p_exists{2})
@@ -106,11 +95,8 @@ function test_get_permissions(tc)
10695
tc.verifyThat(p, StartsWithSubstring("r"))
10796
end
10897

109-
function test_handle2filename(tc)
110-
tc.verifyEqual(stdlib.handle2filename(0), '"' + "stdin" + '"')
111-
tc.verifyEqual(stdlib.handle2filename(1), '"' + "stdout" + '"')
112-
tc.verifyEqual(stdlib.handle2filename(2), '"' + "stderr" + '"')
113-
tc.verifyEmpty(stdlib.handle2filename(fopen(tempname)))
98+
function test_handle2filename(tc, ph)
99+
tc.verifyEqual(stdlib.handle2filename(ph{1}), string(ph{2}))
114100
end
115101

116102
end

test/TestFilePure.m

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
classdef TestFilePure < matlab.unittest.TestCase
22

3-
properties (ClassSetupParameter)
4-
classToTest = {"TestFilePure"};
5-
end
6-
73
properties (TestParameter)
84

95
p_is_absolute
@@ -61,14 +57,10 @@
6157
p_root_name
6258
end
6359

64-
properties
65-
tobj
66-
end
67-
6860

6961
methods (TestParameterDefinition, Static)
7062

71-
function [p_root, p_root_name] = init_relative_to(classToTest) %#ok<INUSD>
63+
function [p_root, p_root_name] = init_relative_to()
7264

7365
p_root = {{"", ""}, ...
7466
{"a/b", ""}, ...
@@ -92,7 +84,7 @@
9284
end
9385

9486

95-
function [p_is_absolute] = init_is_absolute(classToTest) %#ok<INUSD>
87+
function [p_is_absolute] = init_is_absolute()
9688

9789
p_is_absolute = {{"", false}, {"x", false}, {"x:", false}, {"x:/foo", false}, {"/foo", true}};
9890

@@ -109,11 +101,6 @@
109101

110102
methods (TestClassSetup)
111103

112-
function classSetup(tc, classToTest)
113-
constructor = str2func(classToTest);
114-
tc.tobj = constructor();
115-
end
116-
117104
function setup_path(tc)
118105
top = fullfile(fileparts(mfilename("fullpath")), "..");
119106
tc.applyFixture(matlab.unittest.fixtures.PathFixture(top))
@@ -123,7 +110,7 @@ function setup_path(tc)
123110

124111

125112

126-
methods (Test, ParameterCombination = "sequential")
113+
methods (Test)
127114

128115
function test_posix(tc)
129116
import matlab.unittest.constraints.ContainsSubstring

test/TestHDF5.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function setup_file(tc)
6161
end
6262

6363

64-
methods (Test, ParameterCombination = 'sequential')
64+
methods (Test)
6565

6666
function test_auto_chunk_size(tc)
6767

test/TestRelative.m

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

3-
properties (ClassSetupParameter)
4-
classToTest = {"TestRelative"};
5-
end
6-
73
properties (TestParameter)
84
p_relative_to
95
p_proximate_to
106
p_is_subdir
117
end
128

13-
properties
14-
tobj
15-
end
16-
179

1810
methods (TestParameterDefinition, Static)
1911

20-
function [p_relative_to, p_proximate_to] = init_relative_to(classToTest) %#ok<INUSD>
12+
function [p_relative_to, p_proximate_to] = init_relative_to()
2113

2214
p_relative_to = {{"", "", "."}, ...
2315
{"Hello", "Hello", "."}, ...
@@ -67,7 +59,7 @@
6759
end
6860

6961

70-
function [p_is_subdir] = init_is_subdir(classToTest) %#ok<INUSD>
62+
function [p_is_subdir] = init_is_subdir()
7163

7264
p_is_subdir = {
7365
{"a/b", "a/b", false}, ...
@@ -94,11 +86,6 @@
9486

9587
methods (TestClassSetup)
9688

97-
function classSetup(tc, classToTest)
98-
constructor = str2func(classToTest);
99-
tc.tobj = constructor();
100-
end
101-
10289
function setup_path(tc)
10390
top = fullfile(fileparts(mfilename("fullpath")), "..");
10491
tc.applyFixture(matlab.unittest.fixtures.PathFixture(top))
@@ -107,7 +94,7 @@ function setup_path(tc)
10794
end
10895

10996

110-
methods (Test, ParameterCombination = "sequential")
97+
methods (Test)
11198

11299

113100
function test_relative_to(tc, p_relative_to)

test/TestWindowsCOM.m

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,16 @@ function test_short_file(tc)
3636
import matlab.unittest.constraints.IsFile
3737

3838
tc.assumeTrue(ispc, "Windows only")
39+
p = matlabroot;
40+
tc.assumeSubstring(p, " ", "name won't shorten if it doesn't have a space")
3941

40-
file = fullfile(matlabroot, "VersionInfo.xml");
41-
tc.assumeThat(file, IsFile, "VersionInfo.xml missing")
42-
tc.assumeSubstring(file, " ", "name won't shorten if it doesn't have a space")
42+
for d = [p, stdlib.posix(p)]
43+
s = stdlib.windows_shortname(d);
4344

44-
for f = [file, stdlib.posix(file)]
45-
short = stdlib.windows_shortname(f);
46-
47-
tc.verifySubstring(short, "~")
45+
tc.verifySubstring(s, "~")
4846
end
4947

50-
tc.verifyEqual(stdlib.canonical(short), stdlib.posix(file))
48+
tc.verifyEqual(stdlib.canonical(s), stdlib.posix(p), "shortname didn't resolve same as canonical")
5149

5250
end
5351

0 commit comments

Comments
 (0)