OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import "dart:async"; |
| 6 import "dart:typed_data"; |
| 7 |
| 8 import "package:test/test.dart"; |
| 9 import "package:async/async.dart" show byteCollector, collectBytes, Result; |
| 10 |
| 11 void main() { |
| 12 group("collectBytes", () { |
| 13 test("simple list and overflow", () { |
| 14 var result = collectBytes(new Stream.fromIterable([ |
| 15 [0], |
| 16 [1], |
| 17 [2], |
| 18 [256] |
| 19 ])); |
| 20 expect(result, completion([0, 1, 2, 0])); |
| 21 }); |
| 22 |
| 23 test("no events", () { |
| 24 var result = collectBytes(new Stream.fromIterable([])); |
| 25 expect(result, completion([])); |
| 26 }); |
| 27 |
| 28 test("empty events", () { |
| 29 var result = collectBytes(new Stream.fromIterable([[], []])); |
| 30 expect(result, completion([])); |
| 31 }); |
| 32 |
| 33 test("error event", () { |
| 34 var result = collectBytes(new Stream.fromIterable( |
| 35 new Iterable.generate(3, (n) => n == 2 ? throw "badness" : [n]))); |
| 36 expect(result, throwsA("badness")); |
| 37 }); |
| 38 }); |
| 39 } |
OLD | NEW |