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

Unified Diff: tests/standalone/io/string_decoder_test.dart

Issue 17573010: Add a static method decode to StringDecoder (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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
« sdk/lib/io/string_transformer.dart ('K') | « sdk/lib/io/string_transformer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/string_decoder_test.dart
diff --git a/tests/standalone/io/string_decoder_test.dart b/tests/standalone/io/string_decoder_test.dart
index df808ae33f1249be49fd3cd5ad0b730143d0fbd0..6e96000093dd01c1d5e751766b9865bd6cefa801 100644
--- a/tests/standalone/io/string_decoder_test.dart
+++ b/tests/standalone/io/string_decoder_test.dart
@@ -6,7 +6,7 @@ import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
-void test() {
+void testTransform() {
// Code point U+10FFFF is the largest code point supported by Dart.
var controller = new StreamController(sync: true);
controller.add([0xf0, 0x90, 0x80, 0x80]); // U+10000
@@ -40,6 +40,33 @@ void test() {
});
}
+void testDecode() {
+ // Code point U+10FFFF is the largest code point supported by Dart.
+ var controller = new StreamController(sync: true);
+ controller.add([0xf0, 0x90, 0x80, 0x80]); // U+10000
+ controller.add([0xf4, 0x8f, 0xbf, 0xbf]); // U+10FFFF
+ controller.add([0xf4, 0x90, 0x80, 0x80]); // U+110000
+ controller.add([0xfa, 0x80, 0x80, 0x80, 0x80]); // U+2000000
+ controller.add([0xfd, 0x80, 0x80, 0x80, 0x80, 0x80]); // U+40000000
+ controller.close();
+
+ StringDecoder.decode(controller.stream,
+ Encoding.UTF_8,
+ '?'.codeUnitAt(0)).then((decoded) {
+ Expect.equals(8, decoded.length);
+
+ var replacementChar = '?'.codeUnitAt(0);
+ Expect.equals(0xd800, decoded.codeUnitAt(0));
+ Expect.equals(0xdc00, decoded.codeUnitAt(1));
+ Expect.equals(0xdbff, decoded.codeUnitAt(2));
+ Expect.equals(0xdfff, decoded.codeUnitAt(3));
+ Expect.equals(replacementChar, decoded.codeUnitAt(4));
+ Expect.equals(replacementChar, decoded.codeUnitAt(5));
+ Expect.equals(replacementChar, decoded.codeUnitAt(6));
+ Expect.equals(replacementChar, decoded.codeUnitAt(7));
+ });
+}
+
void testInvalid() {
void invalid(var bytes, var outputLength) {
var controller = new StreamController(sync: true);
@@ -61,6 +88,7 @@ void testInvalid() {
}
void main() {
- test();
+ testTransform();
+ testDecode();
testInvalid();
}
« sdk/lib/io/string_transformer.dart ('K') | « sdk/lib/io/string_transformer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698