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

Unified Diff: tests/standalone/src/StringStreamTest.dart

Issue 8318009: Update the streams interfaces (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Starting implementation Created 9 years, 2 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
« runtime/bin/process.dart ('K') | « tests/standalone/src/ProcessStdoutTest.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/StringStreamTest.dart
diff --git a/tests/standalone/src/StringStreamTest.dart b/tests/standalone/src/StringStreamTest.dart
new file mode 100644
index 0000000000000000000000000000000000000000..26946a4f88bdad992e659e4b299c3e72d8454e35
--- /dev/null
+++ b/tests/standalone/src/StringStreamTest.dart
@@ -0,0 +1,56 @@
+// Copyright (c) 2011, 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.
+
+class ListInputStream implements InputStream2 {
+ List<int> read() {
+ var result = _data;
+ _data = null;
+ return result;
+ }
+
+ void set dataHandler(void callback()) {
+ _datahandler = callback;
+ }
+
+ void set closeHandler(void callback()) {
+ }
+
+ void set errorHandler(void callback(int error)) {
+ }
+
+ write(List<int> data) {
+ Expect.equals(null, _data);
+ _data = data;
+ if (_datahandler != null) {
+ _datahandler();
+ }
+ }
+
+ List<int> _data;
+ var _datahandler;
+}
+
+
+main() {
+ List<int> data = [0x01,
+ 0x7f,
+ 0xc2, 0x80,
+ 0xdf, 0xbf,
+ 0xe0, 0xa0, 0x80,
+ 0xef, 0xbf, 0xbf];
+ InputStream2 s = new ListInputStream();
+ StringInputStream stream = new StringInputStream(s);
+ void stringData() {
+ String s = stream.read();
+ Expect.equals(6, s.length);
+ Expect.equals(new String.fromCharCodes([0x01]), s[0]);
+ Expect.equals(new String.fromCharCodes([0x7f]), s[1]);
+ Expect.equals(new String.fromCharCodes([0x80]), s[2]);
+ Expect.equals(new String.fromCharCodes([0x7ff]), s[3]);
+ Expect.equals(new String.fromCharCodes([0x800]), s[4]);
+ Expect.equals(new String.fromCharCodes([0xffff]), s[5]);
+ }
+ stream.dataHandler = stringData;
+ s.write(data);
+}
« runtime/bin/process.dart ('K') | « tests/standalone/src/ProcessStdoutTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698