| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. | 
| 4 | 4 | 
| 5 #source("../../../runtime/bin/base64.dart"); | 5 #source("../../../runtime/bin/base64.dart"); | 
| 6 | 6 | 
| 7 void main() { | 7 void main() { | 
| 8   String line; | 8   String line; | 
| 9   String expected; | 9   String expected; | 
| 10 | 10 | 
| 11   line = | 11   line = | 
| 12       "Man is distinguished, not only by his reason, but by this singular " | 12       "Man is distinguished, not only by his reason, but by this singular " | 
| 13       "passion from other animals, which is a lust of the mind, that by a " | 13       "passion from other animals, which is a lust of the mind, that by a " | 
| 14       "perseverance of delight in the continued and indefatigable generation " | 14       "perseverance of delight in the continued and indefatigable generation " | 
| 15       "of knowledge, exceeds the short vehemence of any carnal pleasure."; | 15       "of knowledge, exceeds the short vehemence of any carnal pleasure."; | 
| 16   expected = | 16   expected = | 
| 17       "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbm" | 17       "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbm" | 
| 18       "x5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz\r\n" | 18       "x5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz\r\n" | 
| 19       "IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlci" | 19       "IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlci" | 
| 20       "BhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg\r\n" | 20       "BhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg\r\n" | 
| 21       "dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcm" | 21       "dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcm" | 
| 22       "FuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu\r\n" | 22       "FuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu\r\n" | 
| 23       "dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYX" | 23       "dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYX" | 
| 24       "Rpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo\r\n" | 24       "Rpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo\r\n" | 
| 25       "ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm" | 25       "ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm" | 
| 26       "5hbCBwbGVhc3VyZS4="; | 26       "5hbCBwbGVhc3VyZS4="; | 
| 27   Expect.equals(expected, _Base64._encode(line.charCodes())); | 27   Expect.equals(expected, _Base64._encode(line.charCodes)); | 
| 28   Expect.listEquals(line.charCodes(), _Base64._decode(expected)); | 28   Expect.listEquals(line.charCodes, _Base64._decode(expected)); | 
| 29 | 29 | 
| 30   line = "Simple string"; | 30   line = "Simple string"; | 
| 31   expected = "U2ltcGxlIHN0cmluZw=="; | 31   expected = "U2ltcGxlIHN0cmluZw=="; | 
| 32   Expect.equals(expected, _Base64._encode(line.charCodes())); | 32   Expect.equals(expected, _Base64._encode(line.charCodes)); | 
| 33   Expect.listEquals(line.charCodes(), _Base64._decode(expected)); | 33   Expect.listEquals(line.charCodes, _Base64._decode(expected)); | 
| 34 | 34 | 
| 35   for (int i = 0; i < 256; i++) { | 35   for (int i = 0; i < 256; i++) { | 
| 36     List<int> x = [i]; | 36     List<int> x = [i]; | 
| 37     Expect.listEquals(x, _Base64._decode(_Base64._encode(x))); | 37     Expect.listEquals(x, _Base64._decode(_Base64._encode(x))); | 
| 38   } | 38   } | 
| 39 | 39 | 
| 40   for (int i = 0; i < 255; i++) { | 40   for (int i = 0; i < 255; i++) { | 
| 41     List<int> x = [i, i + 1]; | 41     List<int> x = [i, i + 1]; | 
| 42     Expect.listEquals(x, _Base64._decode(_Base64._encode(x))); | 42     Expect.listEquals(x, _Base64._decode(_Base64._encode(x))); | 
| 43   } | 43   } | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 60   for (int i = 0; i < 251; i++) { | 60   for (int i = 0; i < 251; i++) { | 
| 61     List<int> x = [i, i + 1, i + 2, i + 3, i + 4, i + 5]; | 61     List<int> x = [i, i + 1, i + 2, i + 3, i + 4, i + 5]; | 
| 62     Expect.listEquals(x, _Base64._decode(_Base64._encode(x))); | 62     Expect.listEquals(x, _Base64._decode(_Base64._encode(x))); | 
| 63   } | 63   } | 
| 64 | 64 | 
| 65   for (int i = 0; i < 250; i++) { | 65   for (int i = 0; i < 250; i++) { | 
| 66     List<int> x = [i, i + 1, i + 2, i + 3, i + 4, i + 5, i + 6]; | 66     List<int> x = [i, i + 1, i + 2, i + 3, i + 4, i + 5, i + 6]; | 
| 67     Expect.listEquals(x, _Base64._decode(_Base64._encode(x))); | 67     Expect.listEquals(x, _Base64._decode(_Base64._encode(x))); | 
| 68   } | 68   } | 
| 69 } | 69 } | 
| OLD | NEW | 
|---|