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

Unified Diff: tests/standalone/src/crypto/Base64Test.dart

Issue 10205012: Initial web socket server implementation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from ajohnsen@ and ager@ Created 8 years, 8 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
Index: tests/standalone/src/crypto/Base64Test.dart
diff --git a/tests/standalone/src/crypto/Base64Test.dart b/tests/standalone/src/crypto/Base64Test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3385e0c35dad7e360d87718dee95942074112d62
--- /dev/null
+++ b/tests/standalone/src/crypto/Base64Test.dart
@@ -0,0 +1,69 @@
+// Copyright (c) 2012, 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.
+
+#source("../../../../runtime/bin/base64.dart");
+
+void main() {
+ String line;
+ String expected;
+
+ line =
+ "Man is distinguished, not only by his reason, but by this singular " +
+ "passion from other animals, which is a lust of the mind, that by a " +
+ "perseverance of delight in the continued and indefatigable generation " +
+ "of knowledge, exceeds the short vehemence of any carnal pleasure.";
+ expected =
+ "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbm"
+ "x5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz\r\n"
+ "IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlci"
+ "BhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg\r\n"
+ "dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcm"
+ "FuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu\r\n"
+ "dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYX"
+ "Rpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo\r\n"
+ "ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm"
+ "5hbCBwbGVhc3VyZS4=";
+ Expect.equals(expected, _Base64._encode(line.charCodes()));
+ Expect.listEquals(line.charCodes(), _Base64._decode(expected));
+
+ line = "Simple string";
+ expected = "U2ltcGxlIHN0cmluZw==";
+ Expect.equals(expected, _Base64._encode(line.charCodes()));
+ Expect.listEquals(line.charCodes(), _Base64._decode(expected));
+
+ for (int i = 0; i < 256; i++) {
+ List<int> x = [i];
+ Expect.listEquals(x, _Base64._decode(_Base64._encode(x)));
+ }
+
+ for (int i = 0; i < 255; i++) {
+ List<int> x = [i, i + 1];
+ Expect.listEquals(x, _Base64._decode(_Base64._encode(x)));
+ }
+
+ for (int i = 0; i < 254; i++) {
+ List<int> x = [i, i + 1, i + 2];
+ Expect.listEquals(x, _Base64._decode(_Base64._encode(x)));
+ }
+
+ for (int i = 0; i < 253; i++) {
+ List<int> x = [i, i + 1, i + 2, i + 3];
+ Expect.listEquals(x, _Base64._decode(_Base64._encode(x)));
+ }
+
+ for (int i = 0; i < 252; i++) {
+ List<int> x = [i, i + 1, i + 2, i + 3, i + 4];
+ Expect.listEquals(x, _Base64._decode(_Base64._encode(x)));
+ }
+
+ for (int i = 0; i < 251; i++) {
+ List<int> x = [i, i + 1, i + 2, i + 3, i + 4, i + 5];
+ Expect.listEquals(x, _Base64._decode(_Base64._encode(x)));
+ }
+
+ for (int i = 0; i < 250; i++) {
+ List<int> x = [i, i + 1, i + 2, i + 3, i + 4, i + 5, i + 6];
+ Expect.listEquals(x, _Base64._decode(_Base64._encode(x)));
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698