File tree Expand file tree Collapse file tree 4 files changed +15
-21
lines changed Expand file tree Collapse file tree 4 files changed +15
-21
lines changed Original file line number Diff line number Diff line change 99% * root_dir('path/to/file') returns ''
1010
1111function r = root_dir(p )
12- arguments
13- p (1 ,1 ) string
14- end
15-
16- r = " " ;
1712
1813if startsWith(p , [" /" , filesep ])
1914 r = extractBefore(p , 2 );
2015elseif ispc() && ~isempty(regexp(p , ' ^[A-Za-z]:[\\ /]' ,' once' ))
2116 r = extractBetween(p , 3 , 3 );
17+ else
18+ r = extractBefore(p , 1 );
2219end
2320
2421end
Original file line number Diff line number Diff line change 66
77
88function r = root_name(p )
9- arguments
10- p (1 ,1 ) string
11- end
12-
13- r = " " ;
149
1510if ispc() && ~isempty(regexp(p , ' ^[A-Za-z]:' , ' once' ))
1611 r = extractBefore(p , 3 );
12+ else
13+ r = extractBefore(p , 1 );
1714end
1815
1916end
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ function test_is_mount(tc, B_ps)
7777
7878 if ispc()
7979 sd = getenv(" SystemDrive" );
80- tc .assertTrue (sd == stdlib .root_name(sd ), sd )
80+ tc .assertEqual (sd , stdlib .root_name(sd ))
8181 tc .verifyFalse(stdlib .is_mount(sd , B_ps ), sd )
8282 tc .verifyTrue(stdlib .is_mount(sd + " /" , B_ps ), sd )
8383 tc .verifyTrue(stdlib .is_mount(sd + " \" , B_ps ), sd )
Original file line number Diff line number Diff line change 1313
1414function test_root(tc , p )
1515r = stdlib .root(p{1 });
16- tc .assertClass(r , ' string ' )
17- tc .verifyEqual(r , p{2 })
16+ tc .assertClass(r , class(p{ 1 }) )
17+ tc .verifyEqual(r , p{2 }, " root( " + p{ 1 } + " ) " )
1818end
1919
2020function test_root_dir(tc , rd )
2121r = stdlib .root_dir(rd{1 });
22- tc .assertClass(r , ' string ' )
22+ tc .assertClass(r , class(rd{ 1 }) )
2323tc .verifyEqual(r , rd{2 }, " root_dir(" + rd{1 } + " )" )
2424end
2525
2626function test_root_name(tc , rn )
2727r = stdlib .root_name(rn{1 });
28- tc .assertClass(r , ' string ' )
28+ tc .assertClass(r , class(rn{ 1 }) )
2929tc .verifyEqual(r , rn{2 })
3030end
3131
@@ -40,15 +40,15 @@ function test_root_name(tc, rn)
4040{" a/b" , " " }, ...
4141{" ./a/b" , " " }, ...
4242{" /etc" , " /" }, ...
43- {' /etc' , " / " }, ...
43+ {' /etc' , ' / ' }, ...
4444{" c:" , " " }, ...
4545{" c:/etc" , " " }, ...
46- {' c:\etc' , " " }};
46+ {' c:\etc' , ' ' }};
4747
4848if ispc()
4949 p{6 }{2 } = " c:" ;
5050 p{7 }{2 } = " c:/" ;
51- p{8 }{2 } = " c:\" ;
51+ p{8 }{2 } = ' c:\' ;
5252end
5353
5454end
@@ -59,12 +59,12 @@ function test_root_name(tc, rn)
5959p = init_root();
6060
6161p{4 }{2 } = " " ;
62- p{5 }{2 } = " " ;
62+ p{5 }{2 } = ' ' ;
6363
6464if ispc()
6565 p{6 }{2 } = " c:" ;
6666 p{7 }{2 } = " c:" ;
67- p{8 }{2 } = " c: " ;
67+ p{8 }{2 } = ' c: ' ;
6868end
6969
7070end
@@ -77,7 +77,7 @@ function test_root_name(tc, rn)
7777if ispc()
7878 p{6 }{2 } = " " ;
7979 p{7 }{2 } = " /" ;
80- p{8 }{2 } = " \ " ;
80+ p{8 }{2 } = ' \ ' ;
8181end
8282
8383end
You can’t perform that action at this time.
0 commit comments