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

Unified Diff: tests/corelib/uri_parse_test.dart

Issue 167703010: Write custom URI-parser, to avoid using regexp. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 | « tests/corelib/uri_file_test.dart ('k') | tests/corelib/uri_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/uri_parse_test.dart
diff --git a/tests/corelib/uri_parse_test.dart b/tests/corelib/uri_parse_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2a0c980882a01c71e92224c7abc11bb5e838cbfe
--- /dev/null
+++ b/tests/corelib/uri_parse_test.dart
@@ -0,0 +1,61 @@
+// 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";
+
+
+void testUriCombi() {
+ var schemes = ["", "file", "ws", "ftp"];
+ var fragments = ["", "#", "#f", "#fragment", "#l:?/"];
+ var queries = ["", "?", "?q", "?query", "?q:/"];
+ var paths = ["/", "/x", "/x/y", "/x/y/", "/x:y"];
+ var userInfos = ["", "x", "xxx", "x:4", "xxx:444", "x:4:x"];
+ var hosts = ["", "h", "hhh", "h:4", "hhh:444", "[::1.2.3.4]"];
+
+ void check(uriString, scheme, fragment, query, path, user, host) {
+ var uri = Uri.parse(uriString);
+ Expect.equals(scheme, uri.scheme);
+ var uriFragment = uri.fragment;
+ if (fragment.startsWith('#')) uriFragment = "#$uriFragment";
+ Expect.equals(fragment, uriFragment);
+ var uriQuery = uri.query;
+ if (query.startsWith('?')) uriQuery = "?$uriQuery";
+ Expect.equals(query, uriQuery);
+ Expect.equals(path, uri.path);
+ Expect.equals(user, uri.userInfo);
+ var uriHost = uri.host;
+ if (host.startsWith("[")) uriHost = "[$uriHost]";
+ if (uri.port != 0) uriHost += ":${uri.port}";
+ Expect.equals(host, uriHost);
+ }
+
+ for (var scheme in schemes) {
+ for (var fragment in fragments) {
+ for (var query in queries) {
+ for (var path in paths) {
+ for (var user in userInfos) {
+ for (var host in hosts) {
+ var auth = host;
+ var s = scheme;
+ if (user.isNotEmpty) auth = "$user@$auth";
+ if (auth.isNotEmpty) auth = "//$auth";
+ check("$scheme${scheme.isEmpty ? "" : ":"}"
+ "$auth$path$query$fragment",
+ scheme,
+ fragment,
+ query,
+ path,
+ user,
+ host);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void main() {
+ testUriCombi();
+}
« no previous file with comments | « tests/corelib/uri_file_test.dart ('k') | tests/corelib/uri_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698