Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: tests/corelib/uri_test.dart

Issue 2220373002: Reapply fast-URI patch. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix bug in SimpleUri.replace where ? was included in the result's query. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/corelib/data_uri_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library uriTest; 5 library uriTest;
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 import 'dart:convert'; 8 import 'dart:convert';
9 9
10 testUri(String uriText, bool isAbsolute) { 10 testUri(String uriText, bool isAbsolute) {
11 var uri = Uri.parse(uriText); 11 var uri = Uri.parse(uriText);
12 12
13 // Test that parsing a substring works the same as parsing the string.
14 String wrapper = "://@[]:/%?#";
15 var embeddedUri = Uri.parse(
16 "$wrapper$uri$wrapper", wrapper.length, uriText.length + wrapper.length);
17
18 Expect.equals(uri, embeddedUri);
13 Expect.equals(isAbsolute, uri.isAbsolute); 19 Expect.equals(isAbsolute, uri.isAbsolute);
14 Expect.stringEquals(uriText, uri.toString()); 20 Expect.stringEquals(uriText, uri.toString());
15 21
16 // Test equals and hashCode members. 22 // Test equals and hashCode members.
17 var uri2 = Uri.parse(uriText); 23 var uri2 = Uri.parse(uriText);
18 Expect.equals(uri, uri2); 24 Expect.equals(uri, uri2);
19 Expect.equals(uri.hashCode, uri2.hashCode); 25 Expect.equals(uri.hashCode, uri2.hashCode);
20 26
21 // Test that removeFragment doesn't change anything else. 27 // Test that removeFragment doesn't change anything else.
22 if (uri.hasFragment) { 28 if (uri.hasFragment) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } else { 81 } else {
76 Expect.throws(() => Uri.encodeQueryComponent(orig, encoding: ASCII), 82 Expect.throws(() => Uri.encodeQueryComponent(orig, encoding: ASCII),
77 (e) => e is ArgumentError); 83 (e) => e is ArgumentError);
78 } 84 }
79 } 85 }
80 86
81 testUriPerRFCs() { 87 testUriPerRFCs() {
82 final urisSample = "http://a/b/c/d;p?q"; 88 final urisSample = "http://a/b/c/d;p?q";
83 Uri base = Uri.parse(urisSample); 89 Uri base = Uri.parse(urisSample);
84 testResolve(expect, relative) { 90 testResolve(expect, relative) {
85 Expect.stringEquals(expect, base.resolve(relative).toString()); 91 String name = "$base << $relative";
92 Expect.stringEquals(expect, base.resolve(relative).toString(), name);
86 } 93 }
87 94
88 // From RFC 3986. 95 // From RFC 3986.
89 testResolve("g:h", "g:h"); 96 testResolve("g:h", "g:h");
90 testResolve("http://a/b/c/g", "g"); 97 testResolve("http://a/b/c/g", "g");
91 testResolve("http://a/b/c/g", "./g"); 98 testResolve("http://a/b/c/g", "./g");
92 testResolve("http://a/b/c/g/", "g/"); 99 testResolve("http://a/b/c/g/", "g/");
93 testResolve("http://a/g", "/g"); 100 testResolve("http://a/g", "/g");
94 testResolve("http://g", "//g"); 101 testResolve("http://g", "//g");
95 testResolve("http://a/b/c/d;p?y", "?y"); 102 testResolve("http://a/b/c/d;p?y", "?y");
(...skipping 29 matching lines...) Expand all
125 testResolve("http://a/b/c/y", "g;x=1/../y"); 132 testResolve("http://a/b/c/y", "g;x=1/../y");
126 testResolve("http://a/b/c/g?y/./x", "g?y/./x"); 133 testResolve("http://a/b/c/g?y/./x", "g?y/./x");
127 testResolve("http://a/b/c/g?y/../x", "g?y/../x"); 134 testResolve("http://a/b/c/g?y/../x", "g?y/../x");
128 testResolve("http://a/b/c/g#s/./x", "g#s/./x"); 135 testResolve("http://a/b/c/g#s/./x", "g#s/./x");
129 testResolve("http://a/b/c/g#s/../x", "g#s/../x"); 136 testResolve("http://a/b/c/g#s/../x", "g#s/../x");
130 testResolve("http:g", "http:g"); 137 testResolve("http:g", "http:g");
131 138
132 // Additional tests (not from RFC 3986). 139 // Additional tests (not from RFC 3986).
133 testResolve("http://a/b/g;p/h;s", "../g;p/h;s"); 140 testResolve("http://a/b/g;p/h;s", "../g;p/h;s");
134 141
142 base = Uri.parse("s:a/b");
143 testResolve("s:a/c", "c");
144 testResolve("s:/c", "../c");
145
146 base = Uri.parse("S:a/b");
147 testResolve("s:a/c", "c");
148 testResolve("s:/c", "../c");
149
150 base = Uri.parse("s:foo");
151 testResolve("s:bar", "bar");
152 testResolve("s:bar", "../bar");
153
154 base = Uri.parse("S:foo");
155 testResolve("s:bar", "bar");
156 testResolve("s:bar", "../bar");
157
158 // Special-case (deliberate non-RFC behavior).
159 base = Uri.parse("foo/bar");
160 testResolve("foo/baz", "baz");
161 testResolve("baz", "../baz");
162
163 base = Uri.parse("s:/foo");
164 testResolve("s:/bar", "bar");
165 testResolve("s:/bar", "../bar");
166
167 base = Uri.parse("S:/foo");
168 testResolve("s:/bar", "bar");
169 testResolve("s:/bar", "../bar");
170
135 // Test non-URI base (no scheme, no authority, relative path). 171 // Test non-URI base (no scheme, no authority, relative path).
136 base = Uri.parse("a/b/c?_#_"); 172 base = Uri.parse("a/b/c?_#_");
137 testResolve("a/b/g?q#f", "g?q#f"); 173 testResolve("a/b/g?q#f", "g?q#f");
138 testResolve("./", "../.."); 174 testResolve("./", "../..");
139 testResolve("../", "../../.."); 175 testResolve("../", "../../..");
140 testResolve("a/b/", "."); 176 testResolve("a/b/", ".");
141 testResolve("c", "../../c"); 177 testResolve("c", "../../c"); // Deliberate non-RFC behavior.
142 base = Uri.parse("../../a/b/c?_#_"); // Initial ".." in base url. 178 base = Uri.parse("../../a/b/c?_#_"); // Initial ".." in base url.
143 testResolve("../../a/d", "../d"); 179 testResolve("../../a/d", "../d");
144 testResolve("../../../d", "../../../d"); 180 testResolve("../../../d", "../../../d");
145 181
146 base = Uri.parse("s:a/b"); 182 base = Uri.parse("s://h/p?q#f"); // A simple base.
147 testResolve("s:/c", "../c"); 183 // Simple references:
184 testResolve("s2://h2/P?Q#F", "s2://h2/P?Q#F");
185 testResolve("s://h2/P?Q#F", "//h2/P?Q#F");
186 testResolve("s://h/P?Q#F", "/P?Q#F");
187 testResolve("s://h/p?Q#F", "?Q#F");
188 testResolve("s://h/p?q#F", "#F");
189 testResolve("s://h/p?q", "");
190 // Non-simple references:
191 testResolve("s2://I@h2/P?Q#F%20", "s2://I@h2/P?Q#F%20");
192 testResolve("s://I@h2/P?Q#F%20", "//I@h2/P?Q#F%20");
193 testResolve("s://h2/P?Q#F%20", "//h2/P?Q#F%20");
194 testResolve("s://h/P?Q#F%20", "/P?Q#F%20");
195 testResolve("s://h/p?Q#F%20", "?Q#F%20");
196 testResolve("s://h/p?q#F%20", "#F%20");
197
198 base = Uri.parse("s://h/p1/p2/p3"); // A simple base with a path.
199 testResolve("s://h/p1/p2/", ".");
200 testResolve("s://h/p1/p2/", "./");
201 testResolve("s://h/p1/", "..");
202 testResolve("s://h/p1/", "../");
203 testResolve("s://h/", "../..");
204 testResolve("s://h/", "../../");
205 testResolve("s://h/p1/%20", "../%20");
206 testResolve("s://h/", "../../../..");
207 testResolve("s://h/", "../../../../");
208
209 base = Uri.parse("s://h/p?q#f%20"); // A non-simpe base.
210 // Simple references:
211 testResolve("s2://h2/P?Q#F", "s2://h2/P?Q#F");
212 testResolve("s://h2/P?Q#F", "//h2/P?Q#F");
213 testResolve("s://h/P?Q#F", "/P?Q#F");
214 testResolve("s://h/p?Q#F", "?Q#F");
215 testResolve("s://h/p?q#F", "#F");
216 testResolve("s://h/p?q", "");
217 // Non-simple references:
218 testResolve("s2://I@h2/P?Q#F%20", "s2://I@h2/P?Q#F%20");
219 testResolve("s://I@h2/P?Q#F%20", "//I@h2/P?Q#F%20");
220 testResolve("s://h2/P?Q#F%20", "//h2/P?Q#F%20");
221 testResolve("s://h/P?Q#F%20", "/P?Q#F%20");
222 testResolve("s://h/p?Q#F%20", "?Q#F%20");
223 testResolve("s://h/p?q#F%20", "#F%20");
224
225 base = Uri.parse("S://h/p1/p2/p3"); // A non-simple base with a path.
226 testResolve("s://h/p1/p2/", ".");
227 testResolve("s://h/p1/p2/", "./");
228 testResolve("s://h/p1/", "..");
229 testResolve("s://h/p1/", "../");
230 testResolve("s://h/", "../..");
231 testResolve("s://h/", "../../");
232 testResolve("s://h/p1/%20", "../%20");
233 testResolve("s://h/", "../../../..");
234 testResolve("s://h/", "../../../../");
235
236 base = Uri.parse("../../../"); // A simple relative path.
237 testResolve("../../../a", "a");
238 testResolve("../../../../a", "../a");
239 testResolve("../../../a%20", "a%20");
240 testResolve("../../../../a%20", "../a%20");
241
242 // Tests covering the branches of the merge algorithm in RFC 3986
243 // with both simple and complex base URIs.
244 for (var b in ["s://a/pa/pb?q#f", "s://a/pa/pb?q#f%20"]) {
245 var origBase = Uri.parse(b);
246 base = origBase;
247
248 // if defined(R.scheme) then ...
249 testResolve("s2://a2/p2?q2#f2", "s2://a2/p2?q2#f2");
250 // else, if defined(R.authority) then ...
251 testResolve("s://a2/p2?q2#f2", "//a2/p2?q2#f2");
252 testResolve("s://a2/?q2#f2", "//a2/../?q2#f2");
253 testResolve("s://a2?q2#f2", "//a2?q2#f2");
254 testResolve("s://a2#f2", "//a2#f2");
255 testResolve("s://a2", "//a2");
256 // else, if (R.path == "") then ...
257 // if defined(R.query) then
258 testResolve("s://a/pa/pb?q2#f2", "?q2#f2");
259 testResolve("s://a/pa/pb?q2", "?q2");
260 // else
261 testResolve("s://a/pa/pb?q#f2", "#f2");
262 testResolve("s://a/pa/pb?q", "");
263 // else, if (R.path starts-with "/") then ...
264 testResolve("s://a/p2?q2#f2", "/p2?q2#f2");
265 testResolve("s://a/?q2#f2", "/?q2#f2");
266 testResolve("s://a/#f2", "/#f2");
267 testResolve("s://a/", "/");
268 testResolve("s://a/", "/../");
269 // else ... T.path = merge(Base.path, R.path)
270 // ... remove-dot-fragments(T.path) ...
271 // (Cover the merge function and the remove-dot-fragments functions too).
272
273 // If base has authority and empty path ...
274 var emptyPathBase = Uri.parse(b.replaceFirst("/pa/pb", ""));
275 base = emptyPathBase;
276 testResolve("s://a/p2?q2#f2", "p2?q2#f2");
277 testResolve("s://a/p2#f2", "p2#f2");
278 testResolve("s://a/p2", "p2");
279
280 base = origBase;
281 // otherwise
282 // (Cover both no authority and non-empty path and both).
283 var noAuthEmptyPathBase = Uri.parse(b.replaceFirst("//a/pa/pb", ""));
284 var noAuthAbsPathBase = Uri.parse(b.replaceFirst("//a", ""));
285 var noAuthRelPathBase = Uri.parse(b.replaceFirst("//a/", ""));
286 var noAuthRelSinglePathBase = Uri.parse(b.replaceFirst("//a/pa/", ""));
287
288 testResolve("s://a/pa/p2?q2#f2", "p2?q2#f2");
289 testResolve("s://a/pa/p2#f2", "p2#f2");
290 testResolve("s://a/pa/p2", "p2");
291
292 base = noAuthEmptyPathBase;
293 testResolve("s:p2?q2#f2", "p2?q2#f2");
294 testResolve("s:p2#f2", "p2#f2");
295 testResolve("s:p2", "p2");
296
297 base = noAuthAbsPathBase;
298 testResolve("s:/pa/p2?q2#f2", "p2?q2#f2");
299 testResolve("s:/pa/p2#f2", "p2#f2");
300 testResolve("s:/pa/p2", "p2");
301
302 base = noAuthRelPathBase;
303 testResolve("s:pa/p2?q2#f2", "p2?q2#f2");
304 testResolve("s:pa/p2#f2", "p2#f2");
305 testResolve("s:pa/p2", "p2");
306
307 base = noAuthRelSinglePathBase;
308 testResolve("s:p2?q2#f2", "p2?q2#f2");
309 testResolve("s:p2#f2", "p2#f2");
310 testResolve("s:p2", "p2");
311
312 // Then remove dot segments.
313
314 // A. if input buffer starts with "../" or "./".
315 // This only happens if base has only a single (may be empty) segment and
316 // no slash.
317 base = emptyPathBase;
318 testResolve("s://a/p2", "../p2");
319 testResolve("s://a/", "../");
320 testResolve("s://a/", "..");
321 testResolve("s://a/p2", "./p2");
322 testResolve("s://a/", "./");
323 testResolve("s://a/", ".");
324 testResolve("s://a/p2", "../../p2");
325 testResolve("s://a/p2", "../../././p2");
326
327 base = noAuthRelSinglePathBase;
328 testResolve("s:p2", "../p2");
329 testResolve("s:", "../");
330 testResolve("s:", "..");
331 testResolve("s:p2", "./p2");
332 testResolve("s:", "./");
333 testResolve("s:", ".");
334 testResolve("s:p2", "../../p2");
335 testResolve("s:p2", "../../././p2");
336
337 // B. if input buffer starts with "/./" or is "/.". replace with "/".
338 // (The URI implementation removes the "." path segments when parsing,
339 // so this case isn't handled by merge).
340 base = origBase;
341 testResolve("s://a/pa/p2", "./p2");
342
343 // C. if input buffer starts with "/../" or is "/..", replace with "/"
344 // and remove preceeding segment.
345 testResolve("s://a/p2", "../p2");
346 var longPathBase = Uri.parse(b.replaceFirst("/pb", "/pb/pc/pd"));
347 base = longPathBase;
348 testResolve("s://a/pa/pb/p2", "../p2");
349 testResolve("s://a/pa/p2", "../../p2");
350 testResolve("s://a/p2", "../../../p2");
351 testResolve("s://a/p2", "../../../../p2");
352 var noAuthRelLongPathBase =
353 Uri.parse(b.replaceFirst("//a/pa/pb", "pa/pb/pc/pd"));
354 base = noAuthRelLongPathBase;
355 testResolve("s:pa/pb/p2", "../p2");
356 testResolve("s:pa/p2", "../../p2");
357 testResolve("s:/p2", "../../../p2");
358 testResolve("s:/p2", "../../../../p2");
359
360 // D. if the input buffer contains only ".." or ".", remove it.
361 base = noAuthEmptyPathBase;
362 testResolve("s:", "..");
363 testResolve("s:", ".");
364 base = noAuthRelSinglePathBase;
365 testResolve("s:", "..");
366 testResolve("s:", ".");
367 }
148 } 368 }
149 369
150 void testResolvePath(String expected, String path) { 370 void testResolvePath(String expected, String path) {
151 Expect.equals(expected, 371 Expect.equals(expected,
152 new Uri(path: '/').resolveUri(new Uri(path: path)).path); 372 new Uri(path: '/').resolveUri(new Uri(path: path)).path);
153 Expect.equals( 373 Expect.equals(
154 "http://localhost$expected", 374 "http://localhost$expected",
155 Uri.parse("http://localhost").resolveUri(new Uri(path: path)).toString()); 375 Uri.parse("http://localhost").resolveUri(new Uri(path: path)).toString());
156 } 376 }
157 377
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 var char = UNRESERVED[i]; 547 var char = UNRESERVED[i];
328 var escape = "%" + char.codeUnitAt(0).toRadixString(16); // all > 0xf. 548 var escape = "%" + char.codeUnitAt(0).toRadixString(16); // all > 0xf.
329 549
330 uri = Uri.parse("s://xX${escape}xX@yY${escape}yY/zZ${escape}zZ" 550 uri = Uri.parse("s://xX${escape}xX@yY${escape}yY/zZ${escape}zZ"
331 "?vV${escape}vV#wW${escape}wW"); 551 "?vV${escape}vV#wW${escape}wW");
332 Expect.equals("xX${char}xX", uri.userInfo); 552 Expect.equals("xX${char}xX", uri.userInfo);
333 Expect.equals("yY${char}yY".toLowerCase(), uri.host); 553 Expect.equals("yY${char}yY".toLowerCase(), uri.host);
334 Expect.equals("/zZ${char}zZ", uri.path); 554 Expect.equals("/zZ${char}zZ", uri.path);
335 Expect.equals("vV${char}vV", uri.query); 555 Expect.equals("vV${char}vV", uri.query);
336 Expect.equals("wW${char}wW", uri.fragment); 556 Expect.equals("wW${char}wW", uri.fragment);
557
558 uri = Uri.parse("s://yY${escape}yY/zZ${escape}zZ"
559 "?vV${escape}vV#wW${escape}wW");
560 Expect.equals("yY${char}yY".toLowerCase(), uri.host);
561 Expect.equals("/zZ${char}zZ", uri.path);
562 Expect.equals("vV${char}vV", uri.query);
563 Expect.equals("wW${char}wW", uri.fragment);
337 } 564 }
338 565
339 // Escapes of reserved characters are kept, but upper-cased. 566 // Escapes of reserved characters are kept, but upper-cased.
340 for (var escape in ["%00", "%1f", "%7F", "%fF"]) { 567 for (var escape in ["%00", "%1f", "%7F", "%fF"]) {
341 uri = Uri.parse("s://xX${escape}xX@yY${escape}yY/zZ${escape}zZ" 568 uri = Uri.parse("s://xX${escape}xX@yY${escape}yY/zZ${escape}zZ"
342 "?vV${escape}vV#wW${escape}wW"); 569 "?vV${escape}vV#wW${escape}wW");
343 var normalizedEscape = escape.toUpperCase(); 570 var normalizedEscape = escape.toUpperCase();
344 Expect.equals("xX${normalizedEscape}xX", uri.userInfo); 571 Expect.equals("xX${normalizedEscape}xX", uri.userInfo);
345 Expect.equals("yy${normalizedEscape}yy", uri.host); 572 Expect.equals("yy${normalizedEscape}yy", uri.host);
346 Expect.equals("/zZ${normalizedEscape}zZ", uri.path); 573 Expect.equals("/zZ${normalizedEscape}zZ", uri.path);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 Expect.equals("scheme:///?#", Uri.parse("scheme:///?#").toString()); 620 Expect.equals("scheme:///?#", Uri.parse("scheme:///?#").toString());
394 Expect.equals("scheme:///#", 621 Expect.equals("scheme:///#",
395 new Uri(scheme: "scheme", host: "", path: "/", 622 new Uri(scheme: "scheme", host: "", path: "/",
396 query: "", fragment: "").toString()); 623 query: "", fragment: "").toString());
397 } 624 }
398 625
399 void testReplace() { 626 void testReplace() {
400 var uris = [ 627 var uris = [
401 Uri.parse(""), 628 Uri.parse(""),
402 Uri.parse("a://@:/?#"), 629 Uri.parse("a://@:/?#"),
630 Uri.parse("a://:/?#"), // Parsed as simple URI.
403 Uri.parse("a://b@c:4/e/f?g#h"), 631 Uri.parse("a://b@c:4/e/f?g#h"),
632 Uri.parse("a://c:4/e/f?g#h"), // Parsed as simple URI.
633 Uri.parse("$SCHEMECHAR://$REGNAMECHAR:$DIGIT/$PCHAR/$PCHAR"
634 "?$QUERYCHAR#$QUERYCHAR"), // Parsed as simple URI.
404 Uri.parse("$SCHEMECHAR://$USERINFOCHAR@$REGNAMECHAR:$DIGIT/$PCHAR/$PCHAR" 635 Uri.parse("$SCHEMECHAR://$USERINFOCHAR@$REGNAMECHAR:$DIGIT/$PCHAR/$PCHAR"
405 "?$QUERYCHAR#$QUERYCHAR"), 636 "?$QUERYCHAR#$QUERYCHAR"),
406 ]; 637 ];
407 for (var uri1 in uris) { 638 for (var uri1 in uris) {
408 for (var uri2 in uris) { 639 for (var uri2 in uris) {
409 if (identical(uri1, uri2)) continue; 640 if (identical(uri1, uri2)) continue;
410 var scheme = uri1.scheme; 641 var scheme = uri1.scheme;
411 var userInfo = uri1.hasAuthority ? uri1.userInfo : ""; 642 var userInfo = uri1.hasAuthority ? uri1.userInfo : "";
412 var host = uri1.hasAuthority ? uri1.host : null; 643 var host = uri1.hasAuthority ? uri1.host : null;
413 var port = uri1.hasAuthority ? uri1.port : 0; 644 var port = uri1.hasAuthority ? uri1.port : 0;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 uri = uri.replace(fragment: "fragment"); 694 uri = uri.replace(fragment: "fragment");
464 Expect.isFalse(uri.hasAuthority); 695 Expect.isFalse(uri.hasAuthority);
465 696
466 uri = new Uri(scheme: "foo", path: "bar"); 697 uri = new Uri(scheme: "foo", path: "bar");
467 uri = uri.replace( 698 uri = uri.replace(
468 queryParameters: {"x": ["42", "37"], "y": ["43", "38"]}); 699 queryParameters: {"x": ["42", "37"], "y": ["43", "38"]});
469 var params = uri.queryParametersAll; 700 var params = uri.queryParametersAll;
470 Expect.equals(2, params.length); 701 Expect.equals(2, params.length);
471 Expect.listEquals(["42", "37"], params["x"]); 702 Expect.listEquals(["42", "37"], params["x"]);
472 Expect.listEquals(["43", "38"], params["y"]); 703 Expect.listEquals(["43", "38"], params["y"]);
704
705 // Test replacing with empty strings.
706 uri = Uri.parse("s://a:1/b/c?d#e");
707 Expect.equals("s://a:1/b/c?d#", uri.replace(fragment: "").toString());
708 Expect.equals("s://a:1/b/c?#e", uri.replace(query: "").toString());
709 Expect.equals("s://a:1?d#e", uri.replace(path: "").toString());
710 Expect.equals("s://:1/b/c?d#e", uri.replace(host: "").toString());
473 } 711 }
474 712
475 main() { 713 main() {
476 testUri("http:", true); 714 testUri("http:", true);
477 testUri("file:///", true); 715 testUri("file:///", true);
478 testUri("file", false); 716 testUri("file", false);
479 testUri("http://user@example.com:8080/fisk?query=89&hest=silas", true); 717 testUri("http://user@example.com:8080/fisk?query=89&hest=silas", true);
480 testUri("http://user@example.com:8080/fisk?query=89&hest=silas#fragment", 718 testUri("http://user@example.com:8080/fisk?query=89&hest=silas#fragment",
481 false); 719 false);
482 Expect.stringEquals("http://user@example.com/a/b/c?query#fragment", 720 Expect.stringEquals("http://user@example.com/a/b/c?query#fragment",
483 new Uri( 721 new Uri(
484 scheme: "http", 722 scheme: "http",
485 userInfo: "user", 723 userInfo: "user",
486 host: "example.com", 724 host: "example.com",
487 port: 80, 725 port: 80,
488 path: "/a/b/c", 726 path: "/a/b/c",
489 query: "query", 727 query: "query",
490 fragment: "fragment").toString()); 728 fragment: "fragment").toString());
491 Expect.stringEquals("/a/b/c/", 729 Expect.stringEquals("/a/b/c/",
492 new Uri( 730 new Uri(
493 scheme: null, 731 scheme: null,
494 userInfo: null, 732 userInfo: null,
495 host: null, 733 host: null,
496 port: 0, 734 port: 0,
497 path: "/a/b/c/", 735 path: "/a/b/c/",
498 query: null, 736 query: null,
499 fragment: null).toString()); 737 fragment: null).toString());
500 Expect.stringEquals("file:///", Uri.parse("file:").toString()); 738 Expect.stringEquals("file:///", Uri.parse("file:").toString());
739 Expect.stringEquals("file:///", Uri.parse("file:/").toString());
740 Expect.stringEquals("file:///", Uri.parse("file:").toString());
741 Expect.stringEquals("file:///foo", Uri.parse("file:foo").toString());
742 Expect.stringEquals("file:///foo", Uri.parse("file:/foo").toString());
743 Expect.stringEquals("file://foo/", Uri.parse("file://foo").toString());
501 744
502 testResolvePath("/a/g", "/a/b/c/./../../g"); 745 testResolvePath("/a/g", "/a/b/c/./../../g");
503 testResolvePath("/a/g", "/a/b/c/./../../g"); 746 testResolvePath("/a/g", "/a/b/c/./../../g");
504 testResolvePath("/mid/6", "mid/content=5/../6"); 747 testResolvePath("/mid/6", "mid/content=5/../6");
505 testResolvePath("/a/b/e", "a/b/c/d/../../e"); 748 testResolvePath("/a/b/e", "a/b/c/d/../../e");
506 testResolvePath("/a/b/e", "../a/b/c/d/../../e"); 749 testResolvePath("/a/b/e", "../a/b/c/d/../../e");
507 testResolvePath("/a/b/e", "./a/b/c/d/../../e"); 750 testResolvePath("/a/b/e", "./a/b/c/d/../../e");
508 testResolvePath("/a/b/e", "../a/b/./c/d/../../e"); 751 testResolvePath("/a/b/e", "../a/b/./c/d/../../e");
509 testResolvePath("/a/b/e", "./a/b/./c/d/../../e"); 752 testResolvePath("/a/b/e", "./a/b/./c/d/../../e");
510 testResolvePath("/a/b/e/", "./a/b/./c/d/../../e/."); 753 testResolvePath("/a/b/e/", "./a/b/./c/d/../../e/.");
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 String dump(Uri uri) { 881 String dump(Uri uri) {
639 return "URI: $uri\n" 882 return "URI: $uri\n"
640 " Scheme: ${uri.scheme} #${uri.scheme.length}\n" 883 " Scheme: ${uri.scheme} #${uri.scheme.length}\n"
641 " User-info: ${uri.userInfo} #${uri.userInfo.length}\n" 884 " User-info: ${uri.userInfo} #${uri.userInfo.length}\n"
642 " Host: ${uri.host} #${uri.host.length}\n" 885 " Host: ${uri.host} #${uri.host.length}\n"
643 " Port: ${uri.port}\n" 886 " Port: ${uri.port}\n"
644 " Path: ${uri.path} #${uri.path.length}\n" 887 " Path: ${uri.path} #${uri.path.length}\n"
645 " Query: ${uri.query} #${uri.query.length}\n" 888 " Query: ${uri.query} #${uri.query.length}\n"
646 " Fragment: ${uri.fragment} #${uri.fragment.length}\n"; 889 " Fragment: ${uri.fragment} #${uri.fragment.length}\n";
647 } 890 }
OLDNEW
« no previous file with comments | « tests/corelib/data_uri_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698