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

Unified Diff: tests/corelib/uri_test.dart

Issue 347393003: Fix bugs in Uri: Allow empty port, handle path starting with "//" in toString. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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
« no previous file with comments | « sdk/lib/core/uri.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 75466eea4484350c7e2d7723888c825d1104170c..703515d537341a32863c74bf89b28e3bd4c583c0 100644
--- a/tests/corelib/uri_test.dart
+++ b/tests/corelib/uri_test.dart
@@ -147,7 +147,7 @@ void testValidCharacters() {
for (var host in ["", "$REGNAMECHAR$REGNAMECHAR",
"255.255.255.256", // valid reg-name.
"[ffff::ffff:ffff]", "[ffff::255.255.255.255]"]) {
- for (var port in ["", ":$DIGIT$DIGIT"]) {
+ for (var port in ["", ":", ":$DIGIT$DIGIT"]) {
var auth = "$userinfo$host$port";
if (auth.isNotEmpty) auth = "//$auth";
var paths = ["", "/", "/$PCHAR", "/$PCHAR/"]; // Absolute or empty.
@@ -258,8 +258,6 @@ void testInvalidUrls() {
checkInvalid("s://x@x:9:9/");
// At most one #.
checkInvalid("s://x/x#foo#bar");
- // Colon in host implies port and port may not be empty.
- checkInvalid("s://:/");
// @ not allowed in scheme.
checkInvalid("s@://x:9/x?x#x");
// ] not allowed alone in host.
@@ -340,6 +338,20 @@ void testNormalization() {
uri = Uri.parse("x://%61/");
Expect.equals("a", uri.host);
+
+ uri = new Uri(scheme: "x", path: "//y");
+ Expect.equals("//y", uri.path);
+ Expect.equals("x:////y", uri.toString());
+
+ uri = new Uri(scheme: "file", path: "//y");
+ Expect.equals("//y", uri.path);
+ Expect.equals("file:////y", uri.toString());
+
+ // File scheme noralizes to always showing authority, even if empty.
+ uri = new Uri(scheme: "file", path: "/y");
+ Expect.equals("file:///y", uri.toString());
+ uri = new Uri(scheme: "file", path: "y");
+ Expect.equals("file:///y", uri.toString());
}
main() {
@@ -502,6 +514,10 @@ main() {
Expect.throws(
() => Uri.parse("file://user@password:host/path"),
(e) => e is FormatException);
+
+ testValidCharacters();
+ testInvalidUrls();
+ testNormalization();
}
String dump(Uri uri) {
« no previous file with comments | « sdk/lib/core/uri.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698