OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library barback.test.multiset_test; | 5 library barback.test.multiset_test; |
6 | 6 |
7 import 'package:barback/src/utils/multiset.dart'; | 7 import 'package:barback/src/utils/multiset.dart'; |
8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
9 | 9 |
10 import 'utils.dart'; | 10 import 'utils.dart'; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 test("remove returns false if the element wasn't in the set", () { | 54 test("remove returns false if the element wasn't in the set", () { |
55 var multiSet = new Multiset(); | 55 var multiSet = new Multiset(); |
56 expect(multiSet.remove(1), isFalse); | 56 expect(multiSet.remove(1), isFalse); |
57 }); | 57 }); |
58 | 58 |
59 test("remove returns true if the element was in the set", () { | 59 test("remove returns true if the element was in the set", () { |
60 var multiSet = new Multiset.from([1]); | 60 var multiSet = new Multiset.from([1]); |
61 expect(multiSet.remove(1), isTrue); | 61 expect(multiSet.remove(1), isTrue); |
62 }); | 62 }); |
63 | 63 |
64 test("remove returns true if the element was in the set even if more copies " | 64 test( |
| 65 "remove returns true if the element was in the set even if more copies " |
65 "remain", () { | 66 "remain", () { |
66 var multiSet = new Multiset.from([1, 1, 1]); | 67 var multiSet = new Multiset.from([1, 1, 1]); |
67 expect(multiSet.remove(1), isTrue); | 68 expect(multiSet.remove(1), isTrue); |
68 }); | 69 }); |
69 | 70 |
70 test("iterator orders distinct elements in insertion order", () { | 71 test("iterator orders distinct elements in insertion order", () { |
71 var multiSet = new Multiset()..add(1)..add(2)..add(3)..add(4)..add(5); | 72 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 expect(multiSet.toList(), equals([1, 2, 3, 4, 5])); |
73 }); | 74 }); |
74 | 75 |
75 test("iterator groups multiple copies of an element together", () { | 76 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 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 expect(multiSet.toList(), equals([1, 1, 1, 2, 2])); |
78 }); | 79 }); |
79 } | 80 } |
OLD | NEW |