|
1 | 1 | classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}, ... |
2 | | - TestTags = {'R2019b', 'impure'}) ... |
| 2 | + TestTags = {'R2017b', 'impure'}) ... |
3 | 3 | TestFileImpure < matlab.unittest.TestCase |
4 | 4 |
|
5 | 5 | properties (TestParameter) |
6 | 6 | ph = {{0, '"stdin"'}, {1, '"stdout"'}, {2, '"stderr"'}, {fopen(tempname()), ''}} |
| 7 | +end |
7 | 8 |
|
8 | | -p_file_size = {mfilename("fullpath") + ".m"} |
| 9 | +methods(TestClassSetup) |
| 10 | +function test_dirs(tc) |
| 11 | +tc.applyFixture(matlab.unittest.fixtures.WorkingFolderFixture()) |
| 12 | +end |
9 | 13 | end |
10 | 14 |
|
11 | 15 |
|
12 | 16 | methods (Test) |
13 | 17 |
|
14 | | -function test_file_size(tc, p_file_size) |
15 | | -s = stdlib.file_size(p_file_size); |
16 | | -tc.verifyGreaterThan(s, 0) |
| 18 | +function test_file_size(tc) |
| 19 | +n = "test_file_size.bin"; |
| 20 | +fid = fopen(n, "wb"); |
| 21 | +fwrite(fid, 0, 'uint8'); |
| 22 | +fclose(fid); |
| 23 | + |
| 24 | +s = stdlib.file_size(n); |
| 25 | +tc.verifyEqual(s, 1) |
17 | 26 | end |
18 | 27 |
|
19 | 28 |
|
20 | 29 | function test_null_file(tc) |
| 30 | +n = stdlib.null_file; |
| 31 | + |
21 | 32 | if ispc() |
22 | | - tc.verifyEqual(stdlib.null_file, "NUL") |
| 33 | + tc.verifyEqual(n, "NUL") |
| 34 | +elseif stdlib.matlabOlderThan('R2019b') |
| 35 | + tc.verifyEqual(n, '/dev/null') |
23 | 36 | else |
24 | | - tc.verifyThat(stdlib.null_file, matlab.unittest.constraints.IsFile) |
| 37 | + tc.verifyThat(n, matlab.unittest.constraints.IsFile) |
25 | 38 | end |
26 | 39 | end |
27 | 40 |
|
28 | 41 |
|
29 | 42 | function test_makedir(tc) |
30 | | -d = tempname(); |
| 43 | +d = "test_makedir.dir"; |
31 | 44 | stdlib.makedir(d) |
32 | | -tc.verifyThat(d, matlab.unittest.constraints.IsFolder) |
33 | | -rmdir(d) |
| 45 | + |
| 46 | +if stdlib.matlabOlderThan('R2018a') |
| 47 | + tc.assertTrue(isfolder(d)) |
| 48 | +else |
| 49 | + tc.verifyThat(d, matlab.unittest.constraints.IsFolder) |
| 50 | +end |
34 | 51 | end |
35 | 52 |
|
36 | 53 |
|
|
0 commit comments