| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 queue.test; | 5 library queue.test; |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 abstract class QueueTest { | 10 abstract class QueueTest { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 Expect.equals(255, queue.removeFirst()); | 117 Expect.equals(255, queue.removeFirst()); |
| 118 Expect.isTrue(queue.isEmpty); | 118 Expect.isTrue(queue.isEmpty); |
| 119 | 119 |
| 120 testAddAll(); | 120 testAddAll(); |
| 121 testLengthChanges(); | 121 testLengthChanges(); |
| 122 testLarge(); | 122 testLarge(); |
| 123 testFromListToList(); | 123 testFromListToList(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void checkQueue(Queue queue, int expectedSize, int expectedSum) { | 126 void checkQueue(Queue queue, int expectedSize, int expectedSum) { |
| 127 Expect.equals(expectedSize, queue.length); | 127 testLength(expectedSize, queue); |
| 128 int sum = 0; | 128 int sum = 0; |
| 129 void sumElements(int value) { | 129 void sumElements(int value) { |
| 130 sum += value; | 130 sum += value; |
| 131 } | 131 } |
| 132 queue.forEach(sumElements); | 132 queue.forEach(sumElements); |
| 133 Expect.equals(expectedSum, sum); | 133 Expect.equals(expectedSum, sum); |
| 134 } | 134 } |
| 135 | 135 |
| 136 testLength(int length, Queue queue) { | 136 testLength(int length, Queue queue) { |
| 137 Expect.equals(length, queue.length); | 137 Expect.equals(length, queue.length); |
| 138 ((length == 0) ? Expect.isTrue : Expect.isFalse)(queue.isEmpty); | 138 ((length == 0) ? Expect.isTrue : Expect.isFalse)(queue.isEmpty); |
| 139 ((length != 0) ? Expect.isTrue : Expect.isFalse)(queue.isNotEmpty); |
| 139 } | 140 } |
| 140 | 141 |
| 141 void testAddAll() { | 142 void testAddAll() { |
| 142 Set<int> set = new Set<int>.from([1, 2, 4]); | 143 Set<int> set = new Set<int>.from([1, 2, 4]); |
| 143 Expect.equals(3, set.length); | 144 Expect.equals(3, set.length); |
| 144 | 145 |
| 145 Queue queue1 = newQueueFrom(set); | 146 Queue queue1 = newQueueFrom(set); |
| 146 Queue queue2 = newQueue(); | 147 Queue queue2 = newQueue(); |
| 147 Queue queue3 = newQueue(); | 148 Queue queue3 = newQueue(); |
| 148 testLength(3, queue1); | 149 testLength(3, queue1); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } | 401 } |
| 401 Expect.equals(null, entry2); | 402 Expect.equals(null, entry2); |
| 402 } | 403 } |
| 403 } | 404 } |
| 404 | 405 |
| 405 | 406 |
| 406 main() { | 407 main() { |
| 407 new DoubleLinkedQueueTest().testMain(); | 408 new DoubleLinkedQueueTest().testMain(); |
| 408 new ListQueueTest().testMain(); | 409 new ListQueueTest().testMain(); |
| 409 } | 410 } |
| OLD | NEW |