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

Side by Side Diff: packages/quiver/test/collection/delegates/set_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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 2013 Google Inc. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 library quiver.collection.delegates.set_test;
16
17 import 'dart:collection' show LinkedHashSet;
18
19 import 'package:quiver/collection.dart';
20 import 'package:test/test.dart';
21
22 class MySet extends DelegatingSet<String> {
23 final Set<String> _delegate;
24
25 MySet(this._delegate);
26
27 Set<String> get delegate => _delegate;
28 }
29
30 void main() {
31 group('DelegatingSet', () {
32 DelegatingSet<String> delegatingSet;
33
34 setUp(() {
35 delegatingSet =
36 new MySet(new LinkedHashSet<String>.from(['a', 'b', 'cc']));
37 });
38
39 test('add', () {
40 delegatingSet.add('d');
41 expect(delegatingSet, equals(['a', 'b', 'cc', 'd']));
42 delegatingSet.add('d');
43 expect(delegatingSet, equals(['a', 'b', 'cc', 'd']));
44 });
45
46 test('addAll', () {
47 delegatingSet.addAll(['d', 'e']);
48 expect(delegatingSet, equals(['a', 'b', 'cc', 'd', 'e']));
49 });
50
51 test('clear', () {
52 delegatingSet.clear();
53 expect(delegatingSet, equals([]));
54 });
55
56 test('containsAll', () {
57 expect(delegatingSet.containsAll(['a', 'cc']), isTrue);
58 expect(delegatingSet.containsAll(['a', 'c']), isFalse);
59 });
60
61 test('difference', () {
62 expect(delegatingSet.difference(new Set<String>.from(['a', 'cc'])),
63 equals(['b']));
64 expect(delegatingSet.difference(new Set<String>.from(['cc'])),
65 equals(['a', 'b']));
66 }, skip: "Test failing: Caught type 'LinkedHashSet<String>' is not a subtype of type 'HashSet<String>' of 'result'.");
67
68 test('intersection', () {
69 expect(delegatingSet.intersection(new Set<String>.from(['a', 'dd'])),
70 equals(['a']));
71 expect(
72 delegatingSet.intersection(new Set<String>.from(['e'])), equals([]));
73 });
74
75 test('remove', () {
76 expect(delegatingSet.remove('b'), isTrue);
77 expect(delegatingSet, equals(['a', 'cc']));
78 });
79
80 test('removeAll', () {
81 delegatingSet.removeAll(['a', 'cc']);
82 expect(delegatingSet, equals(['b']));
83 });
84
85 test('removeWhere', () {
86 delegatingSet.removeWhere((e) => e.length == 1);
87 expect(delegatingSet, equals(['cc']));
88 });
89
90 test('retainAll', () {
91 delegatingSet.retainAll(['a', 'cc', 'd']);
92 expect(delegatingSet, equals(['a', 'cc']));
93 });
94
95 test('retainWhere', () {
96 delegatingSet.retainWhere((e) => e.length == 1);
97 expect(delegatingSet, equals(['a', 'b']));
98 });
99
100 test('union', () {
101 expect(
102 delegatingSet.union(new LinkedHashSet<String>.from(['a', 'cc', 'd'])),
103 equals(['a', 'b', 'cc', 'd']));
104 });
105 });
106 }
OLDNEW
« no previous file with comments | « packages/quiver/test/collection/delegates/queue_test.dart ('k') | packages/quiver/test/collection/lru_map_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698