Index: tests/lib/convert/base64_test.dart |
diff --git a/tests/lib/convert/base64_test.dart b/tests/lib/convert/base64_test.dart |
index c50a06ccfd7e2e72d0c8ec945b40df2171252bbe..4119625316fc606afe6bf2027a48cb060f53c25d 100644 |
--- a/tests/lib/convert/base64_test.dart |
+++ b/tests/lib/convert/base64_test.dart |
@@ -7,17 +7,15 @@ import "dart:typed_data"; |
import "package:expect/expect.dart"; |
main() { |
- for (var list in [ |
- [], |
- [0x00], |
- [0xff, 0x00], |
- [0xff, 0xaa, 0x55], |
- [0x00, 0x01, 0x02, 0x03], |
- new Iterable.generate(13).toList(), |
- new Iterable.generate(254).toList(), |
- new Iterable.generate(255).toList(), |
- new Iterable.generate(256).toList() |
- ]) { |
+ for (var list in [[], |
+ [0x00], |
+ [0xff, 0x00], |
+ [0xff, 0xaa, 0x55], |
+ [0x00, 0x01, 0x02, 0x03], |
+ new Iterable.generate(13).toList(), |
+ new Iterable.generate(254).toList(), |
+ new Iterable.generate(255).toList(), |
+ new Iterable.generate(256).toList()]) { |
testRoundtrip(list, "List#${list.length}"); |
testRoundtrip(new Uint8List.fromList(list), "Uint8List#${list.length}"); |
} |
@@ -53,9 +51,7 @@ void testRoundtrip(list, name) { |
{ |
// Using add/close |
var results; |
- var sink = new ChunkedConversionSink.withCallback((v) { |
- results = v; |
- }); |
+ var sink = new ChunkedConversionSink.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, name) { |
{ |
// Using addSlice |
var results; |
- var sink = new ChunkedConversionSink.withCallback((v) { |
- results = v; |
- }); |
+ var sink = new ChunkedConversionSink.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, name) { |
{ |
// Using add/close |
var results; |
- var sink = new ChunkedConversionSink.withCallback((v) { |
- results = v; |
- }); |
+ var sink = new ChunkedConversionSink.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, name) { |
{ |
// Using addSlice |
var results; |
- var sink = new ChunkedConversionSink.withCallback((v) { |
- results = v; |
- }); |
+ var sink = new ChunkedConversionSink.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, name) { |
{ |
// Using add/close |
var results; |
- var sink = new ChunkedConversionSink.withCallback((v) { |
- results = v; |
- }); |
+ var sink = |
+ new ChunkedConversionSink.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 |
var results; |
- var sink = new ChunkedConversionSink.withCallback((v) { |
- results = v; |
- }); |
+ var sink = |
+ new ChunkedConversionSink.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) { |
for (int i = 0; i < list.length; i++) { |
for (int j = 0; j < list.length; j++) { |