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

Unified Diff: tests/corelib/uri_test.dart

Issue 2086613003: Add fast-mode Uri class. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Tweak operator== Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« sdk/lib/core/uri.dart ('K') | « tests/corelib/data_uri_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/uri_test.dart
diff --git a/tests/corelib/uri_test.dart b/tests/corelib/uri_test.dart
index 30b62428a87e92fa0a1b2ed1d2883e53f5fabcab..86a0ab3dc379e5d011da6f82db7ad6bbd51b34fd 100644
--- a/tests/corelib/uri_test.dart
+++ b/tests/corelib/uri_test.dart
@@ -10,6 +10,12 @@ import 'dart:convert';
testUri(String uriText, bool isAbsolute) {
var uri = Uri.parse(uriText);
+ // Test that parsing a substring works the same as parsing the string.
+ String wrapper = "://@[]:/%?#";
+ var embeddedUri = Uri.parse(
+ "$wrapper$uri$wrapper", wrapper.length, uriText.length + wrapper.length);
+
+ Expect.equals(uri, embeddedUri);
Expect.equals(isAbsolute, uri.isAbsolute);
Expect.stringEquals(uriText, uri.toString());
@@ -127,19 +133,104 @@ testUriPerRFCs() {
// Additional tests (not from RFC 3986).
testResolve("http://a/b/g;p/h;s", "../g;p/h;s");
+ base = Uri.parse("s:a/b");
+ testResolve("s:a/c", "c");
+ testResolve("s:/c", "../c");
+
+ base = Uri.parse("S:a/b");
+ testResolve("s:a/c", "c");
+ testResolve("s:/c", "../c");
+
+ base = Uri.parse("s:foo");
+ testResolve("s:bar", "bar");
+ testResolve("s:bar", "../bar");
+
+ base = Uri.parse("S:foo");
+ testResolve("s:bar", "bar");
+ testResolve("s:bar", "../bar");
+
+ base = Uri.parse("s:/foo");
+ testResolve("s:/bar", "bar");
+ testResolve("s:/bar", "../bar");
+
+ base = Uri.parse("S:/foo");
+ testResolve("s:/bar", "bar");
+ testResolve("s:/bar", "../bar");
+
// Test non-URI base (no scheme, no authority, relative path).
base = Uri.parse("a/b/c?_#_");
testResolve("a/b/g?q#f", "g?q#f");
testResolve("./", "../..");
testResolve("../", "../../..");
testResolve("a/b/", ".");
- testResolve("c", "../../c");
+ testResolve("/c", "../../c");
base = Uri.parse("../../a/b/c?_#_"); // Initial ".." in base url.
testResolve("../../a/d", "../d");
testResolve("../../../d", "../../../d");
- base = Uri.parse("s:a/b");
- testResolve("s:/c", "../c");
+ base = Uri.parse("s://h/p?q#f"); // A simple base.
+ // Simple references:
+ testResolve("s2://h2/P?Q#F", "s2://h2/P?Q#F");
+ testResolve("s://h2/P?Q#F", "//h2/P?Q#F");
+ testResolve("s://h/P?Q#F", "/P?Q#F");
+ testResolve("s://h/p?Q#F", "?Q#F");
+ testResolve("s://h/p?q#F", "#F");
+ testResolve("s://h/p?q", "");
+ // Non-simple references:
+ testResolve("s2://I@h2/P?Q#F%20", "s2://I@h2/P?Q#F%20");
+ testResolve("s://I@h2/P?Q#F%20", "//I@h2/P?Q#F%20");
+ testResolve("s://h2/P?Q#F%20", "//h2/P?Q#F%20");
+ testResolve("s://h/P?Q#F%20", "/P?Q#F%20");
+ testResolve("s://h/p?Q#F%20", "?Q#F%20");
+ testResolve("s://h/p?q#F%20", "#F%20");
+
+ base = Uri.parse("s://h/p1/p2/p3"); // A simple base with a path.
+ testResolve("s://h/p1/p2/", ".");
+ testResolve("s://h/p1/p2/", "./");
+ testResolve("s://h/p1/", "..");
+ testResolve("s://h/p1/", "../");
+ testResolve("s://h/", "../..");
+ testResolve("s://h/", "../../");
+ testResolve("s://h/p1/%20", "../%20");
+ testResolve("s://h/", "../../../..");
+ testResolve("s://h/", "../../../../");
+
+ base = Uri.parse("s://h/p?q#f%20"); // A non-simpe base
floitsch 2016/06/29 23:41:48 finish with ".".
Lasse Reichstein Nielsen 2016/06/30 10:27:31 Argh, missed that one. Will fix.
+ // Simple references:
+ testResolve("s2://h2/P?Q#F", "s2://h2/P?Q#F");
+ testResolve("s://h2/P?Q#F", "//h2/P?Q#F");
+ testResolve("s://h/P?Q#F", "/P?Q#F");
+ testResolve("s://h/p?Q#F", "?Q#F");
+ testResolve("s://h/p?q#F", "#F");
+ testResolve("s://h/p?q", "");
+ // Non-simple references:
+ testResolve("s2://I@h2/P?Q#F%20", "s2://I@h2/P?Q#F%20");
+ testResolve("s://I@h2/P?Q#F%20", "//I@h2/P?Q#F%20");
+ testResolve("s://h2/P?Q#F%20", "//h2/P?Q#F%20");
+ testResolve("s://h/P?Q#F%20", "/P?Q#F%20");
+ testResolve("s://h/p?Q#F%20", "?Q#F%20");
+ testResolve("s://h/p?q#F%20", "#F%20");
+
+ base = Uri.parse("S://h/p1/p2/p3"); // A non-simple base with a path.
+ testResolve("s://h/p1/p2/", ".");
+ testResolve("s://h/p1/p2/", "./");
+ testResolve("s://h/p1/", "..");
+ testResolve("s://h/p1/", "../");
+ testResolve("s://h/", "../..");
+ testResolve("s://h/", "../../");
+ testResolve("s://h/p1/%20", "../%20");
+ testResolve("s://h/", "../../../..");
+ testResolve("s://h/", "../../../../");
+
+ base = Uri.parse("../../../"); // A simple relative path.
+ testResolve("../../../a", "a");
+ testResolve("../../../../a", "../a");
+ testResolve("../../../a%20", "a%20");
+ testResolve("../../../../a%20", "../a%20");
+
+ // Regression test.
+ base = Uri.parse("scheme:pathNoSlash");
+ testResolve("scheme:otherPath", "otherPath");
}
void testResolvePath(String expected, String path) {
@@ -493,6 +584,11 @@ main() {
query: null,
fragment: null).toString());
Expect.stringEquals("file:///", Uri.parse("file:").toString());
+ Expect.stringEquals("file:///", Uri.parse("file:/").toString());
+ Expect.stringEquals("file:///", Uri.parse("file:").toString());
+ Expect.stringEquals("file:///foo", Uri.parse("file:foo").toString());
+ Expect.stringEquals("file:///foo", Uri.parse("file:/foo").toString());
+ Expect.stringEquals("file://foo/", Uri.parse("file://foo").toString());
testResolvePath("/a/g", "/a/b/c/./../../g");
testResolvePath("/a/g", "/a/b/c/./../../g");
« sdk/lib/core/uri.dart ('K') | « tests/corelib/data_uri_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698