|
1 | 1 | classdef TestRelative < matlab.unittest.TestCase |
2 | 2 |
|
3 | 3 | properties (TestParameter) |
4 | | -p_relative_to |
5 | | -p_proximate_to |
| 4 | +p_relative_to = init_rel() |
| 5 | +p_proximate_to = init_prox() |
6 | 6 | end |
7 | 7 |
|
8 | 8 |
|
9 | | -methods (TestParameterDefinition, Static) |
| 9 | +methods (Test) |
| 10 | + |
| 11 | +function test_relative_to(tc, p_relative_to) |
| 12 | +tc.assumeTrue(stdlib.has_java()) |
| 13 | +tc.verifyEqual(stdlib.relative_to(p_relative_to{1}, p_relative_to{2}), p_relative_to{3}, "relative_to(" + p_relative_to{1} + "," + p_relative_to{2}+")") |
| 14 | +end |
10 | 15 |
|
11 | | -function [p_relative_to, p_proximate_to] = init_relative_to() |
| 16 | +function test_proximate_to(tc, p_proximate_to) |
| 17 | +tc.assumeTrue(stdlib.has_java()) |
| 18 | +tc.verifyEqual(stdlib.proximate_to(p_proximate_to{1}, p_proximate_to{2}), p_proximate_to{3}, "proximate_to(" + p_proximate_to{1} + "," + p_proximate_to{2}+")") |
| 19 | +end |
12 | 20 |
|
13 | | -p_relative_to = {{"", "", "."}, ... |
| 21 | +end |
| 22 | +end |
| 23 | + |
| 24 | + |
| 25 | +function p = init_rel() |
| 26 | + |
| 27 | +p = {{"", "", "."}, ... |
14 | 28 | {"Hello", "Hello", "."}, ... |
15 | 29 | {"Hello", "Hello/", "."}, ... |
16 | 30 | {"a/./b", "a/b", "."}, ... |
|
29 | 43 | {"this/one", "this/two", "../two"}}; |
30 | 44 | % NOTE: ".." in relative_to(base) is ambiguous including for python.pathlib, C++ <filesystem>, etc. |
31 | 45 |
|
32 | | -p_proximate_to = p_relative_to; |
33 | | - |
34 | | -p_proximate_to{8}{3} = "/"; |
35 | | -p_proximate_to{12}{3} = "c"; |
36 | | -p_proximate_to{13}{3} = "/a/b"; |
37 | | - |
38 | 46 | if ispc |
39 | | - |
40 | | -p_relative_to = [p_relative_to, ... |
| 47 | +p = [p, ... |
41 | 48 | {{"c:\a\b", "c:/", "../.."}, ... |
42 | 49 | {"c:\", "c:/a/b", "a/b"}, ... |
43 | 50 | {"c:/a/b", "c:/a/b", "."}, ... |
44 | 51 | {"c:/a/b", "c:/a", ".."}, ... |
45 | 52 | {"c:\a/b\c/d", "c:/a\b", "../.."}, ... |
46 | 53 | {"c:/path", "d:/path", ""}}]; |
47 | | - |
48 | | -p_proximate_to = p_relative_to; |
49 | | -% NOTE: ".." in proximate_to(base) is ambiguous including for python.pathlib, C++ <filesystem>, etc |
50 | | - |
51 | | -p_proximate_to{8}{3} = "/"; |
52 | | -p_proximate_to{12}{3} = "c"; |
53 | | -p_proximate_to{13}{3} = "/a/b"; |
54 | | - |
55 | | -p_proximate_to{end}{3} = "d:/path"; |
56 | | -end |
57 | | - |
58 | 54 | end |
59 | 55 |
|
60 | 56 | end |
61 | 57 |
|
| 58 | +function p = init_prox() |
| 59 | +% NOTE: ".." in proximate_to(base) is ambiguous including for python.pathlib, C++ <filesystem>, etc |
62 | 60 |
|
| 61 | +p = init_rel(); |
63 | 62 |
|
64 | | -methods (Test) |
| 63 | +p{8}{3} = "/"; |
| 64 | +p{12}{3} = "c"; |
| 65 | +p{13}{3} = "/a/b"; |
65 | 66 |
|
66 | | -function test_relative_to(tc, p_relative_to) |
67 | | -tc.assumeTrue(stdlib.has_java()) |
68 | | -tc.verifyEqual(stdlib.relative_to(p_relative_to{1}, p_relative_to{2}), p_relative_to{3}, "relative_to(" + p_relative_to{1} + "," + p_relative_to{2}+")") |
69 | | -end |
70 | | - |
71 | | - |
72 | | -function test_proximate_to(tc, p_proximate_to) |
73 | | -tc.assumeTrue(stdlib.has_java()) |
74 | | -tc.verifyEqual(stdlib.proximate_to(p_proximate_to{1}, p_proximate_to{2}), p_proximate_to{3}, "proximate_to(" + p_proximate_to{1} + "," + p_proximate_to{2}+")") |
75 | | -end |
| 67 | +if ispc |
| 68 | +p{8}{3} = "/"; |
| 69 | +p{12}{3} = "c"; |
| 70 | +p{13}{3} = "/a/b"; |
76 | 71 |
|
| 72 | +p{end}{3} = "d:/path"; |
77 | 73 | end |
78 | | - |
79 | 74 | end |
0 commit comments