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

Unified Diff: tests/lib/convert/latin1_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 | « tests/lib/convert/ascii_test.dart ('k') | tests/lib/convert/utf8_encode_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/convert/latin1_test.dart
diff --git a/tests/lib/convert/latin1_test.dart b/tests/lib/convert/latin1_test.dart
index 18a77978aa641a8dd6a84554ecb108341e307797..22e2950888d2cd743a60f3931d322377c0def49c 100644
--- a/tests/lib/convert/latin1_test.dart
+++ b/tests/lib/convert/latin1_test.dart
@@ -52,6 +52,28 @@ void testDirectConversions() {
print(codec.encoder.convert(nonLatin1String));
}, null, nonLatin1String);
}
+
+ var encode = codec.encoder.convert;
+ Expect.listEquals([0x42, 0xff, 0x44], encode("AB\xffDE", 1, 4));
+ Expect.listEquals([0x42, 0xff, 0x44, 0x45], encode("AB\xffDE", 1));
+ Expect.listEquals([0x42, 0xff, 0x44], encode("\u3000B\xffD\u3000", 1, 4));
+ Expect.throws(() { encode("\u3000B\xffD\u3000", 0, 4); });
+ Expect.throws(() { encode("\u3000B\xffD\u3000", 1); });
+ Expect.throws(() { encode("\u3000B\xffD\u3000", 1, 5); });
+ Expect.throws(() { encode("\u3000B\xffD\u3000", -1, 4); });
+ Expect.throws(() { encode("\u3000B\xffD\u3000", 1, -1); });
+ Expect.throws(() { encode("\u3000B\xffD\u3000", 3, 2); });
+
+ var decode = codec.decoder.convert;
+ Expect.equals("B\xffD", decode([0x41, 0x42, 0xff, 0x44, 0x45], 1, 4));
+ Expect.equals("B\xffDE", decode([0x41, 0x42, 0xff, 0x44, 0x45], 1));
+ Expect.equals("B\xffD", decode([0xFF, 0x42, 0xff, 0x44, 0xFF], 1, 4));
+ Expect.throws(() { decode([0x3000, 0x42, 0xff, 0x44, 0x3000], 0, 4); });
+ Expect.throws(() { decode([0x3000, 0x42, 0xff, 0x44, 0x3000], 1); });
+ Expect.throws(() { decode([0x3000, 0x42, 0xff, 0x44, 0x3000], 1, 5); });
+ Expect.throws(() { decode([0x3000, 0x42, 0xff, 0x44, 0x3000], -1, 4); });
+ Expect.throws(() { decode([0x3000, 0x42, 0xff, 0x44, 0x3000], 1, -1); });
+ Expect.throws(() { decode([0x3000, 0x42, 0xff, 0x44, 0x3000], 3, 2); });
}
var allowInvalidCodec = new Latin1Codec(allowInvalid: true);
« no previous file with comments | « tests/lib/convert/ascii_test.dart ('k') | tests/lib/convert/utf8_encode_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698