22
33properties (TestParameter )
44Pn = {" " , " not-exist" , " file:///" }
5+ Pmr = {matlabroot, stdlib.posix(matlabroot)}
56end
67
78methods (Test )
@@ -13,35 +14,41 @@ function test_not(tc, Pn)
1314function test_short_folder(tc )
1415import matlab .unittest .constraints .IsFolder
1516
16- tc .assumeTrue(ispc , " Windows only" )
17-
1817progdir = stdlib .posix(getenv(" PROGRAMFILES" ));
18+ if ispc
1919tc .assumeThat(progdir , IsFolder , " $Env:PROGRAMFILES is not a directory" )
20+ end
2021
2122short = 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
2731end
2832
2933
30- function test_short_file(tc )
34+ function test_short_file(tc , Pmr )
3135import 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 , " " )
4149end
4250
4351tc .verifyEqual(stdlib .canonical(s ), stdlib .posix(p ), " shortname didn't resolve same as canonical" )
44-
4552end
4653
4754end
0 commit comments