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

Side by Side Diff: pkg/barback/test/multiset_test.dart

Issue 808713003: Remove barback from the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, 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 library barback.test.multiset_test;
6
7 import 'package:barback/src/utils/multiset.dart';
8 import 'package:unittest/unittest.dart';
9
10 import 'utils.dart';
11
12 main() {
13 initConfig();
14
15 test("new Multiset() creates an empty set", () {
16 var multiSet = new Multiset();
17 expect(multiSet, isEmpty);
18 expect(multiSet.contains(1), isFalse);
19 expect(multiSet.count(1), equals(0));
20 });
21
22 test("new Multiset.from(...) constructs a set from the argument", () {
23 var multiSet = new Multiset.from([1, 2, 3, 2, 4]);
24 expect(multiSet.toList(), equals([1, 2, 2, 3, 4]));
25 expect(multiSet.contains(1), isTrue);
26 expect(multiSet.contains(5), isFalse);
27 expect(multiSet.count(1), equals(1));
28 expect(multiSet.count(2), equals(2));
29 expect(multiSet.count(5), equals(0));
30 });
31
32 test("an element can be added and removed once", () {
33 var multiSet = new Multiset();
34 expect(multiSet.contains(1), isFalse);
35 multiSet.add(1);
36 expect(multiSet.contains(1), isTrue);
37 multiSet.remove(1);
38 expect(multiSet.contains(1), isFalse);
39 });
40
41 test("a set can contain multiple copies of an element", () {
42 var multiSet = new Multiset();
43 expect(multiSet.count(1), equals(0));
44 multiSet.add(1);
45 expect(multiSet.count(1), equals(1));
46 multiSet.add(1);
47 expect(multiSet.count(1), equals(2));
48 multiSet.remove(1);
49 expect(multiSet.count(1), equals(1));
50 multiSet.remove(1);
51 expect(multiSet.count(1), equals(0));
52 });
53
54 test("remove returns false if the element wasn't in the set", () {
55 var multiSet = new Multiset();
56 expect(multiSet.remove(1), isFalse);
57 });
58
59 test("remove returns true if the element was in the set", () {
60 var multiSet = new Multiset.from([1]);
61 expect(multiSet.remove(1), isTrue);
62 });
63
64 test("remove returns true if the element was in the set even if more copies "
65 "remain", () {
66 var multiSet = new Multiset.from([1, 1, 1]);
67 expect(multiSet.remove(1), isTrue);
68 });
69
70 test("iterator orders distinct elements in insertion order", () {
71 var multiSet = new Multiset()..add(1)..add(2)..add(3)..add(4)..add(5);
72 expect(multiSet.toList(), equals([1, 2, 3, 4, 5]));
73 });
74
75 test("iterator groups multiple copies of an element together", () {
76 var multiSet = new Multiset()..add(1)..add(2)..add(1)..add(2)..add(1);
77 expect(multiSet.toList(), equals([1, 1, 1, 2, 2]));
78 });
79 }
OLDNEW
« no previous file with comments | « pkg/barback/test/logger_test.dart ('k') | pkg/barback/test/package_graph/add_remove_transform_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698