| Index: tests/utils/uri_test.dart
|
| ===================================================================
|
| --- tests/utils/uri_test.dart (revision 7727)
|
| +++ tests/utils/uri_test.dart (working copy)
|
| @@ -4,6 +4,7 @@
|
|
|
| #library('uriTest');
|
|
|
| +#import('../../lib/utf/utf.dart');
|
| #import('../../lib/uri/uri.dart');
|
|
|
| testUri(String uri, bool isAbsolute) {
|
| @@ -11,6 +12,20 @@
|
| Expect.stringEquals(uri, new Uri.fromString(uri).toString());
|
| }
|
|
|
| +testEncodeDecode(String orig, String encoded) {
|
| + var e = encodeUri(orig);
|
| + Expect.stringEquals(encoded, e);
|
| + var d = decodeUri(encoded);
|
| + Expect.stringEquals(orig, d);
|
| +}
|
| +
|
| +testEncodeDecodeComponent(String orig, String encoded) {
|
| + var e = encodeUriComponent(orig);
|
| + Expect.stringEquals(encoded, e);
|
| + var d = decodeUriComponent(encoded);
|
| + Expect.stringEquals(orig, d);
|
| +}
|
| +
|
| main() {
|
| testUri("http:", true);
|
| testUri("file://", true);
|
| @@ -90,4 +105,28 @@
|
| // Additional tests (not from RFC 3986).
|
| Expect.stringEquals("http://a/b/g;p/h;s",
|
| base.resolve("../g;p/h;s").toString());
|
| +
|
| + // URI encode tests
|
| + // Note: dart2js won't handle '\ud800\udc00' and frog
|
| + // won't handle '\u{10000}'. So we cons this up synthetically...
|
| + var s = decodeUtf8([0xf0, 0x90, 0x80, 0x80]);
|
| +
|
| + testEncodeDecode("\uFFFE", "%EF%BF%BE");
|
| + testEncodeDecode("\uFFFF", "%EF%BF%BF");
|
| + testEncodeDecode("\uFFFE", "%EF%BF%BE");
|
| + testEncodeDecode("\uFFFF", "%EF%BF%BF");
|
| + testEncodeDecode("\x7f", "%7F");
|
| + testEncodeDecode("\x80", "%C2%80");
|
| + testEncodeDecode("\u0800", "%E0%A0%80");
|
| + testEncodeDecode(":/@',;?&=+\$", ":/@',;?&=+\$");
|
| + testEncodeDecode(s, "%F0%90%80%80");
|
| + testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE");
|
| + testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF");
|
| + testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE");
|
| + testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF");
|
| + testEncodeDecodeComponent("\x7f", "%7F");
|
| + testEncodeDecodeComponent("\x80", "%C2%80");
|
| + testEncodeDecodeComponent("\u0800", "%E0%A0%80");
|
| + testEncodeDecodeComponent(":/@',;?&=+\$", "%3A%2F%40'%2C%3B%3F%26%3D%2B%24");
|
| + testEncodeDecodeComponent(s, "%F0%90%80%80");
|
| }
|
|
|