Skip to content

Commit 7571f37

Browse files
committed
test: stricter, simpler check
1 parent 5d27ed7 commit 7571f37

File tree

2 files changed

+15
-27
lines changed

2 files changed

+15
-27
lines changed

test/TestDisk.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ function test_disk_capacity(tc, Ps, disk_capacity_fun)
6060

6161

6262
function test_hard_link_count(tc, hl_fun)
63+
fname = "hard_link_count";
64+
n = "stdlib." + hl_fun + "." + fname;
65+
h = str2func("stdlib." + fname);
66+
tc.assertNotEmpty(which(n))
6367
try
64-
c = stdlib.hard_link_count(mfilename("fullpath") + ".m", hl_fun);
65-
tc.verifyGreaterThanOrEqual(c, 1)
68+
tc.verifyGreaterThanOrEqual(h(mfilename("fullpath") + ".m"), 1)
6669
catch e
6770
tc.verifyEqual(e.identifier, 'stdlib:choose_method:NameError')
6871
end

test/TestExists.m

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
{"", false}
1111
}
1212
% on CI matlabroot can be writable!
13-
isr_method = {'java', 'native', 'legacy'}
14-
isw_method = {'java', 'native', 'legacy'}
13+
fname = {'is_readable', 'is_writable'}
14+
method = {'java', 'native', 'legacy'}
1515
end
1616

1717
methods(TestClassSetup)
@@ -29,31 +29,16 @@ function test_exists(tc, Ps)
2929
end
3030

3131

32-
function test_is_readable(tc, Ps, isr_method)
33-
is_capable(tc, str2func("stdlib." + isr_method + ".is_readable"))
34-
35-
ok = stdlib.is_readable(Ps{1}, isr_method);
36-
tc.verifyEqual(ok, Ps{2}, Ps{1})
37-
end
38-
39-
40-
function test_is_writable(tc, Ps, isw_method)
41-
is_capable(tc, str2func("stdlib." + isw_method + ".is_writable"))
42-
43-
ok = stdlib.is_writable(Ps{1}, isw_method);
44-
tc.verifyEqual(ok, Ps{2}, Ps{1})
32+
function test_is_rw(tc, Ps, method, fname)
33+
n = "stdlib." + method + "." + fname;
34+
h = str2func("stdlib." + fname);
35+
tc.assertNotEmpty(which(n))
36+
try
37+
tc.verifyEqual(h(Ps{1}, method), Ps{2})
38+
catch e
39+
tc.verifyEqual(e.identifier, 'stdlib:choose_method:NameError')
4540
end
46-
47-
function test_is_writable_dir(tc, isw_method)
48-
is_capable(tc, str2func("stdlib." + isw_method + ".is_writable"))
49-
50-
tc.assumeFalse(isMATLABReleaseOlderThan('R2022a'))
51-
52-
td = tc.createTemporaryFolder();
53-
54-
tc.verifyTrue(stdlib.is_writable(td, isw_method))
5541
end
5642

5743
end
58-
5944
end

0 commit comments

Comments
 (0)