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 /// Tests priority queue implementations utilities. | 5 /// Tests priority queue implementations utilities. |
6 | 6 |
7 import "package:test/test.dart"; | 7 import "package:test/test.dart"; |
8 | 8 |
9 import "package:collection/priority_queue.dart"; | 9 import "package:collection/src/priority_queue.dart"; |
10 | 10 |
11 void main() { | 11 void main() { |
12 testDefault(); | 12 testDefault(); |
13 testInt(() => new HeapPriorityQueue<int>()); | 13 testInt(() => new HeapPriorityQueue<int>()); |
14 testCustom((comparator) => new HeapPriorityQueue<C>(comparator)); | 14 testCustom((comparator) => new HeapPriorityQueue<C>(comparator)); |
15 } | 15 } |
16 | 16 |
17 void testDefault() { | 17 void testDefault() { |
18 test('new PriorityQueue() returns a HeapPriorityQueue', () { | 18 test('new PriorityQueue() returns a HeapPriorityQueue', () { |
19 expect(new PriorityQueue<int>(), | 19 expect(new PriorityQueue<int>(), |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 int compareNeg(C c1, C c2) => c2.value - c1.value; | 166 int compareNeg(C c1, C c2) => c2.value - c1.value; |
167 | 167 |
168 class C implements Comparable { | 168 class C implements Comparable { |
169 final int value; | 169 final int value; |
170 const C(this.value); | 170 const C(this.value); |
171 int get hashCode => value; | 171 int get hashCode => value; |
172 bool operator==(Object other) => other is C && value == other.value; | 172 bool operator==(Object other) => other is C && value == other.value; |
173 int compareTo(C other) => value - other.value; | 173 int compareTo(C other) => value - other.value; |
174 String toString() => "C($value)"; | 174 String toString() => "C($value)"; |
175 } | 175 } |
OLD | NEW |