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

Unified Diff: tests/lib/convert/ascii_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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/convert/ascii_test.dart
diff --git a/tests/lib/convert/ascii_test.dart b/tests/lib/convert/ascii_test.dart
index f70558e5c41ffeeb0a65c455382fd56d810140d7..1f6851b7701cd4c90bd412a65e89dbd6d0ad9bd4 100644
--- a/tests/lib/convert/ascii_test.dart
+++ b/tests/lib/convert/ascii_test.dart
@@ -20,14 +20,14 @@ var nonAsciiStrings = [
void main() {
// Build longer versions of the example strings.
- for (int i = 0, n = asciiStrings.length; i < n ; i++) {
+ for (int i = 0, n = asciiStrings.length; i < n; i++) {
var string = asciiStrings[i];
while (string.length < 1024) {
string += string;
}
asciiStrings.add(string);
}
- for (int i = 0, n = nonAsciiStrings.length; i < n ; i++) {
+ for (int i = 0, n = nonAsciiStrings.length; i < n; i++) {
var string = nonAsciiStrings[i];
while (string.length < 1024) {
string += string;
@@ -59,23 +59,47 @@ void testDirectConversions() {
Expect.listEquals([0x42, 0x43, 0x44], encode("ABCDE", 1, 4));
Expect.listEquals([0x42, 0x43, 0x44, 0x45], encode("ABCDE", 1));
Expect.listEquals([0x42, 0x43, 0x44], encode("\xffBCD\xff", 1, 4));
- Expect.throws(() { encode("\xffBCD\xff", 0, 4); });
- Expect.throws(() { encode("\xffBCD\xff", 1); });
- Expect.throws(() { encode("\xffBCD\xff", 1, 5); });
- Expect.throws(() { encode("\xffBCD\xff", -1, 4); });
- Expect.throws(() { encode("\xffBCD\xff", 1, -1); });
- Expect.throws(() { encode("\xffBCD\xff", 3, 2); });
+ Expect.throws(() {
+ encode("\xffBCD\xff", 0, 4);
+ });
+ Expect.throws(() {
+ encode("\xffBCD\xff", 1);
+ });
+ Expect.throws(() {
+ encode("\xffBCD\xff", 1, 5);
+ });
+ Expect.throws(() {
+ encode("\xffBCD\xff", -1, 4);
+ });
+ Expect.throws(() {
+ encode("\xffBCD\xff", 1, -1);
+ });
+ Expect.throws(() {
+ encode("\xffBCD\xff", 3, 2);
+ });
var decode = codec.decoder.convert;
Expect.equals("BCD", decode([0x41, 0x42, 0x43, 0x44, 0x45], 1, 4));
Expect.equals("BCDE", decode([0x41, 0x42, 0x43, 0x44, 0x45], 1));
Expect.equals("BCD", decode([0xFF, 0x42, 0x43, 0x44, 0xFF], 1, 4));
- Expect.throws(() { decode([0xFF, 0x42, 0x43, 0x44, 0xFF], 0, 4); });
- Expect.throws(() { decode([0xFF, 0x42, 0x43, 0x44, 0xFF], 1); });
- Expect.throws(() { decode([0xFF, 0x42, 0x43, 0x44, 0xFF], 1, 5); });
- Expect.throws(() { decode([0xFF, 0x42, 0x43, 0x44, 0xFF], -1, 4); });
- Expect.throws(() { decode([0xFF, 0x42, 0x43, 0x44, 0xFF], 1, -1); });
- Expect.throws(() { decode([0xFF, 0x42, 0x43, 0x44, 0xFF], 3, 2); });
+ Expect.throws(() {
+ decode([0xFF, 0x42, 0x43, 0x44, 0xFF], 0, 4);
+ });
+ Expect.throws(() {
+ decode([0xFF, 0x42, 0x43, 0x44, 0xFF], 1);
+ });
+ Expect.throws(() {
+ decode([0xFF, 0x42, 0x43, 0x44, 0xFF], 1, 5);
+ });
+ Expect.throws(() {
+ decode([0xFF, 0x42, 0x43, 0x44, 0xFF], -1, 4);
+ });
+ Expect.throws(() {
+ decode([0xFF, 0x42, 0x43, 0x44, 0xFF], 1, -1);
+ });
+ Expect.throws(() {
+ decode([0xFF, 0x42, 0x43, 0x44, 0xFF], 3, 2);
+ });
}
var allowInvalidCodec = new AsciiCodec(allowInvalid: true);
@@ -88,8 +112,8 @@ void testDirectConversions() {
Expect.equals("\x00\x01\uFFFD\uFFFD\x00", decoded);
}
-List<int> encode(String str, int chunkSize,
- Converter<String, List<int>> converter) {
+List<int> encode(
+ String str, int chunkSize, Converter<String, List<int>> converter) {
List<int> bytes = <int>[];
ChunkedConversionSink byteSink =
new ByteConversionSink.withCallback(bytes.addAll);
@@ -105,11 +129,10 @@ List<int> encode(String str, int chunkSize,
return bytes;
}
-String decode(List<int> bytes, int chunkSize,
- Converter<List<int>, String> converter) {
+String decode(
+ List<int> bytes, int chunkSize, Converter<List<int>, String> converter) {
StringBuffer buf = new StringBuffer();
- var stringSink =
- new StringConversionSink.fromStringSink(buf);
+ var stringSink = new StringConversionSink.fromStringSink(buf);
var byteConversionSink = converter.startChunkedConversion(stringSink);
for (int i = 0; i < bytes.length; i += chunkSize) {
if (i + chunkSize <= bytes.length) {
@@ -124,9 +147,11 @@ String decode(List<int> bytes, int chunkSize,
void testChunkedConversions() {
// Check encoding.
- for (var converter in [ASCII.encoder,
- new AsciiCodec().encoder,
- new AsciiEncoder()]) {
+ for (var converter in [
+ ASCII.encoder,
+ new AsciiCodec().encoder,
+ new AsciiEncoder()
+ ]) {
for (int chunkSize in [1, 2, 5, 50]) {
for (var asciiString in asciiStrings) {
var units = asciiString.codeUnits.toList();
@@ -141,9 +166,11 @@ void testChunkedConversions() {
}
}
// Check decoding.
- for (var converter in [ASCII.decoder,
- new AsciiCodec().decoder,
- new AsciiDecoder()]) {
+ for (var converter in [
+ ASCII.decoder,
+ new AsciiCodec().decoder,
+ new AsciiDecoder()
+ ]) {
for (int chunkSize in [1, 2, 5, 50]) {
for (var asciiString in asciiStrings) {
var units = asciiString.codeUnits.toList();

Powered by Google App Engine
This is Rietveld 408576698