Skip to content

Commit 1fc76a4

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

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,22 @@ function test_filesystem_type(tc, Ps, fst_fun)
7676
end
7777

7878

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

0 commit comments

Comments
 (0)