Skip to content

Commit dd54202

Browse files
committed
test:windows: parameterize
1 parent 1dca437 commit dd54202

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

test/TestWindowsCOM.m

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
properties (TestParameter)
44
Pn = {"", "not-exist", "file:///"}
5+
Pmr = {matlabroot, stdlib.posix(matlabroot)}
56
end
67

78
methods (Test)
@@ -13,35 +14,41 @@ function test_not(tc, Pn)
1314
function test_short_folder(tc)
1415
import matlab.unittest.constraints.IsFolder
1516

16-
tc.assumeTrue(ispc, "Windows only")
17-
1817
progdir = stdlib.posix(getenv("PROGRAMFILES"));
18+
if ispc
1919
tc.assumeThat(progdir, IsFolder, "$Env:PROGRAMFILES is not a directory")
20+
end
2021

2122
short = stdlib.windows_shortname(progdir);
2223

23-
tc.verifySubstring(short, "PROGRA~1")
24-
25-
tc.verifyEqual(stdlib.canonical(short), progdir)
24+
if ispc
25+
tc.verifySubstring(short, "PROGRA~1")
26+
tc.verifyEqual(stdlib.canonical(short), progdir)
27+
else
28+
tc.verifyEqual(short, "")
29+
end
2630

2731
end
2832

2933

30-
function test_short_file(tc)
34+
function test_short_file(tc, Pmr)
3135
import matlab.unittest.constraints.IsFile
3236

33-
tc.assumeTrue(ispc, "Windows only")
34-
p = matlabroot;
35-
tc.assumeSubstring(p, " ", "name won't shorten if it doesn't have a space")
37+
if ispc
38+
tc.assumeSubstring(Pmr, " ", "name won't shorten if it doesn't have a space")
39+
end
3640

37-
for d = [p, stdlib.posix(p)]
38-
s = stdlib.windows_shortname(d);
41+
s = stdlib.windows_shortname(Pmr);
3942

40-
tc.verifySubstring(s, "~")
43+
if ispc
44+
if contains(Pmr, " ")
45+
tc.verifySubstring(s, "~")
46+
end
47+
else
48+
tc.verifyEqual(s, "")
4149
end
4250

4351
tc.verifyEqual(stdlib.canonical(s), stdlib.posix(p), "shortname didn't resolve same as canonical")
44-
4552
end
4653

4754
end

0 commit comments

Comments
 (0)