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

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

Issue 22918029: Change the type of the pathSegments argument to the Uri constructor from List to Iterable (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 3 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 | « sdk/lib/core/uri.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "dart:collection";
6
5 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
6 8
7 void testInvalidArguments() { 9 void testInvalidArguments() {
8 } 10 }
9 11
10 void testPath() { 12 void testPath() {
11 void test(s, uri) { 13 void test(s, uri) {
12 Expect.equals(s, uri.toString()); 14 Expect.equals(s, uri.toString());
13 Expect.equals(uri, Uri.parse(s)); 15 Expect.equals(uri, Uri.parse(s));
14 } 16 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 encoded.write(i.toRadixString(16).toUpperCase()); 86 encoded.write(i.toRadixString(16).toUpperCase());
85 } 87 }
86 unencoded.writeCharCode(i); 88 unencoded.writeCharCode(i);
87 } 89 }
88 encoded = encoded.toString(); 90 encoded = encoded.toString();
89 unencoded = unencoded.toString(); 91 unencoded = unencoded.toString();
90 test(encoded, [unencoded]); 92 test(encoded, [unencoded]);
91 test(encoded + "/" + encoded, [unencoded, unencoded]); 93 test(encoded + "/" + encoded, [unencoded, unencoded]);
92 94
93 Uri uri; 95 Uri uri;
94 uri = new Uri(pathSegments: ["xxx", "yyy", "zzz"]); 96 List pathSegments = ["xxx", "yyy", "zzz"];
97
98 uri = new Uri(pathSegments: pathSegments);
99 Expect.equals(3, uri.pathSegments.length);
100 uri = new Uri(pathSegments: pathSegments.where((_) => true));
101 Expect.equals(3, uri.pathSegments.length);
102 uri = new Uri(pathSegments: new DoubleLinkedQueue.from(pathSegments));
103 Expect.equals(3, uri.pathSegments.length);
104
105 uri = new Uri(scheme: "http",
106 host: "host",
107 pathSegments: pathSegments);
95 Expect.equals(3, uri.pathSegments.length); 108 Expect.equals(3, uri.pathSegments.length);
96 uri = new Uri(scheme: "http", 109 uri = new Uri(scheme: "http",
97 host: "host", 110 host: "host",
98 pathSegments: ["xxx", "yyy", "zzz"]); 111 pathSegments: pathSegments.where((_) => true));
112 Expect.equals(3, uri.pathSegments.length);
113 uri = new Uri(scheme: "http",
114 host: "host",
115 pathSegments: new DoubleLinkedQueue.from(pathSegments));
116 Expect.equals(3, uri.pathSegments.length);
117
118 uri = new Uri(scheme: "file",
119 pathSegments: pathSegments);
99 Expect.equals(3, uri.pathSegments.length); 120 Expect.equals(3, uri.pathSegments.length);
100 uri = new Uri(scheme: "file", 121 uri = new Uri(scheme: "file",
101 pathSegments: ["xxx", "yyy", "zzz"]); 122 pathSegments: pathSegments.where((_) => true));
123 Expect.equals(3, uri.pathSegments.length);
124 uri = new Uri(scheme: "file",
125 pathSegments: new DoubleLinkedQueue.from(pathSegments));
102 Expect.equals(3, uri.pathSegments.length); 126 Expect.equals(3, uri.pathSegments.length);
103 } 127 }
104 128
105 void testPathCompare() { 129 void testPathCompare() {
106 void test(Uri uri1, Uri uri2) { 130 void test(Uri uri1, Uri uri2) {
107 Expect.equals(uri1, uri2); 131 Expect.equals(uri1, uri2);
108 Expect.equals(uri2, uri1); 132 Expect.equals(uri2, uri1);
109 } 133 }
110 134
111 test(new Uri(scheme: "http", host: "host", path: "xxx"), 135 test(new Uri(scheme: "http", host: "host", path: "xxx"),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 test(new Uri(pathSegments: ["a", "b"]).pathSegments); 185 test(new Uri(pathSegments: ["a", "b"]).pathSegments);
162 } 186 }
163 187
164 main() { 188 main() {
165 testInvalidArguments(); 189 testInvalidArguments();
166 testPath(); 190 testPath();
167 testPathSegments(); 191 testPathSegments();
168 testPathCompare(); 192 testPathCompare();
169 testPathSegmentsUnmodifiableList(); 193 testPathSegmentsUnmodifiableList();
170 } 194 }
OLDNEW
« no previous file with comments | « sdk/lib/core/uri.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698