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

Unified Diff: test/byte_collection_test.dart

Issue 2649233006: Add `byteCollector` stream transformer and `collectBytes` function. (Closed)
Patch Set: Address comments. Created 3 years, 11 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
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/byte_collection_test.dart
diff --git a/test/byte_collection_test.dart b/test/byte_collection_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8068542702822310fed3beedafbb27e196328226
--- /dev/null
+++ b/test/byte_collection_test.dart
@@ -0,0 +1,39 @@
+// Copyright (c) 2017, 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.
+
+import "dart:async";
+import "dart:typed_data";
+
+import "package:test/test.dart";
+import "package:async/async.dart" show byteCollector, collectBytes, Result;
+
+void main() {
+ group("collectBytes", () {
+ test("simple list and overflow", () {
+ var result = collectBytes(new Stream.fromIterable([
+ [0],
+ [1],
+ [2],
+ [256]
+ ]));
+ expect(result, completion([0, 1, 2, 0]));
+ });
+
+ test("no events", () {
+ var result = collectBytes(new Stream.fromIterable([]));
+ expect(result, completion([]));
+ });
+
+ test("empty events", () {
+ var result = collectBytes(new Stream.fromIterable([[], []]));
+ expect(result, completion([]));
+ });
+
+ test("error event", () {
+ var result = collectBytes(new Stream.fromIterable(
+ new Iterable.generate(3, (n) => n == 2 ? throw "badness" : [n])));
+ expect(result, throwsA("badness"));
+ });
+ });
+}
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698