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

Unified Diff: test/codegen/corelib/uri_http_test.dart

Issue 1945153002: Add corelib tests (Closed) Base URL: https://github.com/dart-lang/dev_compiler@master
Patch Set: error_test and range_error_test now pass Created 4 years, 7 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 | « test/codegen/corelib/uri_file_test.dart ('k') | test/codegen/corelib/uri_ipv4_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/corelib/uri_http_test.dart
diff --git a/test/codegen/corelib/uri_http_test.dart b/test/codegen/corelib/uri_http_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..79bc3c8746168ecf545ca7e48e052b37bdebe4c0
--- /dev/null
+++ b/test/codegen/corelib/uri_http_test.dart
@@ -0,0 +1,82 @@
+// 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://:8080");
+ 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 b"), "http://host/a%20b");
+ check(new Uri.http("host", "/a b"), "http://host/a%20b");
+ check(new Uri.http("host", "/a b/"), "http://host/a%20b/");
+ 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");
+ check(new Uri.http("host",
+ "/a/b", { "c=": "&d" }), "http://host/a/b?c%3D=%26d");
+ check(new Uri.http("[::]", "a"), "http://[::]/a");
+ check(new Uri.http("[::127.0.0.1]", "a"), "http://[::127.0.0.1]/a");
+}
+
+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://:8080");
+ 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 b"), "https://host/a%20b");
+ check(new Uri.https("host", "/a b"), "https://host/a%20b");
+ check(new Uri.https("host", "/a b/"), "https://host/a%20b/");
+ 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");
+ check(new Uri.https("[::]", "a"), "https://[::]/a");
+ check(new Uri.https("[::127.0.0.1]", "a"), "https://[::127.0.0.1]/a");
+}
+
+testResolveHttpScheme() {
+ String s = "//myserver:1234/path/some/thing";
+ Uri uri = Uri.parse(s);
+ Uri http = new Uri(scheme: "http");
+ Uri https = new Uri(scheme: "https");
+ Expect.equals("http:$s", http.resolveUri(uri).toString());
+ Expect.equals("https:$s", https.resolveUri(uri).toString());
+}
+
+main() {
+ testHttpUri();
+ testHttpsUri();
+ testResolveHttpScheme();
+}
« no previous file with comments | « test/codegen/corelib/uri_file_test.dart ('k') | test/codegen/corelib/uri_ipv4_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698