OLD | NEW |
(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.queue_test; |
| 16 |
| 17 import 'dart:collection' show Queue; |
| 18 |
| 19 import 'package:quiver/collection.dart'; |
| 20 import 'package:test/test.dart'; |
| 21 |
| 22 class MyQueue extends DelegatingQueue<String> { |
| 23 final Queue<String> _delegate; |
| 24 |
| 25 MyQueue(this._delegate); |
| 26 |
| 27 Queue<String> get delegate => _delegate; |
| 28 } |
| 29 |
| 30 void main() { |
| 31 group('DelegatingQueue', () { |
| 32 DelegatingQueue<String> delegatingQueue; |
| 33 |
| 34 setUp(() { |
| 35 delegatingQueue = new MyQueue(new Queue<String>.from(['a', 'b', 'cc'])); |
| 36 }); |
| 37 |
| 38 test('add', () { |
| 39 delegatingQueue.add('d'); |
| 40 expect(delegatingQueue, equals(['a', 'b', 'cc', 'd'])); |
| 41 }); |
| 42 |
| 43 test('addAll', () { |
| 44 delegatingQueue.addAll(['d', 'e']); |
| 45 expect(delegatingQueue, equals(['a', 'b', 'cc', 'd', 'e'])); |
| 46 }); |
| 47 |
| 48 test('addFirst', () { |
| 49 delegatingQueue.addFirst('d'); |
| 50 expect(delegatingQueue, equals(['d', 'a', 'b', 'cc'])); |
| 51 }); |
| 52 |
| 53 test('addLast', () { |
| 54 delegatingQueue.addLast('d'); |
| 55 expect(delegatingQueue, equals(['a', 'b', 'cc', 'd'])); |
| 56 }); |
| 57 |
| 58 test('clear', () { |
| 59 delegatingQueue.clear(); |
| 60 expect(delegatingQueue, equals([])); |
| 61 }); |
| 62 |
| 63 test('remove', () { |
| 64 expect(delegatingQueue.remove('b'), isTrue); |
| 65 expect(delegatingQueue, equals(['a', 'cc'])); |
| 66 }); |
| 67 |
| 68 test('removeFirst', () { |
| 69 expect(delegatingQueue.removeFirst(), 'a'); |
| 70 expect(delegatingQueue, equals(['b', 'cc'])); |
| 71 }); |
| 72 |
| 73 test('removeLast', () { |
| 74 expect(delegatingQueue.removeLast(), 'cc'); |
| 75 expect(delegatingQueue, equals(['a', 'b'])); |
| 76 }); |
| 77 }); |
| 78 } |
OLD | NEW |