OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/uri.h" | 5 #include "vm/uri.h" |
6 #include "vm/unit_test.h" | 6 #include "vm/unit_test.h" |
7 | 7 |
8 namespace dart { | 8 namespace dart { |
9 | 9 |
10 TEST_CASE(ParseUri_WithScheme_NoQueryNoUser) { | 10 TEST_CASE(ParseUri_WithScheme_NoQueryNoUser) { |
11 ParsedUri uri; | 11 ParsedUri uri; |
12 EXPECT(ParseUri("foo://example.com:8042/over/there", &uri)); | 12 EXPECT(ParseUri("foo://example.com:8042/over/there", &uri)); |
13 EXPECT_STREQ("foo", uri.scheme); | 13 EXPECT_STREQ("foo", uri.scheme); |
14 EXPECT(uri.userinfo == NULL); | 14 EXPECT(uri.userinfo == NULL); |
15 EXPECT_STREQ("example.com", uri.host); | 15 EXPECT_STREQ("example.com", uri.host); |
16 EXPECT_STREQ("8042", uri.port); | 16 EXPECT_STREQ("8042", uri.port); |
17 EXPECT_STREQ("/over/there", uri.path); | 17 EXPECT_STREQ("/over/there", uri.path); |
18 EXPECT(uri.query == NULL); | 18 EXPECT(uri.query == NULL); |
19 EXPECT(uri.fragment == NULL); | 19 EXPECT(uri.fragment == NULL); |
20 } | 20 } |
21 | 21 |
22 | |
23 TEST_CASE(ParseUri_WithScheme_WithQuery) { | 22 TEST_CASE(ParseUri_WithScheme_WithQuery) { |
24 ParsedUri uri; | 23 ParsedUri uri; |
25 EXPECT(ParseUri("foo://example.com:8042/over/there?name=ferret", &uri)); | 24 EXPECT(ParseUri("foo://example.com:8042/over/there?name=ferret", &uri)); |
26 EXPECT_STREQ("foo", uri.scheme); | 25 EXPECT_STREQ("foo", uri.scheme); |
27 EXPECT(uri.userinfo == NULL); | 26 EXPECT(uri.userinfo == NULL); |
28 EXPECT_STREQ("example.com", uri.host); | 27 EXPECT_STREQ("example.com", uri.host); |
29 EXPECT_STREQ("8042", uri.port); | 28 EXPECT_STREQ("8042", uri.port); |
30 EXPECT_STREQ("/over/there", uri.path); | 29 EXPECT_STREQ("/over/there", uri.path); |
31 EXPECT_STREQ("name=ferret", uri.query); | 30 EXPECT_STREQ("name=ferret", uri.query); |
32 EXPECT(uri.fragment == NULL); | 31 EXPECT(uri.fragment == NULL); |
33 } | 32 } |
34 | 33 |
35 | |
36 TEST_CASE(ParseUri_WithScheme_WithFragment) { | 34 TEST_CASE(ParseUri_WithScheme_WithFragment) { |
37 ParsedUri uri; | 35 ParsedUri uri; |
38 EXPECT(ParseUri("foo://example.com:8042/over/there#fragment", &uri)); | 36 EXPECT(ParseUri("foo://example.com:8042/over/there#fragment", &uri)); |
39 EXPECT_STREQ("foo", uri.scheme); | 37 EXPECT_STREQ("foo", uri.scheme); |
40 EXPECT(uri.userinfo == NULL); | 38 EXPECT(uri.userinfo == NULL); |
41 EXPECT_STREQ("example.com", uri.host); | 39 EXPECT_STREQ("example.com", uri.host); |
42 EXPECT_STREQ("8042", uri.port); | 40 EXPECT_STREQ("8042", uri.port); |
43 EXPECT_STREQ("/over/there", uri.path); | 41 EXPECT_STREQ("/over/there", uri.path); |
44 EXPECT(uri.query == NULL); | 42 EXPECT(uri.query == NULL); |
45 EXPECT_STREQ("fragment", uri.fragment); | 43 EXPECT_STREQ("fragment", uri.fragment); |
46 } | 44 } |
47 | 45 |
48 | |
49 TEST_CASE(ParseUri_WithScheme_WithQueryWithFragment) { | 46 TEST_CASE(ParseUri_WithScheme_WithQueryWithFragment) { |
50 ParsedUri uri; | 47 ParsedUri uri; |
51 EXPECT( | 48 EXPECT( |
52 ParseUri("foo://example.com:8042/over/there?name=ferret#fragment", &uri)); | 49 ParseUri("foo://example.com:8042/over/there?name=ferret#fragment", &uri)); |
53 EXPECT_STREQ("foo", uri.scheme); | 50 EXPECT_STREQ("foo", uri.scheme); |
54 EXPECT(uri.userinfo == NULL); | 51 EXPECT(uri.userinfo == NULL); |
55 EXPECT_STREQ("example.com", uri.host); | 52 EXPECT_STREQ("example.com", uri.host); |
56 EXPECT_STREQ("8042", uri.port); | 53 EXPECT_STREQ("8042", uri.port); |
57 EXPECT_STREQ("/over/there", uri.path); | 54 EXPECT_STREQ("/over/there", uri.path); |
58 EXPECT_STREQ("name=ferret", uri.query); | 55 EXPECT_STREQ("name=ferret", uri.query); |
59 EXPECT_STREQ("fragment", uri.fragment); | 56 EXPECT_STREQ("fragment", uri.fragment); |
60 } | 57 } |
61 | 58 |
62 | |
63 TEST_CASE(ParseUri_WithScheme_WithUser) { | 59 TEST_CASE(ParseUri_WithScheme_WithUser) { |
64 ParsedUri uri; | 60 ParsedUri uri; |
65 EXPECT(ParseUri("foo://user@example.com:8042/over/there", &uri)); | 61 EXPECT(ParseUri("foo://user@example.com:8042/over/there", &uri)); |
66 EXPECT_STREQ("foo", uri.scheme); | 62 EXPECT_STREQ("foo", uri.scheme); |
67 EXPECT_STREQ("user", uri.userinfo); | 63 EXPECT_STREQ("user", uri.userinfo); |
68 EXPECT_STREQ("example.com", uri.host); | 64 EXPECT_STREQ("example.com", uri.host); |
69 EXPECT_STREQ("8042", uri.port); | 65 EXPECT_STREQ("8042", uri.port); |
70 EXPECT_STREQ("/over/there", uri.path); | 66 EXPECT_STREQ("/over/there", uri.path); |
71 EXPECT(uri.query == NULL); | 67 EXPECT(uri.query == NULL); |
72 EXPECT(uri.fragment == NULL); | 68 EXPECT(uri.fragment == NULL); |
73 } | 69 } |
74 | 70 |
75 | |
76 TEST_CASE(ParseUri_WithScheme_ShortPath) { | 71 TEST_CASE(ParseUri_WithScheme_ShortPath) { |
77 ParsedUri uri; | 72 ParsedUri uri; |
78 EXPECT(ParseUri("foo://example.com:8042/", &uri)); | 73 EXPECT(ParseUri("foo://example.com:8042/", &uri)); |
79 EXPECT_STREQ("foo", uri.scheme); | 74 EXPECT_STREQ("foo", uri.scheme); |
80 EXPECT(uri.userinfo == NULL); | 75 EXPECT(uri.userinfo == NULL); |
81 EXPECT_STREQ("example.com", uri.host); | 76 EXPECT_STREQ("example.com", uri.host); |
82 EXPECT_STREQ("8042", uri.port); | 77 EXPECT_STREQ("8042", uri.port); |
83 EXPECT_STREQ("/", uri.path); | 78 EXPECT_STREQ("/", uri.path); |
84 EXPECT(uri.query == NULL); | 79 EXPECT(uri.query == NULL); |
85 EXPECT(uri.fragment == NULL); | 80 EXPECT(uri.fragment == NULL); |
86 } | 81 } |
87 | 82 |
88 | |
89 TEST_CASE(ParseUri_WithScheme_EmptyPath) { | 83 TEST_CASE(ParseUri_WithScheme_EmptyPath) { |
90 ParsedUri uri; | 84 ParsedUri uri; |
91 EXPECT(ParseUri("foo://example.com:8042", &uri)); | 85 EXPECT(ParseUri("foo://example.com:8042", &uri)); |
92 EXPECT_STREQ("foo", uri.scheme); | 86 EXPECT_STREQ("foo", uri.scheme); |
93 EXPECT(uri.userinfo == NULL); | 87 EXPECT(uri.userinfo == NULL); |
94 EXPECT_STREQ("example.com", uri.host); | 88 EXPECT_STREQ("example.com", uri.host); |
95 EXPECT_STREQ("8042", uri.port); | 89 EXPECT_STREQ("8042", uri.port); |
96 EXPECT_STREQ("", uri.path); | 90 EXPECT_STREQ("", uri.path); |
97 EXPECT(uri.query == NULL); | 91 EXPECT(uri.query == NULL); |
98 EXPECT(uri.fragment == NULL); | 92 EXPECT(uri.fragment == NULL); |
99 } | 93 } |
100 | 94 |
101 | |
102 TEST_CASE(ParseUri_WithScheme_Rootless1) { | 95 TEST_CASE(ParseUri_WithScheme_Rootless1) { |
103 ParsedUri uri; | 96 ParsedUri uri; |
104 EXPECT(ParseUri("foo:here", &uri)); | 97 EXPECT(ParseUri("foo:here", &uri)); |
105 EXPECT_STREQ("foo", uri.scheme); | 98 EXPECT_STREQ("foo", uri.scheme); |
106 EXPECT(uri.userinfo == NULL); | 99 EXPECT(uri.userinfo == NULL); |
107 EXPECT(uri.host == NULL); | 100 EXPECT(uri.host == NULL); |
108 EXPECT(uri.port == NULL); | 101 EXPECT(uri.port == NULL); |
109 EXPECT_STREQ("here", uri.path); | 102 EXPECT_STREQ("here", uri.path); |
110 EXPECT(uri.query == NULL); | 103 EXPECT(uri.query == NULL); |
111 EXPECT(uri.fragment == NULL); | 104 EXPECT(uri.fragment == NULL); |
112 } | 105 } |
113 | 106 |
114 | |
115 TEST_CASE(ParseUri_WithScheme_Rootless2) { | 107 TEST_CASE(ParseUri_WithScheme_Rootless2) { |
116 ParsedUri uri; | 108 ParsedUri uri; |
117 EXPECT(ParseUri("foo:or/here", &uri)); | 109 EXPECT(ParseUri("foo:or/here", &uri)); |
118 EXPECT_STREQ("foo", uri.scheme); | 110 EXPECT_STREQ("foo", uri.scheme); |
119 EXPECT(uri.userinfo == NULL); | 111 EXPECT(uri.userinfo == NULL); |
120 EXPECT(uri.host == NULL); | 112 EXPECT(uri.host == NULL); |
121 EXPECT(uri.port == NULL); | 113 EXPECT(uri.port == NULL); |
122 EXPECT_STREQ("or/here", uri.path); | 114 EXPECT_STREQ("or/here", uri.path); |
123 EXPECT(uri.query == NULL); | 115 EXPECT(uri.query == NULL); |
124 EXPECT(uri.fragment == NULL); | 116 EXPECT(uri.fragment == NULL); |
125 } | 117 } |
126 | 118 |
127 | |
128 TEST_CASE(ParseUri_NoScheme_AbsPath_WithAuthority) { | 119 TEST_CASE(ParseUri_NoScheme_AbsPath_WithAuthority) { |
129 ParsedUri uri; | 120 ParsedUri uri; |
130 EXPECT(ParseUri("//example.com:8042/over/there", &uri)); | 121 EXPECT(ParseUri("//example.com:8042/over/there", &uri)); |
131 EXPECT(uri.scheme == NULL); | 122 EXPECT(uri.scheme == NULL); |
132 EXPECT(uri.userinfo == NULL); | 123 EXPECT(uri.userinfo == NULL); |
133 EXPECT_STREQ("example.com", uri.host); | 124 EXPECT_STREQ("example.com", uri.host); |
134 EXPECT_STREQ("8042", uri.port); | 125 EXPECT_STREQ("8042", uri.port); |
135 EXPECT_STREQ("/over/there", uri.path); | 126 EXPECT_STREQ("/over/there", uri.path); |
136 EXPECT(uri.query == NULL); | 127 EXPECT(uri.query == NULL); |
137 EXPECT(uri.fragment == NULL); | 128 EXPECT(uri.fragment == NULL); |
138 } | 129 } |
139 | 130 |
140 | |
141 TEST_CASE(ParseUri_NoScheme_AbsPath_NoAuthority) { | 131 TEST_CASE(ParseUri_NoScheme_AbsPath_NoAuthority) { |
142 ParsedUri uri; | 132 ParsedUri uri; |
143 EXPECT(ParseUri("/over/there", &uri)); | 133 EXPECT(ParseUri("/over/there", &uri)); |
144 EXPECT(uri.scheme == NULL); | 134 EXPECT(uri.scheme == NULL); |
145 EXPECT(uri.userinfo == NULL); | 135 EXPECT(uri.userinfo == NULL); |
146 EXPECT(uri.host == NULL); | 136 EXPECT(uri.host == NULL); |
147 EXPECT(uri.port == NULL); | 137 EXPECT(uri.port == NULL); |
148 EXPECT_STREQ("/over/there", uri.path); | 138 EXPECT_STREQ("/over/there", uri.path); |
149 EXPECT(uri.query == NULL); | 139 EXPECT(uri.query == NULL); |
150 EXPECT(uri.fragment == NULL); | 140 EXPECT(uri.fragment == NULL); |
151 } | 141 } |
152 | 142 |
153 | |
154 // Colons are permitted in path segments, in many cases. | 143 // Colons are permitted in path segments, in many cases. |
155 TEST_CASE(ParseUri_NoScheme_AbsPath_StrayColon) { | 144 TEST_CASE(ParseUri_NoScheme_AbsPath_StrayColon) { |
156 ParsedUri uri; | 145 ParsedUri uri; |
157 EXPECT(ParseUri("/ov:er/there", &uri)); | 146 EXPECT(ParseUri("/ov:er/there", &uri)); |
158 EXPECT(uri.scheme == NULL); | 147 EXPECT(uri.scheme == NULL); |
159 EXPECT(uri.userinfo == NULL); | 148 EXPECT(uri.userinfo == NULL); |
160 EXPECT(uri.host == NULL); | 149 EXPECT(uri.host == NULL); |
161 EXPECT(uri.port == NULL); | 150 EXPECT(uri.port == NULL); |
162 EXPECT_STREQ("/ov:er/there", uri.path); | 151 EXPECT_STREQ("/ov:er/there", uri.path); |
163 EXPECT(uri.query == NULL); | 152 EXPECT(uri.query == NULL); |
164 } | 153 } |
165 | 154 |
166 | |
167 TEST_CASE(ParseUri_NoScheme_Rootless1) { | 155 TEST_CASE(ParseUri_NoScheme_Rootless1) { |
168 ParsedUri uri; | 156 ParsedUri uri; |
169 EXPECT(ParseUri("here", &uri)); | 157 EXPECT(ParseUri("here", &uri)); |
170 EXPECT(uri.scheme == NULL); | 158 EXPECT(uri.scheme == NULL); |
171 EXPECT(uri.userinfo == NULL); | 159 EXPECT(uri.userinfo == NULL); |
172 EXPECT(uri.host == NULL); | 160 EXPECT(uri.host == NULL); |
173 EXPECT(uri.port == NULL); | 161 EXPECT(uri.port == NULL); |
174 EXPECT_STREQ("here", uri.path); | 162 EXPECT_STREQ("here", uri.path); |
175 EXPECT(uri.query == NULL); | 163 EXPECT(uri.query == NULL); |
176 EXPECT(uri.fragment == NULL); | 164 EXPECT(uri.fragment == NULL); |
177 } | 165 } |
178 | 166 |
179 | |
180 TEST_CASE(ParseUri_NoScheme_Rootless2) { | 167 TEST_CASE(ParseUri_NoScheme_Rootless2) { |
181 ParsedUri uri; | 168 ParsedUri uri; |
182 EXPECT(ParseUri("or/here", &uri)); | 169 EXPECT(ParseUri("or/here", &uri)); |
183 EXPECT(uri.scheme == NULL); | 170 EXPECT(uri.scheme == NULL); |
184 EXPECT(uri.userinfo == NULL); | 171 EXPECT(uri.userinfo == NULL); |
185 EXPECT(uri.host == NULL); | 172 EXPECT(uri.host == NULL); |
186 EXPECT(uri.port == NULL); | 173 EXPECT(uri.port == NULL); |
187 EXPECT_STREQ("or/here", uri.path); | 174 EXPECT_STREQ("or/here", uri.path); |
188 EXPECT(uri.query == NULL); | 175 EXPECT(uri.query == NULL); |
189 EXPECT(uri.fragment == NULL); | 176 EXPECT(uri.fragment == NULL); |
190 } | 177 } |
191 | 178 |
192 | |
193 TEST_CASE(ParseUri_NoScheme_Empty) { | 179 TEST_CASE(ParseUri_NoScheme_Empty) { |
194 ParsedUri uri; | 180 ParsedUri uri; |
195 EXPECT(ParseUri("", &uri)); | 181 EXPECT(ParseUri("", &uri)); |
196 EXPECT(uri.scheme == NULL); | 182 EXPECT(uri.scheme == NULL); |
197 EXPECT(uri.userinfo == NULL); | 183 EXPECT(uri.userinfo == NULL); |
198 EXPECT(uri.host == NULL); | 184 EXPECT(uri.host == NULL); |
199 EXPECT(uri.port == NULL); | 185 EXPECT(uri.port == NULL); |
200 EXPECT_STREQ("", uri.path); | 186 EXPECT_STREQ("", uri.path); |
201 EXPECT(uri.query == NULL); | 187 EXPECT(uri.query == NULL); |
202 EXPECT(uri.fragment == NULL); | 188 EXPECT(uri.fragment == NULL); |
203 } | 189 } |
204 | 190 |
205 | |
206 TEST_CASE(ParseUri_NoScheme_QueryOnly) { | 191 TEST_CASE(ParseUri_NoScheme_QueryOnly) { |
207 ParsedUri uri; | 192 ParsedUri uri; |
208 EXPECT(ParseUri("?name=ferret", &uri)); | 193 EXPECT(ParseUri("?name=ferret", &uri)); |
209 EXPECT(uri.scheme == NULL); | 194 EXPECT(uri.scheme == NULL); |
210 EXPECT(uri.userinfo == NULL); | 195 EXPECT(uri.userinfo == NULL); |
211 EXPECT(uri.host == NULL); | 196 EXPECT(uri.host == NULL); |
212 EXPECT(uri.port == NULL); | 197 EXPECT(uri.port == NULL); |
213 EXPECT_STREQ("", uri.path); | 198 EXPECT_STREQ("", uri.path); |
214 EXPECT_STREQ("name=ferret", uri.query); | 199 EXPECT_STREQ("name=ferret", uri.query); |
215 EXPECT(uri.fragment == NULL); | 200 EXPECT(uri.fragment == NULL); |
216 } | 201 } |
217 | 202 |
218 | |
219 TEST_CASE(ParseUri_NoScheme_FragmentOnly) { | 203 TEST_CASE(ParseUri_NoScheme_FragmentOnly) { |
220 ParsedUri uri; | 204 ParsedUri uri; |
221 EXPECT(ParseUri("#fragment", &uri)); | 205 EXPECT(ParseUri("#fragment", &uri)); |
222 EXPECT(uri.scheme == NULL); | 206 EXPECT(uri.scheme == NULL); |
223 EXPECT(uri.userinfo == NULL); | 207 EXPECT(uri.userinfo == NULL); |
224 EXPECT(uri.host == NULL); | 208 EXPECT(uri.host == NULL); |
225 EXPECT(uri.port == NULL); | 209 EXPECT(uri.port == NULL); |
226 EXPECT_STREQ("", uri.path); | 210 EXPECT_STREQ("", uri.path); |
227 EXPECT(uri.query == NULL); | 211 EXPECT(uri.query == NULL); |
228 EXPECT_STREQ("fragment", uri.fragment); | 212 EXPECT_STREQ("fragment", uri.fragment); |
229 } | 213 } |
230 | 214 |
231 | |
232 TEST_CASE(ParseUri_LowerCaseScheme) { | 215 TEST_CASE(ParseUri_LowerCaseScheme) { |
233 ParsedUri uri; | 216 ParsedUri uri; |
234 EXPECT(ParseUri("ScHeMe:path", &uri)); | 217 EXPECT(ParseUri("ScHeMe:path", &uri)); |
235 EXPECT_STREQ("scheme", uri.scheme); | 218 EXPECT_STREQ("scheme", uri.scheme); |
236 EXPECT(uri.userinfo == NULL); | 219 EXPECT(uri.userinfo == NULL); |
237 EXPECT(uri.host == NULL); | 220 EXPECT(uri.host == NULL); |
238 EXPECT(uri.port == NULL); | 221 EXPECT(uri.port == NULL); |
239 EXPECT_STREQ("path", uri.path); | 222 EXPECT_STREQ("path", uri.path); |
240 EXPECT(uri.query == NULL); | 223 EXPECT(uri.query == NULL); |
241 EXPECT(uri.fragment == NULL); | 224 EXPECT(uri.fragment == NULL); |
242 } | 225 } |
243 | 226 |
244 | |
245 TEST_CASE(ParseUri_NormalizeEscapes_PathQueryFragment) { | 227 TEST_CASE(ParseUri_NormalizeEscapes_PathQueryFragment) { |
246 ParsedUri uri; | 228 ParsedUri uri; |
247 EXPECT(ParseUri("scheme:/This%09Is A P%61th?This%09Is A Qu%65ry#A Fr%61gment", | 229 EXPECT(ParseUri("scheme:/This%09Is A P%61th?This%09Is A Qu%65ry#A Fr%61gment", |
248 &uri)); | 230 &uri)); |
249 EXPECT_STREQ("scheme", uri.scheme); | 231 EXPECT_STREQ("scheme", uri.scheme); |
250 EXPECT(uri.userinfo == NULL); | 232 EXPECT(uri.userinfo == NULL); |
251 EXPECT(uri.host == NULL); | 233 EXPECT(uri.host == NULL); |
252 EXPECT(uri.port == NULL); | 234 EXPECT(uri.port == NULL); |
253 EXPECT_STREQ("/This%09Is%20A%20Path", uri.path); | 235 EXPECT_STREQ("/This%09Is%20A%20Path", uri.path); |
254 EXPECT_STREQ("This%09Is%20A%20Query", uri.query); | 236 EXPECT_STREQ("This%09Is%20A%20Query", uri.query); |
255 EXPECT_STREQ("A%20Fragment", uri.fragment); | 237 EXPECT_STREQ("A%20Fragment", uri.fragment); |
256 } | 238 } |
257 | 239 |
258 | |
259 TEST_CASE(ParseUri_NormalizeEscapes_UppercaseEscapesPreferred) { | 240 TEST_CASE(ParseUri_NormalizeEscapes_UppercaseEscapesPreferred) { |
260 ParsedUri uri; | 241 ParsedUri uri; |
261 EXPECT(ParseUri("scheme:/%1b%1B", &uri)); | 242 EXPECT(ParseUri("scheme:/%1b%1B", &uri)); |
262 EXPECT_STREQ("scheme", uri.scheme); | 243 EXPECT_STREQ("scheme", uri.scheme); |
263 EXPECT(uri.userinfo == NULL); | 244 EXPECT(uri.userinfo == NULL); |
264 EXPECT(uri.host == NULL); | 245 EXPECT(uri.host == NULL); |
265 EXPECT(uri.port == NULL); | 246 EXPECT(uri.port == NULL); |
266 EXPECT_STREQ("/%1B%1B", uri.path); | 247 EXPECT_STREQ("/%1B%1B", uri.path); |
267 EXPECT(uri.query == NULL); | 248 EXPECT(uri.query == NULL); |
268 EXPECT(uri.fragment == NULL); | 249 EXPECT(uri.fragment == NULL); |
269 } | 250 } |
270 | 251 |
271 | |
272 TEST_CASE(ParseUri_NormalizeEscapes_Authority) { | 252 TEST_CASE(ParseUri_NormalizeEscapes_Authority) { |
273 ParsedUri uri; | 253 ParsedUri uri; |
274 EXPECT(ParseUri("scheme://UsEr N%61%4de@h%4FsT.c%6fm:80/", &uri)); | 254 EXPECT(ParseUri("scheme://UsEr N%61%4de@h%4FsT.c%6fm:80/", &uri)); |
275 EXPECT_STREQ("scheme", uri.scheme); | 255 EXPECT_STREQ("scheme", uri.scheme); |
276 EXPECT_STREQ("UsEr%20NaMe", uri.userinfo); // Normalized, case preserved. | 256 EXPECT_STREQ("UsEr%20NaMe", uri.userinfo); // Normalized, case preserved. |
277 EXPECT_STREQ("host.com", uri.host); // Normalized, lower-cased. | 257 EXPECT_STREQ("host.com", uri.host); // Normalized, lower-cased. |
278 EXPECT_STREQ("80", uri.port); | 258 EXPECT_STREQ("80", uri.port); |
279 EXPECT_STREQ("/", uri.path); | 259 EXPECT_STREQ("/", uri.path); |
280 EXPECT(uri.query == NULL); | 260 EXPECT(uri.query == NULL); |
281 EXPECT(uri.fragment == NULL); | 261 EXPECT(uri.fragment == NULL); |
282 } | 262 } |
283 | 263 |
284 | |
285 TEST_CASE(ParseUri_NormalizeEscapes_UppercaseEscapeInHost) { | 264 TEST_CASE(ParseUri_NormalizeEscapes_UppercaseEscapeInHost) { |
286 ParsedUri uri; | 265 ParsedUri uri; |
287 EXPECT(ParseUri("scheme://tEst%1b/", &uri)); | 266 EXPECT(ParseUri("scheme://tEst%1b/", &uri)); |
288 EXPECT_STREQ("scheme", uri.scheme); | 267 EXPECT_STREQ("scheme", uri.scheme); |
289 EXPECT(uri.userinfo == NULL); | 268 EXPECT(uri.userinfo == NULL); |
290 EXPECT_STREQ("test%1B", uri.host); // Notice that %1B is upper-cased. | 269 EXPECT_STREQ("test%1B", uri.host); // Notice that %1B is upper-cased. |
291 EXPECT(uri.port == NULL); | 270 EXPECT(uri.port == NULL); |
292 EXPECT_STREQ("/", uri.path); | 271 EXPECT_STREQ("/", uri.path); |
293 EXPECT(uri.query == NULL); | 272 EXPECT(uri.query == NULL); |
294 EXPECT(uri.fragment == NULL); | 273 EXPECT(uri.fragment == NULL); |
295 } | 274 } |
296 | 275 |
297 | |
298 TEST_CASE(ParseUri_BrokenEscapeSequence) { | 276 TEST_CASE(ParseUri_BrokenEscapeSequence) { |
299 ParsedUri uri; | 277 ParsedUri uri; |
300 EXPECT(ParseUri("scheme:/%1g", &uri)); | 278 EXPECT(ParseUri("scheme:/%1g", &uri)); |
301 EXPECT_STREQ("scheme", uri.scheme); | 279 EXPECT_STREQ("scheme", uri.scheme); |
302 EXPECT(uri.userinfo == NULL); | 280 EXPECT(uri.userinfo == NULL); |
303 EXPECT(uri.host == NULL); | 281 EXPECT(uri.host == NULL); |
304 EXPECT(uri.port == NULL); | 282 EXPECT(uri.port == NULL); |
305 EXPECT_STREQ("/%1g", uri.path); // Broken sequence is unchanged. | 283 EXPECT_STREQ("/%1g", uri.path); // Broken sequence is unchanged. |
306 EXPECT(uri.query == NULL); | 284 EXPECT(uri.query == NULL); |
307 EXPECT(uri.fragment == NULL); | 285 EXPECT(uri.fragment == NULL); |
308 } | 286 } |
309 | 287 |
310 | |
311 TEST_CASE(ResolveUri_WithScheme_NoAuthorityNoQuery) { | 288 TEST_CASE(ResolveUri_WithScheme_NoAuthorityNoQuery) { |
312 const char* target_uri; | 289 const char* target_uri; |
313 EXPECT(ResolveUri("rscheme:/ref/path", | 290 EXPECT(ResolveUri("rscheme:/ref/path", |
314 "bscheme://buser@bhost:11/base/path?baseQuery", | 291 "bscheme://buser@bhost:11/base/path?baseQuery", |
315 &target_uri)); | 292 &target_uri)); |
316 EXPECT_STREQ("rscheme:/ref/path", target_uri); | 293 EXPECT_STREQ("rscheme:/ref/path", target_uri); |
317 } | 294 } |
318 | 295 |
319 | |
320 TEST_CASE(ResolveUri_WithScheme_WithAuthorityWithQuery) { | 296 TEST_CASE(ResolveUri_WithScheme_WithAuthorityWithQuery) { |
321 const char* target_uri; | 297 const char* target_uri; |
322 EXPECT(ResolveUri("rscheme://ruser@rhost:22/ref/path?refQuery", | 298 EXPECT(ResolveUri("rscheme://ruser@rhost:22/ref/path?refQuery", |
323 "bscheme://buser@bhost:11/base/path?baseQuery", | 299 "bscheme://buser@bhost:11/base/path?baseQuery", |
324 &target_uri)); | 300 &target_uri)); |
325 EXPECT_STREQ("rscheme://ruser@rhost:22/ref/path?refQuery", target_uri); | 301 EXPECT_STREQ("rscheme://ruser@rhost:22/ref/path?refQuery", target_uri); |
326 } | 302 } |
327 | 303 |
328 | |
329 TEST_CASE(ResolveUri_NoScheme_WithAuthority) { | 304 TEST_CASE(ResolveUri_NoScheme_WithAuthority) { |
330 const char* target_uri; | 305 const char* target_uri; |
331 EXPECT(ResolveUri("//ruser@rhost:22/ref/path", | 306 EXPECT(ResolveUri("//ruser@rhost:22/ref/path", |
332 "bscheme://buser@bhost:11/base/path?baseQuery", | 307 "bscheme://buser@bhost:11/base/path?baseQuery", |
333 &target_uri)); | 308 &target_uri)); |
334 EXPECT_STREQ("bscheme://ruser@rhost:22/ref/path", target_uri); | 309 EXPECT_STREQ("bscheme://ruser@rhost:22/ref/path", target_uri); |
335 } | 310 } |
336 | 311 |
337 | |
338 TEST_CASE(ResolveUri_NoSchemeNoAuthority_AbsolutePath) { | 312 TEST_CASE(ResolveUri_NoSchemeNoAuthority_AbsolutePath) { |
339 const char* target_uri; | 313 const char* target_uri; |
340 EXPECT(ResolveUri("/ref/path", "bscheme://buser@bhost:11/base/path?baseQuery", | 314 EXPECT(ResolveUri("/ref/path", "bscheme://buser@bhost:11/base/path?baseQuery", |
341 &target_uri)); | 315 &target_uri)); |
342 EXPECT_STREQ("bscheme://buser@bhost:11/ref/path", target_uri); | 316 EXPECT_STREQ("bscheme://buser@bhost:11/ref/path", target_uri); |
343 } | 317 } |
344 | 318 |
345 | |
346 TEST_CASE(ResolveUri_NoSchemeNoAuthority_RelativePath) { | 319 TEST_CASE(ResolveUri_NoSchemeNoAuthority_RelativePath) { |
347 const char* target_uri; | 320 const char* target_uri; |
348 EXPECT(ResolveUri("ref/path", "bscheme://buser@bhost:11/base/path?baseQuery", | 321 EXPECT(ResolveUri("ref/path", "bscheme://buser@bhost:11/base/path?baseQuery", |
349 &target_uri)); | 322 &target_uri)); |
350 EXPECT_STREQ("bscheme://buser@bhost:11/base/ref/path", target_uri); | 323 EXPECT_STREQ("bscheme://buser@bhost:11/base/ref/path", target_uri); |
351 } | 324 } |
352 | 325 |
353 | |
354 TEST_CASE(ResolveUri_NoSchemeNoAuthority_RelativePathEmptyBasePath) { | 326 TEST_CASE(ResolveUri_NoSchemeNoAuthority_RelativePathEmptyBasePath) { |
355 const char* target_uri; | 327 const char* target_uri; |
356 EXPECT(ResolveUri("ref/path", "bscheme://buser@bhost:11", &target_uri)); | 328 EXPECT(ResolveUri("ref/path", "bscheme://buser@bhost:11", &target_uri)); |
357 EXPECT_STREQ("bscheme://buser@bhost:11/ref/path", target_uri); | 329 EXPECT_STREQ("bscheme://buser@bhost:11/ref/path", target_uri); |
358 } | 330 } |
359 | 331 |
360 | |
361 TEST_CASE(ResolveUri_NoSchemeNoAuthority_RelativePathWeirdBasePath) { | 332 TEST_CASE(ResolveUri_NoSchemeNoAuthority_RelativePathWeirdBasePath) { |
362 const char* target_uri; | 333 const char* target_uri; |
363 EXPECT(ResolveUri("ref/path", "bscheme:base", &target_uri)); | 334 EXPECT(ResolveUri("ref/path", "bscheme:base", &target_uri)); |
364 EXPECT_STREQ("bscheme:ref/path", target_uri); | 335 EXPECT_STREQ("bscheme:ref/path", target_uri); |
365 } | 336 } |
366 | 337 |
367 | |
368 TEST_CASE(ResolveUri_NoSchemeNoAuthority_EmptyPath) { | 338 TEST_CASE(ResolveUri_NoSchemeNoAuthority_EmptyPath) { |
369 const char* target_uri; | 339 const char* target_uri; |
370 EXPECT(ResolveUri("", | 340 EXPECT(ResolveUri("", |
371 "bscheme://buser@bhost:11/base/path?baseQuery#bfragment", | 341 "bscheme://buser@bhost:11/base/path?baseQuery#bfragment", |
372 &target_uri)); | 342 &target_uri)); |
373 // Note that we drop the base fragment from the resolved uri. | 343 // Note that we drop the base fragment from the resolved uri. |
374 EXPECT_STREQ("bscheme://buser@bhost:11/base/path?baseQuery", target_uri); | 344 EXPECT_STREQ("bscheme://buser@bhost:11/base/path?baseQuery", target_uri); |
375 } | 345 } |
376 | 346 |
377 | |
378 TEST_CASE(ResolveUri_NoSchemeNoAuthority_EmptyPathWithQuery) { | 347 TEST_CASE(ResolveUri_NoSchemeNoAuthority_EmptyPathWithQuery) { |
379 const char* target_uri; | 348 const char* target_uri; |
380 EXPECT(ResolveUri("?refQuery", | 349 EXPECT(ResolveUri("?refQuery", |
381 "bscheme://buser@bhost:11/base/path?baseQuery#bfragment", | 350 "bscheme://buser@bhost:11/base/path?baseQuery#bfragment", |
382 &target_uri)); | 351 &target_uri)); |
383 EXPECT_STREQ("bscheme://buser@bhost:11/base/path?refQuery", target_uri); | 352 EXPECT_STREQ("bscheme://buser@bhost:11/base/path?refQuery", target_uri); |
384 } | 353 } |
385 | 354 |
386 | |
387 TEST_CASE(ResolveUri_NoSchemeNoAuthority_EmptyPathWithFragment) { | 355 TEST_CASE(ResolveUri_NoSchemeNoAuthority_EmptyPathWithFragment) { |
388 const char* target_uri; | 356 const char* target_uri; |
389 EXPECT(ResolveUri("#rfragment", | 357 EXPECT(ResolveUri("#rfragment", |
390 "bscheme://buser@bhost:11/base/path?baseQuery#bfragment", | 358 "bscheme://buser@bhost:11/base/path?baseQuery#bfragment", |
391 &target_uri)); | 359 &target_uri)); |
392 EXPECT_STREQ("bscheme://buser@bhost:11/base/path?baseQuery#rfragment", | 360 EXPECT_STREQ("bscheme://buser@bhost:11/base/path?baseQuery#rfragment", |
393 target_uri); | 361 target_uri); |
394 } | 362 } |
395 | 363 |
396 | |
397 TEST_CASE(ResolveUri_RemoveDots_RemoveOneDotSegment) { | 364 TEST_CASE(ResolveUri_RemoveDots_RemoveOneDotSegment) { |
398 const char* target_uri; | 365 const char* target_uri; |
399 EXPECT(ResolveUri("./refpath", "scheme://auth/a/b/c/d", &target_uri)); | 366 EXPECT(ResolveUri("./refpath", "scheme://auth/a/b/c/d", &target_uri)); |
400 EXPECT_STREQ("scheme://auth/a/b/c/refpath", target_uri); | 367 EXPECT_STREQ("scheme://auth/a/b/c/refpath", target_uri); |
401 } | 368 } |
402 | 369 |
403 | |
404 TEST_CASE(ResolveUri_RemoveDots_RemoveTwoDotSegments) { | 370 TEST_CASE(ResolveUri_RemoveDots_RemoveTwoDotSegments) { |
405 const char* target_uri; | 371 const char* target_uri; |
406 EXPECT(ResolveUri("././refpath", "scheme://auth/a/b/c/d", &target_uri)); | 372 EXPECT(ResolveUri("././refpath", "scheme://auth/a/b/c/d", &target_uri)); |
407 EXPECT_STREQ("scheme://auth/a/b/c/refpath", target_uri); | 373 EXPECT_STREQ("scheme://auth/a/b/c/refpath", target_uri); |
408 } | 374 } |
409 | 375 |
410 | |
411 TEST_CASE(ResolveUri_RemoveDots_RemoveOneDotDotSegment) { | 376 TEST_CASE(ResolveUri_RemoveDots_RemoveOneDotDotSegment) { |
412 const char* target_uri; | 377 const char* target_uri; |
413 EXPECT(ResolveUri("../refpath", "scheme://auth/a/b/c/d", &target_uri)); | 378 EXPECT(ResolveUri("../refpath", "scheme://auth/a/b/c/d", &target_uri)); |
414 EXPECT_STREQ("scheme://auth/a/b/refpath", target_uri); | 379 EXPECT_STREQ("scheme://auth/a/b/refpath", target_uri); |
415 } | 380 } |
416 | 381 |
417 | |
418 TEST_CASE(ResolveUri_RemoveDots_RemoveTwoDotDotSegments) { | 382 TEST_CASE(ResolveUri_RemoveDots_RemoveTwoDotDotSegments) { |
419 const char* target_uri; | 383 const char* target_uri; |
420 EXPECT(ResolveUri("../../refpath", "scheme://auth/a/b/c/d", &target_uri)); | 384 EXPECT(ResolveUri("../../refpath", "scheme://auth/a/b/c/d", &target_uri)); |
421 EXPECT_STREQ("scheme://auth/a/refpath", target_uri); | 385 EXPECT_STREQ("scheme://auth/a/refpath", target_uri); |
422 } | 386 } |
423 | 387 |
424 | |
425 TEST_CASE(ResolveUri_RemoveDots_RemoveTooManyDotDotSegments) { | 388 TEST_CASE(ResolveUri_RemoveDots_RemoveTooManyDotDotSegments) { |
426 const char* target_uri; | 389 const char* target_uri; |
427 EXPECT(ResolveUri("../../../../../../../../../refpath", | 390 EXPECT(ResolveUri("../../../../../../../../../refpath", |
428 "scheme://auth/a/b/c/d", &target_uri)); | 391 "scheme://auth/a/b/c/d", &target_uri)); |
429 EXPECT_STREQ("scheme://auth/refpath", target_uri); | 392 EXPECT_STREQ("scheme://auth/refpath", target_uri); |
430 } | 393 } |
431 | 394 |
432 | |
433 TEST_CASE(ResolveUri_RemoveDots_RemoveDotSegmentsNothingLeft1) { | 395 TEST_CASE(ResolveUri_RemoveDots_RemoveDotSegmentsNothingLeft1) { |
434 const char* target_uri; | 396 const char* target_uri; |
435 EXPECT(ResolveUri("../../../../..", "scheme://auth/a/b/c/d", &target_uri)); | 397 EXPECT(ResolveUri("../../../../..", "scheme://auth/a/b/c/d", &target_uri)); |
436 EXPECT_STREQ("scheme://auth/", target_uri); | 398 EXPECT_STREQ("scheme://auth/", target_uri); |
437 } | 399 } |
438 | 400 |
439 | |
440 TEST_CASE(ResolveUri_RemoveDots_RemoveDotSegmentsNothingLeft2) { | 401 TEST_CASE(ResolveUri_RemoveDots_RemoveDotSegmentsNothingLeft2) { |
441 const char* target_uri; | 402 const char* target_uri; |
442 EXPECT(ResolveUri(".", "scheme://auth/", &target_uri)); | 403 EXPECT(ResolveUri(".", "scheme://auth/", &target_uri)); |
443 EXPECT_STREQ("scheme://auth/", target_uri); | 404 EXPECT_STREQ("scheme://auth/", target_uri); |
444 } | 405 } |
445 | 406 |
446 | |
447 TEST_CASE(ResolveUri_RemoveDots_RemoveDotSegmentsInitialPrefix) { | 407 TEST_CASE(ResolveUri_RemoveDots_RemoveDotSegmentsInitialPrefix) { |
448 const char* target_uri; | 408 const char* target_uri; |
449 EXPECT(ResolveUri("../../../../refpath", "scheme://auth", &target_uri)); | 409 EXPECT(ResolveUri("../../../../refpath", "scheme://auth", &target_uri)); |
450 EXPECT_STREQ("scheme://auth/refpath", target_uri); | 410 EXPECT_STREQ("scheme://auth/refpath", target_uri); |
451 } | 411 } |
452 | 412 |
453 | |
454 TEST_CASE(ResolveUri_RemoveDots_RemoveDotSegmentsMixed) { | 413 TEST_CASE(ResolveUri_RemoveDots_RemoveDotSegmentsMixed) { |
455 const char* target_uri; | 414 const char* target_uri; |
456 EXPECT(ResolveUri("../../1/./2/../3/4/../5/././6/../7", | 415 EXPECT(ResolveUri("../../1/./2/../3/4/../5/././6/../7", |
457 "scheme://auth/a/b/c/d/e", &target_uri)); | 416 "scheme://auth/a/b/c/d/e", &target_uri)); |
458 EXPECT_STREQ("scheme://auth/a/b/1/3/5/7", target_uri); | 417 EXPECT_STREQ("scheme://auth/a/b/1/3/5/7", target_uri); |
459 } | 418 } |
460 | 419 |
461 | |
462 TEST_CASE(ResolveUri_NormalizeEscapes_PathQueryFragment) { | 420 TEST_CASE(ResolveUri_NormalizeEscapes_PathQueryFragment) { |
463 const char* target_uri; | 421 const char* target_uri; |
464 EXPECT(ResolveUri("#A Fr%61gment", | 422 EXPECT(ResolveUri("#A Fr%61gment", |
465 "scheme:/This%09Is A P%61th?This%09Is A Qu%65ry", | 423 "scheme:/This%09Is A P%61th?This%09Is A Qu%65ry", |
466 &target_uri)); | 424 &target_uri)); |
467 EXPECT_STREQ( | 425 EXPECT_STREQ( |
468 "scheme:/This%09Is%20A%20Path?This%09Is%20A%20Query#A%20Fragment", | 426 "scheme:/This%09Is%20A%20Path?This%09Is%20A%20Query#A%20Fragment", |
469 target_uri); | 427 target_uri); |
470 } | 428 } |
471 | 429 |
472 | |
473 TEST_CASE(ResolveUri_NormalizeEscapes_UppercaseHexPreferred) { | 430 TEST_CASE(ResolveUri_NormalizeEscapes_UppercaseHexPreferred) { |
474 const char* target_uri; | 431 const char* target_uri; |
475 EXPECT(ResolveUri("", "scheme:/%1b%1B", &target_uri)); | 432 EXPECT(ResolveUri("", "scheme:/%1b%1B", &target_uri)); |
476 EXPECT_STREQ("scheme:/%1B%1B", target_uri); | 433 EXPECT_STREQ("scheme:/%1B%1B", target_uri); |
477 } | 434 } |
478 | 435 |
479 | |
480 TEST_CASE(ResolveUri_NormalizeEscapes_Authority) { | 436 TEST_CASE(ResolveUri_NormalizeEscapes_Authority) { |
481 const char* target_uri; | 437 const char* target_uri; |
482 EXPECT( | 438 EXPECT( |
483 ResolveUri("", "scheme://UsEr N%61%4de@h%4FsT.c%6fm:80/", &target_uri)); | 439 ResolveUri("", "scheme://UsEr N%61%4de@h%4FsT.c%6fm:80/", &target_uri)); |
484 // userinfo is normalized and case is preserved. host is normalized | 440 // userinfo is normalized and case is preserved. host is normalized |
485 // and lower-cased. | 441 // and lower-cased. |
486 EXPECT_STREQ("scheme://UsEr%20NaMe@host.com:80/", target_uri); | 442 EXPECT_STREQ("scheme://UsEr%20NaMe@host.com:80/", target_uri); |
487 } | 443 } |
488 | 444 |
489 | |
490 TEST_CASE(ResolveUri_NormalizeEscapes_BrokenEscapeSequence) { | 445 TEST_CASE(ResolveUri_NormalizeEscapes_BrokenEscapeSequence) { |
491 const char* target_uri; | 446 const char* target_uri; |
492 EXPECT(ResolveUri("", "scheme:/%1g", &target_uri)); | 447 EXPECT(ResolveUri("", "scheme:/%1g", &target_uri)); |
493 // We don't change broken escape sequences. | 448 // We don't change broken escape sequences. |
494 EXPECT_STREQ("scheme:/%1g", target_uri); | 449 EXPECT_STREQ("scheme:/%1g", target_uri); |
495 } | 450 } |
496 | 451 |
497 | |
498 TEST_CASE(ResolveUri_DataUri) { | 452 TEST_CASE(ResolveUri_DataUri) { |
499 const char* data_uri = | 453 const char* data_uri = |
500 "data:application/" | 454 "data:application/" |
501 "dart;charset=utf-8,%20%20%20%20%20%20%20%20import%20%22dart:isolate%22;%" | 455 "dart;charset=utf-8,%20%20%20%20%20%20%20%20import%20%22dart:isolate%22;%" |
502 "0A%0A%20%20%20%20%20%20%20%20import%20%22package:stream_channel/" | 456 "0A%0A%20%20%20%20%20%20%20%20import%20%22package:stream_channel/" |
503 "stream_channel.dart%22;%0A%0A%20%20%20%20%20%20%20%20import%20%" | 457 "stream_channel.dart%22;%0A%0A%20%20%20%20%20%20%20%20import%20%" |
504 "22package:test/src/runner/plugin/" | 458 "22package:test/src/runner/plugin/" |
505 "remote_platform_helpers.dart%22;%0A%20%20%20%20%20%20%20%20import%20%" | 459 "remote_platform_helpers.dart%22;%0A%20%20%20%20%20%20%20%20import%20%" |
506 "22package:test/src/runner/vm/" | 460 "22package:test/src/runner/vm/" |
507 "catch_isolate_errors.dart%22;%0A%0A%20%20%20%20%20%20%20%20import%20%" | 461 "catch_isolate_errors.dart%22;%0A%0A%20%20%20%20%20%20%20%20import%20%" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 EXPECT(!ResolveUri("../../../r1", "b1/b2", &target_uri)); | 495 EXPECT(!ResolveUri("../../../r1", "b1/b2", &target_uri)); |
542 EXPECT(target_uri == NULL); | 496 EXPECT(target_uri == NULL); |
543 | 497 |
544 EXPECT(!ResolveUri("../r1", "../../b1/b2/b3", &target_uri)); | 498 EXPECT(!ResolveUri("../r1", "../../b1/b2/b3", &target_uri)); |
545 EXPECT(target_uri == NULL); | 499 EXPECT(target_uri == NULL); |
546 | 500 |
547 EXPECT(!ResolveUri("../../../r1", "../../b1/b2/b3", &target_uri)); | 501 EXPECT(!ResolveUri("../../../r1", "../../b1/b2/b3", &target_uri)); |
548 EXPECT(target_uri == NULL); | 502 EXPECT(target_uri == NULL); |
549 } | 503 } |
550 | 504 |
551 | |
552 static const char* TestResolve(const char* base_uri, const char* uri) { | 505 static const char* TestResolve(const char* base_uri, const char* uri) { |
553 const char* target_uri; | 506 const char* target_uri; |
554 EXPECT(ResolveUri(uri, base_uri, &target_uri)); | 507 EXPECT(ResolveUri(uri, base_uri, &target_uri)); |
555 return target_uri; | 508 return target_uri; |
556 } | 509 } |
557 | 510 |
558 | |
559 // This test is ported from sdk/tests/corelib/uri_test.dart (testUriPerRFCs). | 511 // This test is ported from sdk/tests/corelib/uri_test.dart (testUriPerRFCs). |
560 TEST_CASE(ResolveUri_TestUriPerRFCs) { | 512 TEST_CASE(ResolveUri_TestUriPerRFCs) { |
561 const char* base = "http://a/b/c/d;p?q"; | 513 const char* base = "http://a/b/c/d;p?q"; |
562 | 514 |
563 // From RFC 3986 | 515 // From RFC 3986 |
564 EXPECT_STREQ("g:h", TestResolve(base, "g:h")); | 516 EXPECT_STREQ("g:h", TestResolve(base, "g:h")); |
565 EXPECT_STREQ("http://a/b/c/g", TestResolve(base, "g")); | 517 EXPECT_STREQ("http://a/b/c/g", TestResolve(base, "g")); |
566 EXPECT_STREQ("http://a/b/c/g", TestResolve(base, "./g")); | 518 EXPECT_STREQ("http://a/b/c/g", TestResolve(base, "./g")); |
567 EXPECT_STREQ("http://a/b/c/g/", TestResolve(base, "g/")); | 519 EXPECT_STREQ("http://a/b/c/g/", TestResolve(base, "g/")); |
568 EXPECT_STREQ("http://a/g", TestResolve(base, "/g")); | 520 EXPECT_STREQ("http://a/g", TestResolve(base, "/g")); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 EXPECT_STREQ("http://a/b/c/g#s/../x", TestResolve(base, "g#s/../x")); | 556 EXPECT_STREQ("http://a/b/c/g#s/../x", TestResolve(base, "g#s/../x")); |
605 EXPECT_STREQ("http:g", TestResolve(base, "http:g")); | 557 EXPECT_STREQ("http:g", TestResolve(base, "http:g")); |
606 | 558 |
607 // Additional tests (not from RFC 3986). | 559 // Additional tests (not from RFC 3986). |
608 EXPECT_STREQ("http://a/b/g;p/h;s", TestResolve(base, "../g;p/h;s")); | 560 EXPECT_STREQ("http://a/b/g;p/h;s", TestResolve(base, "../g;p/h;s")); |
609 | 561 |
610 base = "s:a/b"; | 562 base = "s:a/b"; |
611 EXPECT_STREQ("s:/c", TestResolve(base, "../c")); | 563 EXPECT_STREQ("s:/c", TestResolve(base, "../c")); |
612 } | 564 } |
613 | 565 |
614 | |
615 // This test is ported from sdk/tests/corelib/uri_test.dart (testResolvePath). | 566 // This test is ported from sdk/tests/corelib/uri_test.dart (testResolvePath). |
616 TEST_CASE(ResolveUri_MoreDotSegmentTests) { | 567 TEST_CASE(ResolveUri_MoreDotSegmentTests) { |
617 const char* base = "/"; | 568 const char* base = "/"; |
618 EXPECT_STREQ("/a/g", TestResolve(base, "/a/b/c/./../../g")); | 569 EXPECT_STREQ("/a/g", TestResolve(base, "/a/b/c/./../../g")); |
619 EXPECT_STREQ("/a/g", TestResolve(base, "/a/b/c/./../../g")); | 570 EXPECT_STREQ("/a/g", TestResolve(base, "/a/b/c/./../../g")); |
620 EXPECT_STREQ("/mid/6", TestResolve(base, "mid/content=5/../6")); | 571 EXPECT_STREQ("/mid/6", TestResolve(base, "mid/content=5/../6")); |
621 EXPECT_STREQ("/a/b/e", TestResolve(base, "a/b/c/d/../../e")); | 572 EXPECT_STREQ("/a/b/e", TestResolve(base, "a/b/c/d/../../e")); |
622 EXPECT_STREQ("/a/b/e", TestResolve(base, "../a/b/c/d/../../e")); | 573 EXPECT_STREQ("/a/b/e", TestResolve(base, "../a/b/c/d/../../e")); |
623 EXPECT_STREQ("/a/b/e", TestResolve(base, "./a/b/c/d/../../e")); | 574 EXPECT_STREQ("/a/b/e", TestResolve(base, "./a/b/c/d/../../e")); |
624 EXPECT_STREQ("/a/b/e", TestResolve(base, "../a/b/./c/d/../../e")); | 575 EXPECT_STREQ("/a/b/e", TestResolve(base, "../a/b/./c/d/../../e")); |
(...skipping 12 matching lines...) Expand all Loading... |
637 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "./a/b/c/d/../../e")); | 588 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "./a/b/c/d/../../e")); |
638 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "../a/b/./c/d/../../e")); | 589 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "../a/b/./c/d/../../e")); |
639 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "./a/b/./c/d/../../e")); | 590 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "./a/b/./c/d/../../e")); |
640 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/.")); | 591 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/.")); |
641 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/./.")); | 592 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/./.")); |
642 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/././.")); | 593 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/././.")); |
643 #undef LH | 594 #undef LH |
644 } | 595 } |
645 | 596 |
646 } // namespace dart | 597 } // namespace dart |
OLD | NEW |