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

Unified Diff: tests/lib_strong/convert/base64_test.dart

Issue 2768073002: Format all multitests (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
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 9e943273f7e150963b62d81143884713d5118158..bd932d306a4a2b80335b84bb37aa9883ef01742e 100644
--- a/tests/lib_strong/convert/base64_test.dart
+++ b/tests/lib_strong/convert/base64_test.dart
@@ -7,15 +7,17 @@ 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}");
}
@@ -51,7 +53,9 @@ 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));
@@ -63,7 +67,9 @@ 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);
@@ -75,7 +81,9 @@ 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));
@@ -87,7 +95,9 @@ 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);
@@ -105,27 +115,29 @@ 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);
}
}
}
@@ -148,6 +160,7 @@ 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);
@@ -198,7 +211,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)) {
@@ -217,7 +230,6 @@ 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++) {

Powered by Google App Engine
This is Rietveld 408576698