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

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

Issue 10456028: Add base 64 encoding to the crypto library utils. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 6 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 | « lib/crypto/crypto_vm.dart ('k') | no next file » | 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 // Library tag to allow the test to run on Dartium.
6 #library('base64_test');
7
8 #import("dart:crypto");
9
10 // Data from http://tools.ietf.org/html/rfc4648.
11 var inputs =
12 const [ '', 'f', 'fo', 'foo', 'foob', 'fooba', 'foobar' ];
13 var results =
14 const [ '', 'Zg==', 'Zm8=', 'Zm9v', 'Zm9vYg==', 'Zm9vYmE=', 'Zm9vYmFy' ];
15
16 var longLine =
17 "Man is distinguished, not only by his reason, but by this singular "
18 "passion from other animals, which is a lust of the mind, that by a "
19 "perseverance of delight in the continued and indefatigable generation "
20 "of knowledge, exceeds the short vehemence of any carnal pleasure.";
21
22 var longLineResult =
23 "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbm"
24 "x5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz\r\n"
25 "IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlci"
26 "BhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg\r\n"
27 "dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcm"
28 "FuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu\r\n"
29 "dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYX"
30 "Rpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo\r\n"
31 "ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm"
32 "5hbCBwbGVhc3VyZS4=";
33
34 var longLineResultNoBreak =
35 "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbm"
36 "x5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz"
37 "IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlci"
38 "BhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg"
39 "dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcm"
40 "FuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu"
41 "dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYX"
42 "Rpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo"
43 "ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm"
44 "5hbCBwbGVhc3VyZS4=";
45
46 void main() {
47 for (var i = 0; i < inputs.length; i++) {
48 var enc = CryptoUtils.bytesToBase64(inputs[i].charCodes());
49 Expect.equals(results[i], enc);
50 }
51 Expect.equals(CryptoUtils.bytesToBase64(longLine.charCodes(), 76),
52 longLineResult);
53 Expect.equals(CryptoUtils.bytesToBase64(longLine.charCodes()),
54 longLineResultNoBreak);
55 }
OLDNEW
« no previous file with comments | « lib/crypto/crypto_vm.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698