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

Side by Side Diff: tests/corelib/uri_parse_test.dart

Issue 2983123002: Migrate test block 30 + corelib portion of block 31 to Dart 2.0. (Closed)
Patch Set: Addressed Bob's comments Created 3 years, 5 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
« no previous file with comments | « tests/corelib/uri_parameters_all_test.dart ('k') | tests/corelib/uri_path_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 void testUriCombi() {
8 var schemes = ["", "file", "ws", "ftp"];
9 var fragments = ["", "#", "#f", "#fragment", "#l:?/"];
10 var queries = ["", "?", "?q", "?query", "?q:/"];
11 var paths = ["/", "/x", "/x/y", "/x/y/", "/x:y", "x", "x/y", "x/y/"];
12 var userInfos = ["", "x", "xxx", "x:4", "xxx:444", "x:4:x"];
13 var hosts = ["", "h", "hhh", "h:4", "hhh:444", "[::1.2.3.4]"];
14
15 void check(uriString, scheme, fragment, query, path, user, host) {
16 for (var uri in [
17 Uri.parse(uriString),
18 Uri.parse(">\u{10000}>$uriString<\u{10000}<", 4, uriString.length + 4),
19 Uri.parse(
20 "http://example.com/$uriString#?:/[]\"", 19, uriString.length + 19),
21 Uri.parse(uriString * 3, uriString.length, uriString.length * 2)
22 ]) {
23 String name = "$uriString -> $uri";
24 Expect.equals(scheme, uri.scheme, name);
25 var uriFragment = uri.fragment;
26 if (fragment.startsWith('#')) uriFragment = "#$uriFragment";
27 Expect.equals(fragment, uriFragment, name);
28 var uriQuery = uri.query;
29 if (query.startsWith('?')) uriQuery = "?$uriQuery";
30 Expect.equals(query, uriQuery, name);
31 Expect.equals(path, uri.path, name);
32 Expect.equals(user, uri.userInfo, name);
33 var uriHost = uri.host;
34 if (host.startsWith("[")) uriHost = "[$uriHost]";
35 if (uri.port != 0) uriHost += ":${uri.port}";
36 Expect.equals(host, uriHost, name);
37 }
38 }
39
40 for (var scheme in schemes) {
41 for (var fragment in fragments) {
42 for (var query in queries) {
43 for (var path in paths) {
44 // File scheme URIs always get a leading slash.
45 if (scheme == "file" && !path.startsWith('/')) continue;
46 for (var user in userInfos) {
47 for (var host in hosts) {
48 var auth = host;
49 var s = scheme;
50 if (user.isNotEmpty) auth = "$user@$auth";
51 if (auth.isNotEmpty) auth = "//$auth";
52 if (auth.isNotEmpty && !path.startsWith('/')) continue;
53 check(
54 "$scheme${scheme.isEmpty ? "" : ":"}"
55 "$auth$path$query$fragment",
56 scheme,
57 fragment,
58 query,
59 path,
60 user,
61 host);
62 }
63 }
64 }
65 }
66 }
67 }
68 }
69
70 void main() {
71 testUriCombi();
72 }
OLDNEW
« no previous file with comments | « tests/corelib/uri_parameters_all_test.dart ('k') | tests/corelib/uri_path_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698