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

Side by Side Diff: tests/standalone/crypto/base64_test.dart

Issue 15298004: Use dart:crypto's Base64 methods in dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/websocket_impl.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6
7 part "../../../sdk/lib/io/base64.dart";
8
9 void main() {
10 String line;
11 String expected;
12
13 line =
14 "Man is distinguished, not only by his reason, but by this singular "
15 "passion from other animals, which is a lust of the mind, that by a "
16 "perseverance of delight in the continued and indefatigable generation "
17 "of knowledge, exceeds the short vehemence of any carnal pleasure.";
18 expected =
19 "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbm"
20 "x5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz\r\n"
21 "IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlci"
22 "BhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg\r\n"
23 "dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcm"
24 "FuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu\r\n"
25 "dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYX"
26 "Rpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo\r\n"
27 "ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm"
28 "5hbCBwbGVhc3VyZS4=";
29 Expect.equals(expected, _Base64._encode(line.codeUnits));
30 Expect.listEquals(line.codeUnits, _Base64._decode(expected));
31
32 line = "Simple string";
33 expected = "U2ltcGxlIHN0cmluZw==";
34 Expect.equals(expected, _Base64._encode(line.codeUnits));
35 Expect.listEquals(line.codeUnits, _Base64._decode(expected));
36
37 for (int i = 0; i < 256; i++) {
38 List<int> x = [i];
39 Expect.listEquals(x, _Base64._decode(_Base64._encode(x)));
40 }
41
42 for (int i = 0; i < 255; i++) {
43 List<int> x = [i, i + 1];
44 Expect.listEquals(x, _Base64._decode(_Base64._encode(x)));
45 }
46
47 for (int i = 0; i < 254; i++) {
48 List<int> x = [i, i + 1, i + 2];
49 Expect.listEquals(x, _Base64._decode(_Base64._encode(x)));
50 }
51
52 for (int i = 0; i < 253; i++) {
53 List<int> x = [i, i + 1, i + 2, i + 3];
54 Expect.listEquals(x, _Base64._decode(_Base64._encode(x)));
55 }
56
57 for (int i = 0; i < 252; i++) {
58 List<int> x = [i, i + 1, i + 2, i + 3, i + 4];
59 Expect.listEquals(x, _Base64._decode(_Base64._encode(x)));
60 }
61
62 for (int i = 0; i < 251; i++) {
63 List<int> x = [i, i + 1, i + 2, i + 3, i + 4, i + 5];
64 Expect.listEquals(x, _Base64._decode(_Base64._encode(x)));
65 }
66
67 for (int i = 0; i < 250; i++) {
68 List<int> x = [i, i + 1, i + 2, i + 3, i + 4, i + 5, i + 6];
69 Expect.listEquals(x, _Base64._decode(_Base64._encode(x)));
70 }
71 }
OLDNEW
« no previous file with comments | « sdk/lib/io/websocket_impl.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698