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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/corelib/uri_file_test.dart ('k') | tests/corelib/uri_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6
7
8 void testUriCombi() {
9 var schemes = ["", "file", "ws", "ftp"];
10 var fragments = ["", "#", "#f", "#fragment", "#l:?/"];
11 var queries = ["", "?", "?q", "?query", "?q:/"];
12 var paths = ["/", "/x", "/x/y", "/x/y/", "/x:y"];
13 var userInfos = ["", "x", "xxx", "x:4", "xxx:444", "x:4:x"];
14 var hosts = ["", "h", "hhh", "h:4", "hhh:444", "[::1.2.3.4]"];
15
16 void check(uriString, scheme, fragment, query, path, user, host) {
17 var uri = Uri.parse(uriString);
18 Expect.equals(scheme, uri.scheme);
19 var uriFragment = uri.fragment;
20 if (fragment.startsWith('#')) uriFragment = "#$uriFragment";
21 Expect.equals(fragment, uriFragment);
22 var uriQuery = uri.query;
23 if (query.startsWith('?')) uriQuery = "?$uriQuery";
24 Expect.equals(query, uriQuery);
25 Expect.equals(path, uri.path);
26 Expect.equals(user, uri.userInfo);
27 var uriHost = uri.host;
28 if (host.startsWith("[")) uriHost = "[$uriHost]";
29 if (uri.port != 0) uriHost += ":${uri.port}";
30 Expect.equals(host, uriHost);
31 }
32
33 for (var scheme in schemes) {
34 for (var fragment in fragments) {
35 for (var query in queries) {
36 for (var path in paths) {
37 for (var user in userInfos) {
38 for (var host in hosts) {
39 var auth = host;
40 var s = scheme;
41 if (user.isNotEmpty) auth = "$user@$auth";
42 if (auth.isNotEmpty) auth = "//$auth";
43 check("$scheme${scheme.isEmpty ? "" : ":"}"
44 "$auth$path$query$fragment",
45 scheme,
46 fragment,
47 query,
48 path,
49 user,
50 host);
51 }
52 }
53 }
54 }
55 }
56 }
57 }
58
59 void main() {
60 testUriCombi();
61 }
OLDNEW
« 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