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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Create a string with code point 0x10000 encoded as a surrogate pair. | 190 // Create a string with code point 0x10000 encoded as a surrogate pair. |
191 var s = decodeUtf8([0xf0, 0x90, 0x80, 0x80]); | 191 var s = decodeUtf8([0xf0, 0x90, 0x80, 0x80]); |
192 | 192 |
193 Expect.stringEquals("\u{10000}", s); | 193 Expect.stringEquals("\u{10000}", s); |
194 | 194 |
| 195 testEncodeDecode("A + B", "A+%2B+B"); |
195 testEncodeDecode("\uFFFE", "%EF%BF%BE"); | 196 testEncodeDecode("\uFFFE", "%EF%BF%BE"); |
196 testEncodeDecode("\uFFFF", "%EF%BF%BF"); | 197 testEncodeDecode("\uFFFF", "%EF%BF%BF"); |
197 testEncodeDecode("\uFFFE", "%EF%BF%BE"); | 198 testEncodeDecode("\uFFFE", "%EF%BF%BE"); |
198 testEncodeDecode("\uFFFF", "%EF%BF%BF"); | 199 testEncodeDecode("\uFFFF", "%EF%BF%BF"); |
199 testEncodeDecode("\x7f", "%7F"); | 200 testEncodeDecode("\x7f", "%7F"); |
200 testEncodeDecode("\x80", "%C2%80"); | 201 testEncodeDecode("\x80", "%C2%80"); |
201 testEncodeDecode("\u0800", "%E0%A0%80"); | 202 testEncodeDecode("\u0800", "%E0%A0%80"); |
202 testEncodeDecode(":/@',;?&=+\$", ":/@',;?&=+\$"); | 203 testEncodeDecode(":/@',;?&=+\$", ":/@',;?&=%2B\$"); |
203 testEncodeDecode(s, "%F0%90%80%80"); | 204 testEncodeDecode(s, "%F0%90%80%80"); |
204 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); | 205 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); |
205 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); | 206 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); |
206 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); | 207 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); |
207 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); | 208 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); |
208 testEncodeDecodeComponent("\x7f", "%7F"); | 209 testEncodeDecodeComponent("\x7f", "%7F"); |
209 testEncodeDecodeComponent("\x80", "%C2%80"); | 210 testEncodeDecodeComponent("\x80", "%C2%80"); |
210 testEncodeDecodeComponent("\u0800", "%E0%A0%80"); | 211 testEncodeDecodeComponent("\u0800", "%E0%A0%80"); |
211 testEncodeDecodeComponent(":/@',;?&=+\$", "%3A%2F%40'%2C%3B%3F%26%3D%2B%24"); | 212 testEncodeDecodeComponent(":/@',;?&=+\$", "%3A%2F%40'%2C%3B%3F%26%3D%2B%24"); |
212 testEncodeDecodeComponent(s, "%F0%90%80%80"); | 213 testEncodeDecodeComponent(s, "%F0%90%80%80"); |
213 } | 214 } |
OLD | NEW |