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

Unified Diff: tests/corelib/uri_http_test.dart

Issue 17221003: Add Uri.http and Uri.https constructors (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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') | « 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_http_test.dart
diff --git a/tests/corelib/uri_http_test.dart b/tests/corelib/uri_http_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..fc25c6325a94c8ced60140092910858ff2c3eb9b
--- /dev/null
+++ b/tests/corelib/uri_http_test.dart
@@ -0,0 +1,60 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+testHttpUri() {
+ void check(Uri uri, String expected) {
+ Expect.equals(expected, uri.toString());
+ }
+
+ check(new Uri.http("", ""), "http:");
+ check(new Uri.http("@:", ""), "http:");
+ check(new Uri.http("@:8080", ""), "http:");
+ check(new Uri.http("@host:", ""), "http://host");
+ check(new Uri.http("@host:", ""), "http://host");
+ check(new Uri.http("xxx:yyy@host:8080", ""), "http://xxx:yyy@host:8080");
+ check(new Uri.http("host", "a"), "http://host/a");
+ check(new Uri.http("host", "/a"), "http://host/a");
+ check(new Uri.http("host", "a/"), "http://host/a/");
+ check(new Uri.http("host", "/a/"), "http://host/a/");
+ check(new Uri.http("host", "a/b"), "http://host/a/b");
+ check(new Uri.http("host", "/a/b"), "http://host/a/b");
+ check(new Uri.http("host", "a/b/"), "http://host/a/b/");
+ check(new Uri.http("host", "/a/b/"), "http://host/a/b/");
+ check(new Uri.http("host", "/a%2F"), "http://host/a%252F");
+ check(new Uri.http("host", "/a%2F/"), "http://host/a%252F/");
+ check(new Uri.http("host", "/a/b", { "c": "d" }), "http://host/a/b?c=d");
floitsch 2013/06/17 14:31:34 add test that contains spaces (at least in the pat
Søren Gjesse 2013/06/18 06:05:34 Done.
+ check(new Uri.http("host", "/a/b", { "c=": "&d" }), "http://host/a/b?c%3D=%26d");
floitsch 2013/06/17 14:31:34 long line.
Søren Gjesse 2013/06/18 06:05:34 Done.
+}
+
+testHttpsUri() {
+ void check(Uri uri, String expected) {
+ Expect.equals(expected, uri.toString());
+ }
+
+ check(new Uri.https("", ""), "https:");
+ check(new Uri.https("@:", ""), "https:");
+ check(new Uri.https("@:8080", ""), "https:");
+ check(new Uri.https("@host:", ""), "https://host");
+ check(new Uri.https("@host:", ""), "https://host");
+ check(new Uri.https("xxx:yyy@host:8080", ""), "https://xxx:yyy@host:8080");
+ check(new Uri.https("host", "a"), "https://host/a");
+ check(new Uri.https("host", "/a"), "https://host/a");
+ check(new Uri.https("host", "a/"), "https://host/a/");
+ check(new Uri.https("host", "/a/"), "https://host/a/");
+ check(new Uri.https("host", "a/b"), "https://host/a/b");
+ check(new Uri.https("host", "/a/b"), "https://host/a/b");
+ check(new Uri.https("host", "a/b/"), "https://host/a/b/");
+ check(new Uri.https("host", "/a/b/"), "https://host/a/b/");
+ check(new Uri.https("host", "/a%2F"), "https://host/a%252F");
+ check(new Uri.https("host", "/a%2F/"), "https://host/a%252F/");
+ check(new Uri.https("host", "/a/b", { "c": "d" }), "https://host/a/b?c=d");
+ check(new Uri.https("host", "/a/b", { "c=": "&d" }), "https://host/a/b?c%3D=%26d");
+}
+
+main() {
+ testHttpUri();
+ testHttpsUri();
+}
« sdk/lib/core/uri.dart ('K') | « sdk/lib/core/uri.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698