|
1 | 1 | classdef TestAbsolute < matlab.unittest.TestCase |
2 | 2 |
|
| 3 | +properties |
| 4 | +td |
| 5 | +end |
| 6 | + |
| 7 | + |
3 | 8 | properties (TestParameter) |
4 | | -p1 = init1arg() |
5 | | -p2 = init2arg() |
| 9 | +p1 |
| 10 | +p2 |
6 | 11 | end |
7 | 12 |
|
8 | 13 |
|
9 | | -methods(Test) |
| 14 | +methods (TestParameterDefinition, Static) |
10 | 15 |
|
11 | | -function test_absolute1arg(tc, p1) |
12 | | -tc.verifyEqual(stdlib.absolute(p1{1}), p1{2}) |
| 16 | +function p1 = init1arg() |
| 17 | +p1 = {"", "hi", "./hi", "../hi"}; |
13 | 18 | end |
14 | 19 |
|
15 | | -function test_absolute2arg(tc, p2) |
16 | | -tc.verifyEqual(stdlib.absolute(p2{1}, p2{2}), p2{3}) |
| 20 | +function p2 = init2arg() |
| 21 | +p2 = {{"", ""}, {"", "hi"}, {"hi", ""}, {"there", "hi"}}; |
17 | 22 | end |
18 | 23 |
|
19 | 24 | end |
20 | 25 |
|
| 26 | + |
| 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)) |
21 | 32 | end |
| 33 | +end |
| 34 | + |
| 35 | + |
| 36 | +methods(Test) |
22 | 37 |
|
| 38 | +function test_absolute1arg(tc, p1) |
23 | 39 |
|
24 | | -function p = init1arg() |
25 | | -td = stdlib.posix(pwd()); |
26 | | -r = td + "/hi"; |
| 40 | +r = tc.td; |
27 | 41 |
|
28 | | -p = {{"", td}, {"hi", r}, {"./hi", td + "/./hi"}, {"../hi", td + "/../hi"}}; |
| 42 | +if strlength(p1) |
| 43 | + r = r + "/" + p1; |
29 | 44 | end |
30 | 45 |
|
31 | | -function p = init2arg() |
32 | | -td = stdlib.posix(pwd()); |
33 | | -r = td + "/hi"; |
| 46 | +tc.verifyEqual(stdlib.absolute(p1), r) |
| 47 | +end |
| 48 | + |
| 49 | + |
| 50 | +function test_absolute2arg(tc, p2) |
| 51 | + |
| 52 | +r = tc.td; |
| 53 | + |
| 54 | +if strlength(p2{2}) |
| 55 | + r = r + "/" + p2{2}; |
| 56 | +end |
| 57 | + |
| 58 | +if strlength(p2{1}) |
| 59 | + r = r + "/" + p2{1}; |
| 60 | +end |
| 61 | + |
| 62 | +tc.verifyEqual(stdlib.absolute(p2{1}, p2{2}), r) |
| 63 | +end |
| 64 | + |
| 65 | +end |
34 | 66 |
|
35 | | -p = {{"", "", td}, {"", "hi", r}, {"hi", "", r}, {"there", "hi", td + "/hi/there"}}; |
36 | 67 | end |
0 commit comments