@@ -35,97 +35,97 @@ fn p(s: &str) -> &Path {
35
35
#[ test]
36
36
#[ cfg( windows) ]
37
37
fn path_join_handling ( ) {
38
- let absolute = p ( "/absolute" ) ;
38
+ let looks_absolute = p ( "/absolute" ) ;
39
39
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)"
42
42
) ;
43
- let bs_absolute = p ( " \ \ absolute") ;
43
+ let bs_looks_absolute = p ( r" \absolute") ;
44
44
assert ! (
45
- absolute . is_relative( ) ,
45
+ bs_looks_absolute . is_relative( ) ,
46
46
"on Windows, strange single-backslash paths are relative (and relative to the current drive)"
47
47
) ;
48
48
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 "
52
52
) ;
53
53
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 "
57
57
) ;
58
58
59
59
assert_eq ! (
60
60
p( "c:" ) . join( "relative" ) ,
61
61
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 "
63
63
) ;
64
64
assert_eq ! (
65
- p( "c:\ \ " ) . join( "relative" ) ,
66
- p( "c:\ \ relative" ) ,
65
+ p( r "c:\") . join( "relative" ) ,
66
+ p( r "c:\relative") ,
67
67
"absolute + relative = joined result"
68
68
) ;
69
69
70
70
assert_eq ! (
71
- p( "\\ \\ ? \\ base" ) . join( absolute ) ,
72
- p( "\\ \\ ? \\ base\ \ absolute" ) ,
71
+ p( r "\\?\ base") . join( looks_absolute ) ,
72
+ p( r "\\?\ base\absolute") ,
73
73
"absolute1 + unix-absolute2 = joined result with backslash"
74
74
) ;
75
75
assert_eq ! (
76
- p( "\\ \\ . \\ base" ) . join( absolute ) ,
77
- p( "\\ \\ . \\ base\ \ absolute" ) ,
76
+ p( r "\\.\ base") . join( looks_absolute ) ,
77
+ p( r "\\.\ base\absolute") ,
78
78
"absolute1 + absolute2 = joined result with backslash (device namespace)"
79
79
) ;
80
80
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") ,
83
83
"absolute1 + absolute2 = joined result"
84
84
) ;
85
85
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") ,
88
88
"absolute1 + absolute2 = joined result (device namespace)"
89
89
) ;
90
90
91
91
assert_eq ! ( p( "/" ) . join( "C:" ) , p( "C:" ) , "unix-absolute + win-drive = win-drive" ) ;
92
92
assert_eq ! (
93
93
p( "d:/" ) . join( "C:" ) ,
94
94
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: "
96
96
) ;
97
97
assert_eq ! (
98
- p( "d:\\ " ) . join( "C:\ \ " ) ,
99
- p( "C:\ \ " ) ,
98
+ p( r "d:\") . join( r "C:\") ,
99
+ p( r "C:\") ,
100
100
"d-drive-with-bs + c-drive-with-bs = c-drive-with-bs - nothing special happens with backslashes"
101
101
) ;
102
102
assert_eq ! (
103
- p( "c:\\ " ) . join( "\\ \\ . \ \ " ) ,
104
- p( "\\ \\ . \ \ " ) ,
103
+ p( r "c:\") . join( r "\\. \") ,
104
+ p( r "\\. \") ,
105
105
"c-drive-with-bs + device-namespace-unc = device-namespace-unc"
106
106
) ;
107
107
assert_eq ! (
108
108
p( "/" ) . join( "C:/" ) ,
109
- p( "C:\ \ " ) ,
109
+ p( r "C:\") ,
110
110
"unix-absolute + win-drive = win-drive, strangely enough it changed the trailing slash to backslash, so better not have trailing slashes"
111
111
) ;
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" ) ;
113
113
assert_eq ! (
114
- p( " \\ \\ .") . join( "C:" ) ,
114
+ p( r" \\.") . join( "C:" ) ,
115
115
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: "
117
117
) ;
118
118
assert_eq ! ( p( "relative" ) . join( "C:" ) , p( "C:" ) , "relative + win-drive = win-drive" ) ;
119
119
120
120
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 "
124
124
) ;
125
125
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 "
129
129
) ;
130
130
}
131
131
@@ -154,8 +154,8 @@ fn path_join_handling() {
154
154
assert_eq ! ( p( "/" ) . join( "C:" ) , p( "/C:" ) , "absolute + win-drive = joined result" ) ;
155
155
assert_eq ! ( p( "/" ) . join( "C:/" ) , p( "/C:/" ) , "absolute + win-absolute = joined result" ) ;
156
156
assert_eq ! (
157
- p( "/" ) . join( "C:\ \ " ) ,
158
- p( "/C:\ \ " ) ,
157
+ p( "/" ) . join( r "C:\") ,
158
+ p( r "/C:\") ,
159
159
"absolute + win-absolute = joined result"
160
160
) ;
161
161
assert_eq ! (
@@ -165,14 +165,14 @@ fn path_join_handling() {
165
165
) ;
166
166
167
167
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"
171
171
) ;
172
172
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"
176
176
) ;
177
177
}
178
178
0 commit comments