Skip to content

Commit e651250

Browse files
committed
testAbsolute: dedupe
1 parent e473964 commit e651250

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

test/TestAbsolute.m

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
classdef TestAbsolute < matlab.unittest.TestCase
22

3+
properties
4+
td
5+
end
6+
37

48
properties (TestParameter)
59
p1
@@ -17,18 +21,23 @@
1721
p2 = {{"", ""}, {"", "hi"}, {"hi", ""}, {"there", "hi"}};
1822
end
1923

24+
end
25+
2026

27+
methods(TestClassSetup)
28+
function set_cwd(tc)
29+
import matlab.unittest.fixtures.CurrentFolderFixture
30+
tc.td = stdlib.posix(tc.createTemporaryFolder());
31+
tc.applyFixture(CurrentFolderFixture(tc.td))
32+
end
2133
end
2234

2335

2436
methods(Test)
2537

2638
function test_absolute1arg(tc, p1)
27-
import matlab.unittest.fixtures.CurrentFolderFixture
28-
td = tc.createTemporaryFolder();
29-
tc.applyFixture(CurrentFolderFixture(td))
3039

31-
r = stdlib.posix(td);
40+
r = tc.td;
3241

3342
if strlength(p1)
3443
r = r + "/" + p1;
@@ -39,11 +48,8 @@ function test_absolute1arg(tc, p1)
3948

4049

4150
function test_absolute2arg(tc, p2)
42-
import matlab.unittest.fixtures.CurrentFolderFixture
43-
td = tc.createTemporaryFolder();
44-
tc.applyFixture(CurrentFolderFixture(td))
4551

46-
r = stdlib.posix(td);
52+
r = tc.td;
4753

4854
if strlength(p2{2})
4955
r = r + "/" + p2{2};

0 commit comments

Comments
 (0)