Skip to content

Commit 2a3b573

Browse files
committed
test: add hard_link_count
1 parent 4185aaa commit 2a3b573

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

+stdlib/hard_link_count.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
% https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/Files.html#getPosixFileAttributes(java.nio.file.Path,java.nio.file.LinkOption...)
44
% https://docs.oracle.com/javase/tutorial/essential/io/links.html
55
arguments
6-
filepath (1,1) string {mustBeFile}
6+
filepath (1,1) string
77
end
88

9-
if ispc
9+
if ispc || ~isfile(filepath)
1010
c = [];
1111
return
1212
end

test/TestFileImpure.m

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
end
66

77
properties(TestParameter)
8-
in_exists = {pwd, string(mfilename("fullpath"))+".m", "not-exists"}
8+
in_exists = {pwd, mfilename("fullpath") + ".m", "not-exists"}
99
ref_exists = {true, true, false}
1010
% on CI matlabroot can be writable!
1111
in_is_write = {pwd, "not-exists"};
@@ -357,6 +357,20 @@ function test_java_api(tc)
357357
tc.verifyGreaterThanOrEqual(v, 8)
358358
end
359359

360+
function test_hard_link_count(tc)
361+
362+
fn = mfilename("fullpath") + ".m";
363+
364+
if ispc
365+
tc.verifyEmpty(stdlib.hard_link_count(fn))
366+
else
367+
tc.verifyGreaterThanOrEqual(stdlib.hard_link_count(fn), 1)
368+
end
369+
370+
tc.verifyEmpty(stdlib.hard_link_count(tempname))
371+
372+
end
373+
360374
end
361375

362376
end

0 commit comments

Comments
 (0)