5
5
function test_posix(tc )
6
6
import stdlib .fileio .posix
7
7
8
+ tc .verifyEmpty(posix(string .empty ))
9
+ tc .verifyEqual(posix(" " ), " " )
10
+
8
11
if ispc
9
12
tc .verifyFalse(contains(posix(" c:\foo" ), " \" ))
10
13
tc .verifyFalse(all(contains(posix([" x:\123" , " d:\abc" ]), " \" )))
11
14
end
12
15
13
- tc .verifyEmpty(posix(string .empty ))
14
16
end
15
17
16
18
function test_path_tail(tc )
17
19
18
20
import stdlib.fileio.path_tail
19
21
22
+ tc .verifyEmpty(path_tail(string .empty ))
23
+ tc .verifyEqual(path_tail(" " ), " " )
20
24
tc .verifyEqual(path_tail(" /foo/bar/baz" ), " baz" )
21
25
tc .verifyEqual(path_tail(" /foo/bar/baz/" ), " baz" )
22
26
tc .verifyEqual(path_tail(" /foo/bar/baz/." ), " baz" )
@@ -29,6 +33,10 @@ function test_is_absolute_path(tc)
29
33
30
34
import stdlib.fileio.is_absolute_path
31
35
% path need not exist
36
+
37
+ tc .verifyEmpty(is_absolute_path(string .empty ))
38
+ tc .verifyFalse(is_absolute_path(" " ))
39
+
32
40
tc .verifyTrue(is_absolute_path(' ~/foo' ))
33
41
if ispc
34
42
tc .verifyTrue(is_absolute_path(' x:/foo' ))
@@ -37,15 +45,16 @@ function test_is_absolute_path(tc)
37
45
tc .verifyTrue(is_absolute_path(' /foo' ))
38
46
end
39
47
40
- tc .verifyEmpty(is_absolute_path(string .empty ))
41
- tc .verifyFalse(is_absolute_path(" " ))
42
48
tc .verifyFalse(is_absolute_path(" c" ))
43
49
end
44
50
45
51
function test_absolute_path(tc )
46
52
47
53
import stdlib.fileio.absolute_path
48
54
55
+ tc .verifyEmpty(absolute_path(string .empty ))
56
+ tc .verifyEqual(absolute_path(" " ), string(pwd ))
57
+
49
58
pabs = absolute_path(' 2foo' );
50
59
pabs2 = absolute_path(' 4foo' );
51
60
tc .verifyFalse(startsWith(pabs , " 2" ))
@@ -64,19 +73,19 @@ function test_absolute_path(tc)
64
73
tc .verifyFalse(startsWith(va , " 2" ))
65
74
tc .verifyTrue(strncmp(va , vb , 2 ))
66
75
67
- tc .verifyEmpty(absolute_path(string .empty ))
68
- tc .verifyEqual(absolute_path(" " ), string(pwd ))
69
76
end
70
77
71
78
function test_with_suffix(tc )
72
79
import stdlib.fileio.with_suffix
80
+
81
+ tc .verifyEmpty(with_suffix(string .empty , " .nc" ))
82
+ tc .verifyEqual(with_suffix(" " , " " ), " " )
83
+
73
84
tc .verifyEqual(with_suffix(" foo.h5" , " .nc" ), " foo.nc" )
74
85
if ~verLessThan(" matlab" , " 9.9" )
75
86
% fileparts vectorized in R2020b
76
87
tc .verifyEqual(with_suffix([" foo.h5" , " bar.dat" ], " .nc" ), [" foo.nc" , " bar.nc" ])
77
88
78
- tc .verifyEmpty(with_suffix(string .empty , " .nc" ))
79
- tc .verifyEqual(with_suffix(" " , " " ), " " )
80
89
tc .verifyEqual(with_suffix(" c" , " " ), " c" )
81
90
tc .verifyEqual(with_suffix(" c.nc" , " " ), " c" )
82
91
tc .verifyEqual(with_suffix(" " , " .nc" ), " .nc" )
0 commit comments