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