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

Side by Side 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, 4 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 unified diff | Download patch
OLDNEW
(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 'package:collection/collection.dart';
6 import 'package:test/test.dart';
7
8 import '../unmodifiable_collection_test.dart' as common;
9
10 void main() {
11 var list1 = [1, 2, 3];
12 var list2 = [4, 5, 6];
13 var list3 = [7, 8, 9];
14 var concat = []..addAll(list1)..addAll(list2)..addAll(list3);
15
16 // In every way possible this should test the same as an UnmodifiableListView.
17 common.testUnmodifiableList(
18 concat, new CombinedListView([list1, list2, list3]), 'combineLists');
19
20 common.testUnmodifiableList(concat,
21 new CombinedListView([list1, [], list2, [], list3, []]), 'combineLists');
22
23 test('should function as an empty list when no lists are passed', () {
24 var empty = new CombinedListView([]);
25 expect(empty, isEmpty);
26 expect(empty.length, 0);
27 expect(() => empty[0], throwsRangeError);
28 });
29
30 test('should function as an empty list when only empty lists are passed', () {
31 var empty = new CombinedListView([[], [], []]);
32 expect(empty, isEmpty);
33 expect(empty.length, 0);
34 expect(() => empty[0], throwsRangeError);
35 });
36
37 test('should reflect underlying changes back to the combined list', () {
38 var backing1 = <int>[];
39 var backing2 = <int>[];
40 var combined = new CombinedListView([backing1, backing2]);
41 expect(combined, isEmpty);
42 backing1.addAll(list1);
43 expect(combined, list1);
44 backing2.addAll(list2);
45 expect(combined, backing1.toList()..addAll(backing2));
46 });
47
48 test('should reflect underlying changes from the list of lists', () {
49 var listOfLists = <List<int>>[];
50 var combined = new CombinedListView(listOfLists);
51 expect(combined, isEmpty);
52 listOfLists.add(list1);
53 expect(combined, list1);
54 listOfLists.add(list2);
55 expect(combined, []..addAll(list1)..addAll(list2));
56 listOfLists.clear();
57 expect(combined, isEmpty);
58 });
59
60 test('should reflect underlying changes with a single list', () {
61 var backing1 = <int>[];
62 var combined = new CombinedListView([backing1]);
63 expect(combined, isEmpty);
64 backing1.addAll(list1);
65 expect(combined, list1);
66 });
67 }
OLDNEW
« 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