OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 library uriTest; | 5 library uriTest; |
6 | 6 |
7 import 'dart:utf'; | 7 import 'dart:utf'; |
8 import 'dart:uri'; | 8 import 'dart:uri'; |
9 | 9 |
10 testUri(String uri, bool isAbsolute) { | 10 testUri(String uri, bool isAbsolute) { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 Expect.throws( | 180 Expect.throws( |
181 () => new Uri.fromString("http://:80").origin, | 181 () => new Uri.fromString("http://:80").origin, |
182 (e) { return e is ArgumentError; }, | 182 (e) { return e is ArgumentError; }, |
183 "origin for uri with empty domain should fail"); | 183 "origin for uri with empty domain should fail"); |
184 Expect.throws( | 184 Expect.throws( |
185 () => new Uri.fromString("file://localhost/test.txt").origin, | 185 () => new Uri.fromString("file://localhost/test.txt").origin, |
186 (e) { return e is ArgumentError; }, | 186 (e) { return e is ArgumentError; }, |
187 "origin for non-http/https uri should fail"); | 187 "origin for non-http/https uri should fail"); |
188 | 188 |
189 // URI encode tests | 189 // URI encode tests |
190 // Note: dart2js won't handle '\ud800\udc00' and frog | 190 // Create a string with code point 0x10000 encoded as a surrogate pair. |
191 // won't handle '\u{10000}'. So we cons this up synthetically... | |
192 var s = decodeUtf8([0xf0, 0x90, 0x80, 0x80]); | 191 var s = decodeUtf8([0xf0, 0x90, 0x80, 0x80]); |
193 | 192 |
| 193 Expect.stringEquals("\u{10000}", s); |
| 194 |
194 testEncodeDecode("\uFFFE", "%EF%BF%BE"); | 195 testEncodeDecode("\uFFFE", "%EF%BF%BE"); |
195 testEncodeDecode("\uFFFF", "%EF%BF%BF"); | 196 testEncodeDecode("\uFFFF", "%EF%BF%BF"); |
196 testEncodeDecode("\uFFFE", "%EF%BF%BE"); | 197 testEncodeDecode("\uFFFE", "%EF%BF%BE"); |
197 testEncodeDecode("\uFFFF", "%EF%BF%BF"); | 198 testEncodeDecode("\uFFFF", "%EF%BF%BF"); |
198 testEncodeDecode("\x7f", "%7F"); | 199 testEncodeDecode("\x7f", "%7F"); |
199 testEncodeDecode("\x80", "%C2%80"); | 200 testEncodeDecode("\x80", "%C2%80"); |
200 testEncodeDecode("\u0800", "%E0%A0%80"); | 201 testEncodeDecode("\u0800", "%E0%A0%80"); |
201 testEncodeDecode(":/@',;?&=+\$", ":/@',;?&=+\$"); | 202 testEncodeDecode(":/@',;?&=+\$", ":/@',;?&=+\$"); |
202 testEncodeDecode(s, "%F0%90%80%80"); | 203 testEncodeDecode(s, "%F0%90%80%80"); |
203 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); | 204 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); |
204 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); | 205 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); |
205 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); | 206 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); |
206 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); | 207 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); |
207 testEncodeDecodeComponent("\x7f", "%7F"); | 208 testEncodeDecodeComponent("\x7f", "%7F"); |
208 testEncodeDecodeComponent("\x80", "%C2%80"); | 209 testEncodeDecodeComponent("\x80", "%C2%80"); |
209 testEncodeDecodeComponent("\u0800", "%E0%A0%80"); | 210 testEncodeDecodeComponent("\u0800", "%E0%A0%80"); |
210 testEncodeDecodeComponent(":/@',;?&=+\$", "%3A%2F%40'%2C%3B%3F%26%3D%2B%24"); | 211 testEncodeDecodeComponent(":/@',;?&=+\$", "%3A%2F%40'%2C%3B%3F%26%3D%2B%24"); |
211 testEncodeDecodeComponent(s, "%F0%90%80%80"); | 212 testEncodeDecodeComponent(s, "%F0%90%80%80"); |
212 } | 213 } |
OLD | NEW |