Skip to content

Commit fa46da3

Browse files
committed
test samepath: more robust cwd case
1 parent 138a8eb commit fa46da3

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

test/TestHDF4.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}, ...
2-
TestTags = {'R2017b', 'hdf4'}) ...
2+
TestTags = {'R2017a', 'hdf4'}) ...
33
TestHDF4 < matlab.unittest.TestCase
44

55
properties
@@ -8,7 +8,7 @@
88

99
methods (TestClassSetup)
1010
function check_file(tc)
11-
tc.assumeTrue(isfile(tc.file), "HDF4 file not found: " + tc.file)
11+
tc.assumeTrue(stdlib.is_file(tc.file), "HDF4 file not found: " + tc.file)
1212
end
1313
end
1414

test/TestSame.m

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,53 @@
11
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}, ...
2-
TestTags = {'R2017b', 'impure'}) ...
2+
TestTags = {'R2017a'}) ...
33
TestSame < matlab.unittest.TestCase
44

5+
properties
6+
file = 'same.txt'
7+
cwd
8+
end
9+
510
properties (TestParameter)
6-
p_same = {...
7-
{".", pwd()}, ...
8-
{"..", "./.."}, ...
9-
{"..", pwd() + "/.."}, ...
10-
{pwd(), pwd() + "/."}}
11+
p = {...
12+
{'..', './..'}, ...
13+
{'same.txt', './same.txt'}}
1114

1215
backend = {'python', 'java', 'perl', 'sys', 'native'}
1316
end
1417

1518

19+
methods(TestClassSetup)
20+
function w_dirs(tc)
21+
f = matlab.unittest.fixtures.WorkingFolderFixture();
22+
tc.applyFixture(f);
23+
tc.cwd = f.Folder;
24+
tc.assertTrue(stdlib.touch(tc.file))
25+
end
26+
end
27+
28+
1629
methods(Test)
1730

18-
function test_samepath(tc, p_same, backend)
19-
[r, b] = stdlib.samepath(p_same{:}, backend);
31+
function test_samepath(tc, p, backend)
32+
[r, b] = stdlib.samepath(p{:}, backend);
2033
tc.assertEqual(char(b), backend)
2134
tc.verifyClass(r, 'logical')
2235

2336
if ismember(backend, stdlib.Backend().select('samepath'))
24-
tc.verifyTrue(r)
37+
tc.verifyTrue(r, [p{1} ' ' p{2}])
2538
else
2639
tc.assertEmpty(r)
2740
end
2841
end
2942

3043

44+
function test_samepath_cwd(tc, backend)
45+
46+
tc.verifyTrue(stdlib.samepath('.', tc.cwd, backend))
47+
48+
end
49+
50+
3151
function test_samepath_notexist(tc, backend)
3252

3353
t = tempname();

0 commit comments

Comments
 (0)