Index: tests/lib_strong/convert/base64_test.dart |
diff --git a/tests/lib_strong/convert/base64_test.dart b/tests/lib_strong/convert/base64_test.dart |
index bd932d306a4a2b80335b84bb37aa9883ef01742e..9e943273f7e150963b62d81143884713d5118158 100644 |
--- a/tests/lib_strong/convert/base64_test.dart |
+++ b/tests/lib_strong/convert/base64_test.dart |
@@ -7,17 +7,15 @@ import "dart:typed_data"; |
import "package:expect/expect.dart"; |
main() { |
- for (var list in [ |
- <int>[], |
- [0x00], |
- [0xff, 0x00], |
- [0xff, 0xaa, 0x55], |
- [0x00, 0x01, 0x02, 0x03], |
- new Iterable<int>.generate(13).toList(), |
- new Iterable<int>.generate(254).toList(), |
- new Iterable<int>.generate(255).toList(), |
- new Iterable<int>.generate(256).toList() |
- ]) { |
+ for (var list in [<int>[], |
+ [0x00], |
+ [0xff, 0x00], |
+ [0xff, 0xaa, 0x55], |
+ [0x00, 0x01, 0x02, 0x03], |
+ new Iterable<int>.generate(13).toList(), |
+ new Iterable<int>.generate(254).toList(), |
+ new Iterable<int>.generate(255).toList(), |
+ new Iterable<int>.generate(256).toList()]) { |
testRoundtrip(list, "List#${list.length}"); |
testRoundtrip(new Uint8List.fromList(list), "Uint8List#${list.length}"); |
} |
@@ -53,9 +51,7 @@ void testRoundtrip(List<int> list, String name) { |
{ |
// Using add/close |
var results; |
- var sink = new ChunkedConversionSink<String>.withCallback((v) { |
- results = v; |
- }); |
+ var sink = new ChunkedConversionSink<String>.withCallback((v) { results = v; }); |
var encoder = BASE64.encoder.startChunkedConversion(sink); |
encoder.add(list.sublist(0, i)); |
encoder.add(list.sublist(i, j)); |
@@ -67,9 +63,7 @@ void testRoundtrip(List<int> list, String name) { |
{ |
// Using addSlice |
var results; |
- var sink = new ChunkedConversionSink<String>.withCallback((v) { |
- results = v; |
- }); |
+ var sink = new ChunkedConversionSink<String>.withCallback((v) { results = v; }); |
var encoder = BASE64.encoder.startChunkedConversion(sink); |
encoder.addSlice(list, 0, i, false); |
encoder.addSlice(list, i, j, false); |
@@ -81,9 +75,7 @@ void testRoundtrip(List<int> list, String name) { |
{ |
// Using add/close |
var results; |
- var sink = new ChunkedConversionSink<String>.withCallback((v) { |
- results = v; |
- }); |
+ var sink = new ChunkedConversionSink<String>.withCallback((v) { results = v; }); |
var encoder = BASE64URL.encoder.startChunkedConversion(sink); |
encoder.add(list.sublist(0, i)); |
encoder.add(list.sublist(i, j)); |
@@ -95,9 +87,7 @@ void testRoundtrip(List<int> list, String name) { |
{ |
// Using addSlice |
var results; |
- var sink = new ChunkedConversionSink<String>.withCallback((v) { |
- results = v; |
- }); |
+ var sink = new ChunkedConversionSink<String>.withCallback((v) { results = v; }); |
var encoder = BASE64URL.encoder.startChunkedConversion(sink); |
encoder.addSlice(list, 0, i, false); |
encoder.addSlice(list, i, j, false); |
@@ -115,29 +105,27 @@ void testRoundtrip(List<int> list, String name) { |
{ |
// Using add/close |
List<List<int>> results; |
- var sink = new ChunkedConversionSink<List<int>>.withCallback((v) { |
- results = v; |
- }); |
+ var sink = |
+ new ChunkedConversionSink<List<int>>.withCallback((v) { results = v; }); |
var decoder = BASE64.decoder.startChunkedConversion(sink); |
decoder.add(encoded.substring(0, i)); |
decoder.add(encoded.substring(i, j)); |
decoder.add(encoded.substring(j, encoded.length)); |
decoder.close(); |
var name = "0-$i-$j-${encoded.length}: $encoded"; |
- Expect.listEquals(list, results.expand((x) => x).toList(), name); |
+ Expect.listEquals(list, results.expand((x)=>x).toList(), name); |
} |
{ |
// Using addSlice |
List<List<int>> results; |
- var sink = new ChunkedConversionSink<List<int>>.withCallback((v) { |
- results = v; |
- }); |
+ var sink = |
+ new ChunkedConversionSink<List<int>>.withCallback((v) { results = v; }); |
var decoder = BASE64.decoder.startChunkedConversion(sink); |
decoder.addSlice(encoded, 0, i, false); |
decoder.addSlice(encoded, i, j, false); |
decoder.addSlice(encoded, j, encoded.length, true); |
var name = "0-$i-$j-${encoded.length}: $encoded"; |
- Expect.listEquals(list, results.expand((x) => x).toList(), name); |
+ Expect.listEquals(list, results.expand((x)=>x).toList(), name); |
} |
} |
} |
@@ -160,7 +148,6 @@ void testErrors() { |
c.close(); |
}, isFormatException, "chunk $list"); |
} |
- |
void badDecode(String string) { |
Expect.throws(() => BASE64.decode(string), isFormatException, string); |
Expect.throws(() => BASE64URL.decode(string), isFormatException, string); |
@@ -211,7 +198,7 @@ void testErrors() { |
badDecode("AA\u{10041}="); |
var alphabet = |
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/-_"; |
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/-_"; |
var units = alphabet.codeUnits; |
for (int i = 0; i < 128; i++) { |
if (!units.contains(i)) { |
@@ -230,6 +217,7 @@ void testErrors() { |
badChunkDecode(["AA=", ""]); |
badChunkDecode(["AB==", ""]); |
+ |
badChunkEncode(List<int> list) { |
for (int i = 0; i < list.length; i++) { |
for (int j = 0; j < list.length; j++) { |