|
1 | 1 | classdef TestFileImpure < matlab.unittest.TestCase |
2 | 2 |
|
3 | 3 | properties(TestParameter) |
4 | | -p_exists = {{pwd(), true}, {mfilename("fullpath") + ".m", true}, {"TestFileImpure.m", true} {tempname, false}} |
5 | | -% on CI matlabroot can be writable! |
6 | | - |
7 | 4 | p_is_writable = {{pwd(), true}, {"not-exists", false}}; |
8 | 5 |
|
9 | 6 | p_expand = {{"", ""}, {"~abc", "~abc"}, {"~", stdlib.homedir()}, {"~/c", stdlib.homedir() + "/c"}, {'~/////c', stdlib.homedir() + "/c"}}; |
|
20 | 17 |
|
21 | 18 | methods (Test) |
22 | 19 |
|
23 | | -function test_exists(tc, p_exists) |
24 | | -ok = stdlib.exists(p_exists{1}); |
25 | | -tc.verifyEqual(ok, p_exists{2}) |
26 | | -end |
27 | | - |
28 | 20 | function test_file_size(tc) |
29 | 21 | s = stdlib.file_size(mfilename("fullpath") + ".m"); |
30 | 22 | tc.verifyGreaterThan(s, 0) |
31 | 23 | end |
32 | 24 |
|
33 | 25 |
|
34 | | -function test_is_readable(tc, p_exists) |
35 | | -ok = stdlib.is_readable(p_exists{1}); |
36 | | -tc.verifyEqual(ok, p_exists{2}) |
37 | | -end |
38 | | - |
39 | | - |
40 | 26 | function test_is_writable(tc, p_is_writable) |
41 | 27 | ok = stdlib.is_writable(p_is_writable{1}); |
42 | 28 | tc.verifyEqual(ok, p_is_writable{2}) |
@@ -70,20 +56,9 @@ function test_samepath(tc, p_same) |
70 | 56 |
|
71 | 57 | function test_get_pid(tc) |
72 | 58 | pid = stdlib.get_pid(); |
73 | | -tc.verifyGreaterThan(pid, 0, "expected positive PID") |
| 59 | +tc.verifyGreaterThan(pid, 0) |
74 | 60 | end |
75 | 61 |
|
76 | | -function test_get_permissions(tc) |
77 | | -import matlab.unittest.constraints.StartsWithSubstring |
78 | | -import matlab.unittest.constraints.IsOfClass |
79 | | - |
80 | | -p = stdlib.get_permissions("."); |
81 | | -tc.verifyThat(p, StartsWithSubstring("r")) |
82 | | -tc.verifyThat(p, IsOfClass("char")) |
83 | | - |
84 | | -p = stdlib.get_permissions(tempname); |
85 | | -tc.verifyEmpty(p) |
86 | | -end |
87 | 62 |
|
88 | 63 | function test_handle2filename(tc, ph) |
89 | 64 | tc.verifyEqual(stdlib.handle2filename(ph{1}), string(ph{2})) |
|
0 commit comments