Skip to content

Commit fe19c66

Browse files
committed
with_suffix: enhance test
1 parent 63d8175 commit fe19c66

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

+stdlib/with_suffix.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
suffix {mustBeTextScalar}
1313
end
1414

15-
f = "";
15+
f = '';
1616

1717
r = stdlib.parent(p);
1818
if ~strlength(r), return, end

test/TestWithSuffix.m

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
classdef TestWithSuffix < matlab.unittest.TestCase
22

3+
properties
4+
is_mex = stdlib.is_mex_fun("stdlib.parent")
5+
end
6+
37
properties (TestParameter)
4-
p = {{"foo.h5", ".nc", "foo\.nc"},...
8+
p = {{"foo.h5", ".nc", "foo.nc"},...
59
{"c", "", "c"}, ...
610
{"c.nc", "", "c"}, ...
7-
{"", ".nc", "\.nc"}, ...
8-
{"a/b/c/", ".h5", "a/b/c/\.h5"}, ...
9-
{"a/b/.h5", ".nc", "a/b/\.h5\.nc"}, ...
10-
{'a/b', '.nc', 'a/b\.nc'}};
11+
{"", ".nc", ".nc"}, ...
12+
{'a/b/c/', '.h5', 'a/b/c/.h5'}, ...
13+
{"a/b/.h5", '.nc', "a/b/.h5.nc"}, ...
14+
{'a/b', '.nc', 'a/b.nc'}};
1115
end
1216

1317
methods (Test)
1418
function test_with_suffix(tc, p)
15-
import matlab.unittest.constraints.Matches
16-
tc.verifyThat(stdlib.with_suffix(p{1}, p{2}), Matches(p{3}))
19+
20+
if tc.is_mex
21+
r = string(p{3});
22+
else
23+
r = p{3};
24+
end
25+
26+
tc.verifyEqual(stdlib.with_suffix(p{1}, p{2}), r, ...
27+
sprintf("mex: %d", tc.is_mex))
1728
end
1829
end
1930

0 commit comments

Comments
 (0)