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

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

Issue 19883003: Add chunked conversion to converters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Improve some typse. Created 7 years, 5 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/chunked_conversion_utf8_test.dart
diff --git a/tests/lib/convert/utf8_test.dart b/tests/lib/convert/chunked_conversion_utf8_test.dart
similarity index 83%
copy from tests/lib/convert/utf8_test.dart
copy to tests/lib/convert/chunked_conversion_utf8_test.dart
index 4fa02970df59d891df5c7f068684261bd7ac50ed..9260f85c0dbd444ec6b280092f5269c44a04ed6e 100644
--- a/tests/lib/convert/utf8_test.dart
+++ b/tests/lib/convert/chunked_conversion_utf8_test.dart
@@ -1,4 +1,4 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -6,7 +6,15 @@ library utf8_test;
import "package:expect/expect.dart";
import 'dart:convert';
-String decode(List<int> bytes) => new Utf8Decoder().convert(bytes);
+String decode(List<int> bytes) {
+ StringBuffer buffer = new StringBuffer();
+ ChunkedConversionSink stringSink =
+ new StringConversionSink.fromStringSink(buffer);
+ var byteSink = new Utf8Decoder().startChunkedConversion(stringSink);
+ bytes.forEach((byte) { byteSink.add([byte]); });
+ byteSink.close();
+ return buffer.toString();
+}
main() {
// Google favorite: "Îñţérñåţîöñåļîžåţîờñ".
@@ -42,6 +50,4 @@ main() {
Expect.equals(string.length, 2);
Expect.equals("𐐒".length, 2);
Expect.stringEquals("𐐒", string);
-
- // TODO(ahe): Add tests of bad input.
}

Powered by Google App Engine
This is Rietveld 408576698