OLD | NEW |
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"; | 5 import "dart:collection"; |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 | 8 |
9 void testInvalidArguments() {} | 9 void testInvalidArguments() {} |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 var unencoded = new StringBuffer(); | 76 var unencoded = new StringBuffer(); |
77 for (int i = 32; i < 128; i++) { | 77 for (int i = 32; i < 128; i++) { |
78 if (pchar.indexOf(new String.fromCharCode(i)) != -1) { | 78 if (pchar.indexOf(new String.fromCharCode(i)) != -1) { |
79 encoded.writeCharCode(i); | 79 encoded.writeCharCode(i); |
80 } else { | 80 } else { |
81 encoded.write("%"); | 81 encoded.write("%"); |
82 encoded.write(i.toRadixString(16).toUpperCase()); | 82 encoded.write(i.toRadixString(16).toUpperCase()); |
83 } | 83 } |
84 unencoded.writeCharCode(i); | 84 unencoded.writeCharCode(i); |
85 } | 85 } |
86 encoded = encoded.toString(); | 86 var encodedStr = encoded.toString(); |
87 unencoded = unencoded.toString(); | 87 var unencodedStr = unencoded.toString(); |
88 test(encoded, [unencoded]); | 88 test(encodedStr, [unencodedStr]); |
89 test(encoded + "/" + encoded, [unencoded, unencoded]); | 89 test(encodedStr + "/" + encodedStr, [unencodedStr, unencodedStr]); |
90 | 90 |
91 Uri uri; | 91 Uri uri; |
92 List pathSegments = ["xxx", "yyy", "zzz"]; | 92 var pathSegments = ["xxx", "yyy", "zzz"]; |
93 | 93 |
94 uri = new Uri(pathSegments: pathSegments); | 94 uri = new Uri(pathSegments: pathSegments); |
95 Expect.equals(3, uri.pathSegments.length); | 95 Expect.equals(3, uri.pathSegments.length); |
96 uri = new Uri(pathSegments: pathSegments.where((_) => true)); | 96 uri = new Uri(pathSegments: pathSegments.where((_) => true)); |
97 Expect.equals(3, uri.pathSegments.length); | 97 Expect.equals(3, uri.pathSegments.length); |
98 uri = new Uri(pathSegments: new DoubleLinkedQueue.from(pathSegments)); | 98 uri = new Uri(pathSegments: new DoubleLinkedQueue.from(pathSegments)); |
99 Expect.equals(3, uri.pathSegments.length); | 99 Expect.equals(3, uri.pathSegments.length); |
100 | 100 |
101 uri = new Uri(scheme: "http", host: "host", pathSegments: pathSegments); | 101 uri = new Uri(scheme: "http", host: "host", pathSegments: pathSegments); |
102 Expect.equals(3, uri.pathSegments.length); | 102 Expect.equals(3, uri.pathSegments.length); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 test(new Uri(pathSegments: ["a", "b"]).pathSegments); | 179 test(new Uri(pathSegments: ["a", "b"]).pathSegments); |
180 } | 180 } |
181 | 181 |
182 main() { | 182 main() { |
183 testInvalidArguments(); | 183 testInvalidArguments(); |
184 testPath(); | 184 testPath(); |
185 testPathSegments(); | 185 testPathSegments(); |
186 testPathCompare(); | 186 testPathCompare(); |
187 testPathSegmentsUnmodifiableList(); | 187 testPathSegmentsUnmodifiableList(); |
188 } | 188 } |
OLD | NEW |