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

Unified Diff: tests/corelib/uri_normalize_test.dart

Issue 16019002: Merge the dart:uri library into dart:core and update the Uri class (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Final cleanup Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/corelib/uri_ipv6_test.dart ('k') | tests/corelib/uri_path_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/uri_normalize_test.dart
diff --git a/tests/corelib/uri_normalize_test.dart b/tests/corelib/uri_normalize_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..91bbe10f1c1bc8b047012531a1ec4288d0240103
--- /dev/null
+++ b/tests/corelib/uri_normalize_test.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+testNormalizePath() {
+ test(String expected, String path) {
+ var uri = new Uri(path: path);
+ Expect.equals(expected, uri.path);
+ Expect.equals(expected, uri.toString());
+ }
+
+ var unreserved = "-._~0123456789"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz";
+
+ test("A", "%41");
+ test("AB", "%41%42");
+ test("%40AB", "%40%41%42");
+ test("a", "%61");
+ test("ab", "%61%62");
+ test("%60ab", "%60%61%62");
+ test(unreserved, unreserved);
+
+ var x = new StringBuffer();
+ for (int i = 32; i < 128; i++) {
+ if (unreserved.indexOf(new String.fromCharCode(i)) != -1) {
+ x.writeCharCode(i);
+ } else {
+ x.write("%");
+ x.write(i.toRadixString(16));
+ }
+ }
+ print(x.toString().toUpperCase());
+ Expect.equals(x.toString().toUpperCase(),
+ new Uri(path: x.toString()).toString().toUpperCase());
+}
+
+main() {
+ testNormalizePath();
+}
« no previous file with comments | « tests/corelib/uri_ipv6_test.dart ('k') | tests/corelib/uri_path_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698