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

Unified Diff: packages/collection/test/combined_wrapper/list_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/list_test.dart
diff --git a/packages/collection/test/combined_wrapper/list_test.dart b/packages/collection/test/combined_wrapper/list_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1a00f32421aab770eba53f07ca5ae82f0b8f694e
--- /dev/null
+++ b/packages/collection/test/combined_wrapper/list_test.dart
@@ -0,0 +1,67 @@
+// 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';
+
+import '../unmodifiable_collection_test.dart' as common;
+
+void main() {
+ var list1 = [1, 2, 3];
+ var list2 = [4, 5, 6];
+ var list3 = [7, 8, 9];
+ var concat = []..addAll(list1)..addAll(list2)..addAll(list3);
+
+ // In every way possible this should test the same as an UnmodifiableListView.
+ common.testUnmodifiableList(
+ concat, new CombinedListView([list1, list2, list3]), 'combineLists');
+
+ common.testUnmodifiableList(concat,
+ new CombinedListView([list1, [], list2, [], list3, []]), 'combineLists');
+
+ test('should function as an empty list when no lists are passed', () {
+ var empty = new CombinedListView([]);
+ expect(empty, isEmpty);
+ expect(empty.length, 0);
+ expect(() => empty[0], throwsRangeError);
+ });
+
+ test('should function as an empty list when only empty lists are passed', () {
+ var empty = new CombinedListView([[], [], []]);
+ expect(empty, isEmpty);
+ expect(empty.length, 0);
+ expect(() => empty[0], throwsRangeError);
+ });
+
+ test('should reflect underlying changes back to the combined list', () {
+ var backing1 = <int>[];
+ var backing2 = <int>[];
+ var combined = new CombinedListView([backing1, backing2]);
+ expect(combined, isEmpty);
+ backing1.addAll(list1);
+ expect(combined, list1);
+ backing2.addAll(list2);
+ expect(combined, backing1.toList()..addAll(backing2));
+ });
+
+ test('should reflect underlying changes from the list of lists', () {
+ var listOfLists = <List<int>>[];
+ var combined = new CombinedListView(listOfLists);
+ expect(combined, isEmpty);
+ listOfLists.add(list1);
+ expect(combined, list1);
+ listOfLists.add(list2);
+ expect(combined, []..addAll(list1)..addAll(list2));
+ listOfLists.clear();
+ expect(combined, isEmpty);
+ });
+
+ test('should reflect underlying changes with a single list', () {
+ var backing1 = <int>[];
+ var combined = new CombinedListView([backing1]);
+ expect(combined, isEmpty);
+ backing1.addAll(list1);
+ expect(combined, list1);
+ });
+}
« no previous file with comments | « packages/collection/test/combined_wrapper/iterable_test.dart ('k') | packages/collection/test/combined_wrapper/map_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698