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

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: 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: new DoubleLinkedQueue.from(pathSegments));
101 Expect.equals(3, uri.pathSegments.length);
102
103 uri = new Uri(scheme: "http",
104 host: "host",
105 pathSegments: pathSegments);
95 Expect.equals(3, uri.pathSegments.length); 106 Expect.equals(3, uri.pathSegments.length);
96 uri = new Uri(scheme: "http", 107 uri = new Uri(scheme: "http",
97 host: "host", 108 host: "host",
98 pathSegments: ["xxx", "yyy", "zzz"]); 109 pathSegments: new DoubleLinkedQueue.from(pathSegments));
110 Expect.equals(3, uri.pathSegments.length);
111
112 uri = new Uri(scheme: "file",
113 pathSegments: pathSegments);
99 Expect.equals(3, uri.pathSegments.length); 114 Expect.equals(3, uri.pathSegments.length);
100 uri = new Uri(scheme: "file", 115 uri = new Uri(scheme: "file",
101 pathSegments: ["xxx", "yyy", "zzz"]); 116 pathSegments: new DoubleLinkedQueue.from(pathSegments));
Lasse Reichstein Nielsen 2013/08/26 13:55:37 Try using something that has inefficient length, e
Søren Gjesse 2013/08/26 14:24:54 Done.
102 Expect.equals(3, uri.pathSegments.length); 117 Expect.equals(3, uri.pathSegments.length);
103 } 118 }
104 119
105 void testPathCompare() { 120 void testPathCompare() {
106 void test(Uri uri1, Uri uri2) { 121 void test(Uri uri1, Uri uri2) {
107 Expect.equals(uri1, uri2); 122 Expect.equals(uri1, uri2);
108 Expect.equals(uri2, uri1); 123 Expect.equals(uri2, uri1);
109 } 124 }
110 125
111 test(new Uri(scheme: "http", host: "host", path: "xxx"), 126 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); 176 test(new Uri(pathSegments: ["a", "b"]).pathSegments);
162 } 177 }
163 178
164 main() { 179 main() {
165 testInvalidArguments(); 180 testInvalidArguments();
166 testPath(); 181 testPath();
167 testPathSegments(); 182 testPathSegments();
168 testPathCompare(); 183 testPathCompare();
169 testPathSegmentsUnmodifiableList(); 184 testPathSegmentsUnmodifiableList();
170 } 185 }
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