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

Unified Diff: packages/collection/test/combined_wrapper/iterable_test.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 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: packages/collection/test/combined_wrapper/iterable_test.dart
diff --git a/packages/collection/test/combined_wrapper/iterable_test.dart b/packages/collection/test/combined_wrapper/iterable_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..330182125932194b52c5b475113b51a6a14cfc4c
--- /dev/null
+++ b/packages/collection/test/combined_wrapper/iterable_test.dart
@@ -0,0 +1,60 @@
+// 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 'package:collection/collection.dart';
+import 'package:test/test.dart';
+
+void main() {
+ var iterable1 = new Iterable.generate(3);
+ var iterable2 = new Iterable.generate(3, (i) => i + 3);
+ var iterable3 = new Iterable.generate(3, (i) => i + 6);
+
+ test('should combine multiple iterables when iterating', () {
+ var combined = new CombinedIterableView([iterable1, iterable2, iterable3]);
+ expect(combined, [0, 1, 2, 3, 4, 5, 6, 7, 8]);
+ });
+
+ test('should combine multiple iterables with some empty ones', () {
+ var combined =
+ new CombinedIterableView([iterable1, [], iterable2, [], iterable3, []]);
+ expect(combined, [0, 1, 2, 3, 4, 5, 6, 7, 8]);
+ });
+
+ test('should function as an empty iterable when no iterables are passed', () {
+ var empty = new CombinedIterableView([]);
+ expect(empty, isEmpty);
+ });
+
+ test('should function as an empty iterable with all empty iterables', () {
+ var empty = new CombinedIterableView([[], [], []]);
+ expect(empty, isEmpty);
+ });
+
+ test('should reflect changes from the underlying iterables', () {
+ var list1 = [];
+ var list2 = [];
+ var combined = new CombinedIterableView([list1, list2]);
+ expect(combined, isEmpty);
+ list1.addAll([1, 2]);
+ list2.addAll([3, 4]);
+ expect(combined, [1, 2, 3, 4]);
+ expect(combined.last, 4);
+ expect(combined.first, 1);
+ });
+
+ test('should reflect changes from the iterable of iterables', () {
+ var iterables = <Iterable>[];
+ var combined = new CombinedIterableView(iterables);
+ expect(combined, isEmpty);
+ expect(combined, hasLength(0));
+
+ iterables.add(iterable1);
+ expect(combined, isNotEmpty);
+ expect(combined, hasLength(3));
+
+ iterables.clear();
+ expect(combined, isEmpty);
+ expect(combined, hasLength(0));
+ });
+}
« no previous file with comments | « packages/collection/test/canonicalized_map_test.dart ('k') | packages/collection/test/combined_wrapper/list_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698