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

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

Issue 736583008: Make Utf8Decoder and Utf8Encoder's convert methods take start and end too. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add documentation for new parameters. Created 6 years, 1 month 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
« no previous file with comments | « sdk/lib/convert/utf.dart ('k') | tests/lib/convert/latin1_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/convert/ascii_test.dart
diff --git a/tests/lib/convert/ascii_test.dart b/tests/lib/convert/ascii_test.dart
index 239130f7a61d8c3c9b2509aa8db6f5c72d8b39ac..f70558e5c41ffeeb0a65c455382fd56d810140d7 100644
--- a/tests/lib/convert/ascii_test.dart
+++ b/tests/lib/convert/ascii_test.dart
@@ -54,6 +54,28 @@ void testDirectConversions() {
print(codec.encoder.convert(nonAsciiString));
}, null, nonAsciiString);
}
+
+ var encode = codec.encoder.convert;
+ 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); });
+
+ 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); });
}
var allowInvalidCodec = new AsciiCodec(allowInvalid: true);
« no previous file with comments | « sdk/lib/convert/utf.dart ('k') | tests/lib/convert/latin1_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698