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

Unified Diff: tests/corelib/uri_test.dart

Issue 94733003: Add encodimg argument to Uri.encodeQueryString (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Separate the two encodings into separate steps Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« sdk/lib/core/uri.dart ('K') | « sdk/lib/core/uri.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/uri_test.dart
diff --git a/tests/corelib/uri_test.dart b/tests/corelib/uri_test.dart
index 351c3b98d75af85df4f2db4615883fb06e31675d..3e66ac9a085b6d542d5dabcae23dd1842c43dccf 100644
--- a/tests/corelib/uri_test.dart
+++ b/tests/corelib/uri_test.dart
@@ -30,11 +30,35 @@ testEncodeDecodeComponent(String orig, String encoded) {
Expect.stringEquals(orig, d);
}
-testEncodeDecodeQueryComponent(String orig, String encoded) {
- var e = Uri.encodeQueryComponent(orig);
- Expect.stringEquals(encoded, e);
- var d = Uri.decodeQueryComponent(encoded);
+testEncodeDecodeQueryComponent(String orig,
+ String encodedUTF8,
+ String encodedLatin1,
+ String encodedAscii) {
+ var e, d;
+ e = Uri.encodeQueryComponent(orig);
+ Expect.stringEquals(encodedUTF8, e);
+ d = Uri.decodeQueryComponent(encodedUTF8);
+ Expect.stringEquals(orig, d);
+
+ e = Uri.encodeQueryComponent(orig, encoding: UTF8);
+ Expect.stringEquals(encodedUTF8, e);
+ d = Uri.decodeQueryComponent(encodedUTF8, encoding: UTF8);
Expect.stringEquals(orig, d);
+
+ e = Uri.encodeQueryComponent(orig, encoding: LATIN1);
+ Expect.stringEquals(encodedLatin1, e);
+ d = Uri.decodeQueryComponent(encodedLatin1, encoding: LATIN1);
+ Expect.stringEquals(orig, d);
+
+ if (encodedAscii != null) {
+ e = Uri.encodeQueryComponent(orig, encoding: ASCII);
+ Expect.stringEquals(encodedAscii, e);
+ d = Uri.decodeQueryComponent(encodedAscii, encoding: ASCII);
+ Expect.stringEquals(orig, d);
+ } else {
+ Expect.throws(() => Uri.encodeQueryComponent(orig, encoding: ASCII),
+ (e) => e is ArgumentError);
+ }
}
testUriPerRFCs(Uri base) {
@@ -229,5 +253,7 @@ main() {
testEncodeDecodeComponent("\u0800", "%E0%A0%80");
testEncodeDecodeComponent(":/@',;?&=+\$", "%3A%2F%40'%2C%3B%3F%26%3D%2B%24");
testEncodeDecodeComponent(s, "%F0%90%80%80");
- testEncodeDecodeQueryComponent("A + B", "A+%2B+B");
+ testEncodeDecodeQueryComponent("A + B", "A+%2B+B", "A+%2B+B", "A+%2B+B");
+ testEncodeDecodeQueryComponent(
+ "æ ø å", "%C3%A6+%C3%B8+%C3%A5", "%E6+%F8+%E5", null);
}
« sdk/lib/core/uri.dart ('K') | « sdk/lib/core/uri.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698