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

Unified Diff: packages/collection/test/combined_wrapper/map_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/map_test.dart
diff --git a/packages/collection/test/combined_wrapper/map_test.dart b/packages/collection/test/combined_wrapper/map_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..832fe364fe741ecf5dd527fc1243a00a0346a8ca
--- /dev/null
+++ b/packages/collection/test/combined_wrapper/map_test.dart
@@ -0,0 +1,55 @@
+// 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 map1 = const {1: 1, 2: 2, 3: 3};
+ var map2 = const {4: 4, 5: 5, 6: 6};
+ var map3 = const {7: 7, 8: 8, 9: 9};
+ var concat = {}..addAll(map1)..addAll(map2)..addAll(map3);
+
+ // In every way possible this should test the same as an UnmodifiableMapView.
+ common.testReadMap(
+ concat, new CombinedMapView([map1, map2, map3]), 'CombinedMapView');
+
+ common.testReadMap(
+ concat,
+ new CombinedMapView([map1, {}, map2, {}, map3, {}]),
+ 'CombinedMapView (some empty)');
+
+ test('should function as an empty map when no maps are passed', () {
+ var empty = new CombinedMapView([]);
+ expect(empty, isEmpty);
+ expect(empty.length, 0);
+ });
+
+ test('should function as an empty map when only empty maps are passed', () {
+ var empty = new CombinedMapView([{}, {}, {}]);
+ expect(empty, isEmpty);
+ expect(empty.length, 0);
+ });
+
+ test('should reflect underlying changes back to the combined map', () {
+ var backing1 = <int, int>{};
+ var backing2 = <int, int>{};
+ var combined = new CombinedMapView([backing1, backing2]);
+ expect(combined, isEmpty);
+ backing1.addAll(map1);
+ expect(combined, map1);
+ backing2.addAll(map2);
+ expect(combined, new Map.from(backing1)..addAll(backing2));
+ });
+
+ test('should reflect underlying changes with a single map', () {
+ var backing1 = <int, int>{};
+ var combined = new CombinedMapView([backing1]);
+ expect(combined, isEmpty);
+ backing1.addAll(map1);
+ expect(combined, map1);
+ });
+}
« no previous file with comments | « packages/collection/test/combined_wrapper/list_test.dart ('k') | packages/collection/test/comparators_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698