@@ -35,97 +35,97 @@ fn p(s: &str) -> &Path {
3535#[ test]
3636#[ cfg( windows) ]
3737fn path_join_handling ( ) {
38- let absolute = p ( "/absolute" ) ;
38+ let looks_absolute = p ( "/absolute" ) ;
3939 assert ! (
40- absolute . is_relative( ) ,
41- "on Windows, absolute Linux paths are considered relative (and relative to the current drive)"
40+ looks_absolute . is_relative( ) ,
41+ "on Windows, ' absolute' Linux paths are relative (and relative to the current drive)"
4242 ) ;
43- let bs_absolute = p ( " \ \ absolute") ;
43+ let bs_looks_absolute = p ( r" \absolute") ;
4444 assert ! (
45- absolute . is_relative( ) ,
45+ bs_looks_absolute . is_relative( ) ,
4646 "on Windows, strange single-backslash paths are relative (and relative to the current drive)"
4747 ) ;
4848 assert_eq ! (
49- p( "relative" ) . join( absolute ) ,
50- absolute ,
51- "relative + absolute = absolute - however, they kind of act like they are absolute in conjunction with relative base paths "
49+ p( "relative" ) . join( looks_absolute ) ,
50+ looks_absolute ,
51+ "relative + unix- absolute = unix- absolute - the relative path without a drive is replaced "
5252 ) ;
5353 assert_eq ! (
54- p( "relative" ) . join( bs_absolute ) ,
55- bs_absolute ,
56- "relative + absolute = absolute - backslashes aren't special here, and it just acts like it's absolute "
54+ p( "relative" ) . join( bs_looks_absolute ) ,
55+ bs_looks_absolute ,
56+ "relative + unix- absolute = unix- absolute - the relative path without a drive is replaced - backslashes aren't special here "
5757 ) ;
5858
5959 assert_eq ! (
6060 p( "c:" ) . join( "relative" ) ,
6161 p( "c:relative" ) ,
62- "drive + relative = strange joined result with missing backslash, but it's a valid path that works just like `c: \r elative` "
62+ "drive + relative = relative to the drive-specific current directory "
6363 ) ;
6464 assert_eq ! (
65- p( "c:\ \ " ) . join( "relative" ) ,
66- p( "c:\ \ relative" ) ,
65+ p( r "c:\") . join( "relative" ) ,
66+ p( r "c:\relative") ,
6767 "absolute + relative = joined result"
6868 ) ;
6969
7070 assert_eq ! (
71- p( "\\ \\ ? \\ base" ) . join( absolute ) ,
72- p( "\\ \\ ? \\ base\ \ absolute" ) ,
71+ p( r "\\?\ base") . join( looks_absolute ) ,
72+ p( r "\\?\ base\absolute") ,
7373 "absolute1 + unix-absolute2 = joined result with backslash"
7474 ) ;
7575 assert_eq ! (
76- p( "\\ \\ . \\ base" ) . join( absolute ) ,
77- p( "\\ \\ . \\ base\ \ absolute" ) ,
76+ p( r "\\.\ base") . join( looks_absolute ) ,
77+ p( r "\\.\ base\absolute") ,
7878 "absolute1 + absolute2 = joined result with backslash (device namespace)"
7979 ) ;
8080 assert_eq ! (
81- p( "\\ \\ ? \\ base" ) . join( bs_absolute ) ,
82- p( "\\ \\ ? \\ base\ \ absolute" ) ,
81+ p( r "\\?\ base") . join( bs_looks_absolute ) ,
82+ p( r "\\?\ base\absolute") ,
8383 "absolute1 + absolute2 = joined result"
8484 ) ;
8585 assert_eq ! (
86- p( "\\ \\ . \\ base" ) . join( bs_absolute ) ,
87- p( "\\ \\ . \\ base\ \ absolute" ) ,
86+ p( r "\\.\ base") . join( bs_looks_absolute ) ,
87+ p( r "\\.\ base\absolute") ,
8888 "absolute1 + absolute2 = joined result (device namespace)"
8989 ) ;
9090
9191 assert_eq ! ( p( "/" ) . join( "C:" ) , p( "C:" ) , "unix-absolute + win-drive = win-drive" ) ;
9292 assert_eq ! (
9393 p( "d:/" ) . join( "C:" ) ,
9494 p( "C:" ) ,
95- "d-drive + c-drive = c-drive - interesting, as C: is supposed to be relative "
95+ "d-drive + c-drive-relative = c-drive-relative - C: is relative but not on D: "
9696 ) ;
9797 assert_eq ! (
98- p( "d:\\ " ) . join( "C:\ \ " ) ,
99- p( "C:\ \ " ) ,
98+ p( r "d:\") . join( r "C:\") ,
99+ p( r "C:\") ,
100100 "d-drive-with-bs + c-drive-with-bs = c-drive-with-bs - nothing special happens with backslashes"
101101 ) ;
102102 assert_eq ! (
103- p( "c:\\ " ) . join( "\\ \\ . \ \ " ) ,
104- p( "\\ \\ . \ \ " ) ,
103+ p( r "c:\") . join( r "\\. \") ,
104+ p( r "\\. \") ,
105105 "c-drive-with-bs + device-namespace-unc = device-namespace-unc"
106106 ) ;
107107 assert_eq ! (
108108 p( "/" ) . join( "C:/" ) ,
109- p( "C:\ \ " ) ,
109+ p( r "C:\") ,
110110 "unix-absolute + win-drive = win-drive, strangely enough it changed the trailing slash to backslash, so better not have trailing slashes"
111111 ) ;
112- assert_eq ! ( p( "/" ) . join( "C:\\ " ) , p( "C:\ \ " ) , "unix-absolute + win-drive = win-drive" ) ;
112+ assert_eq ! ( p( "/" ) . join( r "C:\") , p( r "C:\") , "unix-absolute + win-drive = win-drive" ) ;
113113 assert_eq ! (
114- p( " \\ \\ .") . join( "C:" ) ,
114+ p( r" \\.") . join( "C:" ) ,
115115 p( "C:" ) ,
116- "device-namespace-unc + win-drive-relative = win-drive-relative - c: was supposed to be relative, but it's not acting like it. "
116+ r "device-namespace-unc + win-drive-relative = win-drive-relative - C: as a relative path is not the C: device, so this is not \\.\C: "
117117 ) ;
118118 assert_eq ! ( p( "relative" ) . join( "C:" ) , p( "C:" ) , "relative + win-drive = win-drive" ) ;
119119
120120 assert_eq ! (
121- p( "/" ) . join( " \\ \\ localhost") ,
122- p( " \ \ localhost") ,
123- "unix-absolute + win-absolute-unc = win-absolute-unc "
121+ p( "/" ) . join( r" \\localhost") ,
122+ p( r" \localhost") ,
123+ "unix-absolute + win-absolute-unc-host = strangely, single-backslashed host "
124124 ) ;
125125 assert_eq ! (
126- p( "relative" ) . join( " \\ \\ localhost") ,
127- p( " \\ \\ localhost") ,
128- "relative + win-absolute-unc = win-absolute-unc"
126+ p( "relative" ) . join( r" \\localhost") ,
127+ p( r" \\localhost") ,
128+ "relative + win-absolute-unc-host = win-absolute-unc-host "
129129 ) ;
130130}
131131
@@ -154,8 +154,8 @@ fn path_join_handling() {
154154 assert_eq ! ( p( "/" ) . join( "C:" ) , p( "/C:" ) , "absolute + win-drive = joined result" ) ;
155155 assert_eq ! ( p( "/" ) . join( "C:/" ) , p( "/C:/" ) , "absolute + win-absolute = joined result" ) ;
156156 assert_eq ! (
157- p( "/" ) . join( "C:\ \ " ) ,
158- p( "/C:\ \ " ) ,
157+ p( "/" ) . join( r "C:\") ,
158+ p( r "/C:\") ,
159159 "absolute + win-absolute = joined result"
160160 ) ;
161161 assert_eq ! (
@@ -165,14 +165,14 @@ fn path_join_handling() {
165165 ) ;
166166
167167 assert_eq ! (
168- p( "/" ) . join( "\\ localhost" ) ,
169- p( "/\\ localhost" ) ,
170- "absolute + win-absolute-unc = joined result"
168+ p( "/" ) . join( r "\\localhost") ,
169+ p( r "/\\localhost") ,
170+ "absolute + win-absolute-unc-host = joined result"
171171 ) ;
172172 assert_eq ! (
173- p( "relative" ) . join( "\\ localhost" ) ,
174- p( "relative/\\ localhost" ) ,
175- "relative + win-absolute-unc = joined result"
173+ p( "relative" ) . join( r "\\localhost") ,
174+ p( r "relative/\\localhost") ,
175+ "relative + win-absolute-unc-host = joined result"
176176 ) ;
177177}
178178
0 commit comments