Skip to content

Commit 2ea4cee

Browse files
committed
test: stem, filename: arrays
1 parent 7c404b5 commit 2ea4cee

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

+stdlib/filename.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
case 'regexp'
1919
f = regexp(p, ['[^/\' filesep ']*$'], 'match', 'once');
2020
f(ismissing(f)) = "";
21-
otherwise, error('must be backend "pattern" or "regexp"')
21+
otherwise, error('must be backend "pattern" or "regexp"')
2222
end
2323

2424
end

test/TestFilename.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ function test_filename_empty(tc, e, backend)
2525
tc.verifyEqual(strlength(fn), 0)
2626
end
2727

28+
function test_filename_array(tc, backend)
29+
in = ["", "a", "a/b/c", "a/b/c.txt", "a/b/.hidden", "a/b/c/"];
30+
exp = ["", "a", "c", "c.txt", ".hidden", ""];
31+
out = stdlib.filename(in, backend);
32+
tc.verifyEqual(out, exp)
33+
end
34+
2835
end
2936

3037
end

test/TestStem.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,17 @@ function pkg_path(tc)
2525
end
2626

2727
methods (Test, TestTags="pure")
28-
function test(tc, p)
28+
function test_stem(tc, p)
2929
tc.verifyEqual(stdlib.stem(p{1}), p{2})
3030
end
31+
32+
function test_stem_array(tc)
33+
in = ["", ".txt", "a/b/c.txt", "a/b/c.txt.gz", "a/b/c"];
34+
exp = ["", ".txt", "c", "c.txt", "c"];
35+
out = stdlib.stem(in);
36+
tc.verifyEqual(out, exp)
37+
end
38+
3139
end
3240

3341
end

0 commit comments

Comments
 (0)