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

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

Issue 366873005: Version 1.5.2 (Closed) Base URL: http://dart.googlecode.com/svn/branches/1.5/
Patch Set: Created 6 years, 5 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 | « dart/sdk/lib/html/dart2js/html_dart2js.dart ('k') | dart/tools/VERSION » ('j') | 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) 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 "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 import 'dart:convert'; 8 import 'dart:convert';
9 9
10 testUri(String uri, bool isAbsolute) { 10 testUri(String uri, bool isAbsolute) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 () => Uri.parse("file://localhost/test.txt").origin, 226 () => Uri.parse("file://localhost/test.txt").origin,
227 (e) { return e is StateError; }, 227 (e) { return e is StateError; },
228 "origin for non-http/https uri should fail"); 228 "origin for non-http/https uri should fail");
229 229
230 // URI encode tests 230 // URI encode tests
231 // Create a string with code point 0x10000 encoded as a surrogate pair. 231 // Create a string with code point 0x10000 encoded as a surrogate pair.
232 var s = UTF8.decode([0xf0, 0x90, 0x80, 0x80]); 232 var s = UTF8.decode([0xf0, 0x90, 0x80, 0x80]);
233 233
234 Expect.stringEquals("\u{10000}", s); 234 Expect.stringEquals("\u{10000}", s);
235 235
236 testEncodeDecode("A + B", "A%20%2B%20B"); 236 testEncodeDecode("A + B", "A%20+%20B");
237 testEncodeDecode("\uFFFE", "%EF%BF%BE"); 237 testEncodeDecode("\uFFFE", "%EF%BF%BE");
238 testEncodeDecode("\uFFFF", "%EF%BF%BF"); 238 testEncodeDecode("\uFFFF", "%EF%BF%BF");
239 testEncodeDecode("\uFFFE", "%EF%BF%BE"); 239 testEncodeDecode("\uFFFE", "%EF%BF%BE");
240 testEncodeDecode("\uFFFF", "%EF%BF%BF"); 240 testEncodeDecode("\uFFFF", "%EF%BF%BF");
241 testEncodeDecode("\x7f", "%7F"); 241 testEncodeDecode("\x7f", "%7F");
242 testEncodeDecode("\x80", "%C2%80"); 242 testEncodeDecode("\x80", "%C2%80");
243 testEncodeDecode("\u0800", "%E0%A0%80"); 243 testEncodeDecode("\u0800", "%E0%A0%80");
244 testEncodeDecode(":/@',;?&=+\$", ":/@',;?&=%2B\$"); 244 // All characters not escaped by encodeFull.
245 var unescapedFull =
246 r"abcdefghijklmnopqrstuvwxyz"
247 r"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
248 r"0123456789!#$&'()*+,-./:;=?@_~";
249 // ASCII characters escaped by encodeFull:
250 var escapedFull =
251 "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
252 "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
253 r' "%<>[\]^`{|}'
254 "\x7f";
255 var escapedTo =
256 "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F"
257 "%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F"
258 "%20%22%25%3C%3E%5B%5C%5D%5E%60%7B%7C%7D%7F";
259 testEncodeDecode(unescapedFull, unescapedFull);
260 testEncodeDecode(escapedFull, escapedTo);
261 var nonAscii =
262 "\x80-\xff-\u{100}-\u{7ff}-\u{800}-\u{ffff}-\u{10000}-\u{10ffff}";
263 var nonAsciiEncoding =
264 "%C2%80-%C3%BF-%C4%80-%DF%BF-%E0%A0%80-%EF%BF%BF-"
265 "%F0%90%80%80-%F4%8F%BF%BF";
266 testEncodeDecode(nonAscii, nonAsciiEncoding);
245 testEncodeDecode(s, "%F0%90%80%80"); 267 testEncodeDecode(s, "%F0%90%80%80");
246 testEncodeDecodeComponent("A + B", "A%20%2B%20B"); 268 testEncodeDecodeComponent("A + B", "A%20%2B%20B");
247 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); 269 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE");
248 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); 270 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF");
249 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); 271 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE");
250 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); 272 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF");
251 testEncodeDecodeComponent("\x7f", "%7F"); 273 testEncodeDecodeComponent("\x7f", "%7F");
252 testEncodeDecodeComponent("\x80", "%C2%80"); 274 testEncodeDecodeComponent("\x80", "%C2%80");
253 testEncodeDecodeComponent("\u0800", "%E0%A0%80"); 275 testEncodeDecodeComponent("\u0800", "%E0%A0%80");
254 testEncodeDecodeComponent(":/@',;?&=+\$", "%3A%2F%40'%2C%3B%3F%26%3D%2B%24"); 276 testEncodeDecodeComponent(":/@',;?&=+\$", "%3A%2F%40'%2C%3B%3F%26%3D%2B%24");
255 testEncodeDecodeComponent(s, "%F0%90%80%80"); 277 testEncodeDecodeComponent(s, "%F0%90%80%80");
256 testEncodeDecodeQueryComponent("A + B", "A+%2B+B", "A+%2B+B", "A+%2B+B"); 278 testEncodeDecodeQueryComponent("A + B", "A+%2B+B", "A+%2B+B", "A+%2B+B");
257 testEncodeDecodeQueryComponent( 279 testEncodeDecodeQueryComponent(
258 "æ ø å", "%C3%A6+%C3%B8+%C3%A5", "%E6+%F8+%E5", null); 280 "æ ø å", "%C3%A6+%C3%B8+%C3%A5", "%E6+%F8+%E5", null);
281 testEncodeDecodeComponent(nonAscii, nonAsciiEncoding);
259 282
260 // Invalid URI - : and @ is swapped, port ("host") should be numeric. 283 // Invalid URI - : and @ is swapped, port ("host") should be numeric.
261 Expect.throws( 284 Expect.throws(
262 () => Uri.parse("file://user@password:host/path"), 285 () => Uri.parse("file://user@password:host/path"),
263 (e) => e is FormatException); 286 (e) => e is FormatException);
264 } 287 }
OLDNEW
« no previous file with comments | « dart/sdk/lib/html/dart2js/html_dart2js.dart ('k') | dart/tools/VERSION » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698