File tree Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Original file line number Diff line number Diff line change
1
+ classdef TestUnit < matlab .unittest .TestCase
2
+
3
+ methods (Test )
4
+
5
+ function test_expanduser(tc )
6
+ tc .verifyEmpty(expanduser(string .empty ))
7
+ tc .verifyFalse(startsWith(expanduser(" ~" ), " ~" ))
8
+ tc .verifyFalse(any(startsWith(expanduser([" ~" ," ~" ]), " ~" )))
9
+
10
+ a = expanduser([" ~" , " foo" ]);
11
+ tc .verifyEqual(a(2 ), " foo" )
12
+ tc .verifyNotEqual(a(1 ), " ~" )
13
+ end
14
+
15
+ end
16
+
17
+ end
Original file line number Diff line number Diff line change 1
1
function A = coerce_ds(A , dtype )
2
2
% used by h5save and ncsave
3
3
arguments
4
- A { mustBeNonempty }
4
+ A
5
5
dtype string
6
6
end
7
7
Original file line number Diff line number Diff line change 24
24
25
25
expanded = p ;
26
26
27
- if ~startsWith(expanded , " ~" )
28
- return
29
- end
30
-
31
27
if ispc
32
28
home = getenv(' USERPROFILE' );
33
29
else
34
30
home = getenv(' HOME' );
35
31
end
36
32
37
33
if ~isempty(home )
38
- expanded = fullfile(home , extractAfter(expanded , 1 ));
34
+ i = startsWith(expanded , " ~" );
35
+ expanded(i ) = fullfile(home , extractAfter(expanded(i ), 1 ));
39
36
end
40
37
41
38
end % function
You can’t perform that action at this time.
0 commit comments