Skip to content

Commit 38e74aa

Browse files
committed
remove: correct code and add non-mex test
1 parent 774b26f commit 38e74aa

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

+stdlib/remove.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
return
1717
end
1818

19-
%% fallback for if MEX not compiled
19+
lastwarn('')
20+
2021
try %#ok<*TRYNC>
2122
delete(p);
2223
ok = true;

test/TestDisk.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,21 @@ function test_filesystem_type(tc, Ps, fst_fun)
7676
end
7777

7878

79+
function test_remove_file(tc)
80+
81+
d = tc.createTemporaryFolder();
82+
83+
f = tempname(d);
84+
85+
tc.verifyFalse(stdlib.remove(f), "should not succeed at removing non-existant path")
86+
87+
tc.assumeTrue(stdlib.touch(f), "failed to touch file " + f)
88+
tc.assumeThat(f, matlab.unittest.constraints.IsFile)
89+
90+
tc.verifyTrue(stdlib.remove(f), "failed to remove file " + f)
91+
end
92+
93+
7994
function test_device(tc, device_fun)
8095
is_capable(tc, device_fun)
8196

0 commit comments

Comments
 (0)