38 |
|
} |
39 |
|
|
40 |
|
public static void main(String[] args) { |
41 |
< |
junit.textui.TestRunner.run(suite()); |
41 |
> |
main(suite(), args); |
42 |
|
} |
43 |
|
|
44 |
|
public static Test suite() { |
116 |
|
*/ |
117 |
|
public void testConstructor5() { |
118 |
|
Integer[] ints = new Integer[SIZE]; |
119 |
< |
for (int i = 0; i < SIZE-1; ++i) |
119 |
> |
for (int i = 0; i < SIZE - 1; ++i) |
120 |
|
ints[i] = i; |
121 |
|
Collection<Integer> elements = Arrays.asList(ints); |
122 |
|
try { |
148 |
|
for (int i = 0; i < SIZE; ++i) |
149 |
|
ints[i] = new Integer(i); |
150 |
|
q.addAll(Arrays.asList(ints)); |
151 |
< |
for (int i = SIZE-1; i >= 0; --i) |
151 |
> |
for (int i = SIZE - 1; i >= 0; --i) |
152 |
|
assertEquals(ints[i], q.poll()); |
153 |
|
} |
154 |
|
|
197 |
|
* Offer of non-Comparable throws CCE |
198 |
|
*/ |
199 |
|
public void testOfferNonComparable() { |
200 |
+ |
PriorityBlockingQueue q = new PriorityBlockingQueue(1); |
201 |
|
try { |
201 |
– |
PriorityBlockingQueue q = new PriorityBlockingQueue(1); |
202 |
– |
q.offer(new Object()); |
202 |
|
q.offer(new Object()); |
203 |
|
q.offer(new Object()); |
204 |
|
shouldThrow(); |
220 |
|
* addAll(this) throws IAE |
221 |
|
*/ |
222 |
|
public void testAddAllSelf() { |
223 |
+ |
PriorityBlockingQueue q = populatedQueue(SIZE); |
224 |
|
try { |
225 |
– |
PriorityBlockingQueue q = populatedQueue(SIZE); |
225 |
|
q.addAll(q); |
226 |
|
shouldThrow(); |
227 |
|
} catch (IllegalArgumentException success) {} |
232 |
|
* possibly adding some elements |
233 |
|
*/ |
234 |
|
public void testAddAll3() { |
235 |
+ |
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); |
236 |
+ |
Integer[] ints = new Integer[SIZE]; |
237 |
+ |
for (int i = 0; i < SIZE - 1; ++i) |
238 |
+ |
ints[i] = new Integer(i); |
239 |
|
try { |
237 |
– |
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); |
238 |
– |
Integer[] ints = new Integer[SIZE]; |
239 |
– |
for (int i = 0; i < SIZE-1; ++i) |
240 |
– |
ints[i] = new Integer(i); |
240 |
|
q.addAll(Arrays.asList(ints)); |
241 |
|
shouldThrow(); |
242 |
|
} catch (NullPointerException success) {} |
248 |
|
public void testAddAll5() { |
249 |
|
Integer[] empty = new Integer[0]; |
250 |
|
Integer[] ints = new Integer[SIZE]; |
251 |
< |
for (int i = SIZE-1; i >= 0; --i) |
251 |
> |
for (int i = SIZE - 1; i >= 0; --i) |
252 |
|
ints[i] = new Integer(i); |
253 |
|
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); |
254 |
|
assertFalse(q.addAll(Arrays.asList(empty))); |
512 |
|
assertTrue(changed); |
513 |
|
|
514 |
|
assertTrue(q.containsAll(p)); |
515 |
< |
assertEquals(SIZE-i, q.size()); |
515 |
> |
assertEquals(SIZE - i, q.size()); |
516 |
|
p.remove(); |
517 |
|
} |
518 |
|
} |
525 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
526 |
|
PriorityBlockingQueue p = populatedQueue(i); |
527 |
|
assertTrue(q.removeAll(p)); |
528 |
< |
assertEquals(SIZE-i, q.size()); |
528 |
> |
assertEquals(SIZE - i, q.size()); |
529 |
|
for (int j = 0; j < i; ++j) { |
530 |
|
Integer x = (Integer)(p.remove()); |
531 |
|
assertFalse(q.contains(x)); |
689 |
|
final PriorityBlockingQueue q = populatedQueue(SIZE); |
690 |
|
Thread t = new Thread(new CheckedRunnable() { |
691 |
|
public void realRun() { |
692 |
< |
q.put(new Integer(SIZE+1)); |
692 |
> |
q.put(new Integer(SIZE + 1)); |
693 |
|
}}); |
694 |
|
|
695 |
|
t.start(); |
706 |
|
* drainTo(c, n) empties first min(n, size) elements of queue into c |
707 |
|
*/ |
708 |
|
public void testDrainToN() { |
709 |
< |
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE*2); |
709 |
> |
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE * 2); |
710 |
|
for (int i = 0; i < SIZE + 2; ++i) { |
711 |
|
for (int j = 0; j < SIZE; j++) |
712 |
|
assertTrue(q.offer(new Integer(j))); |
714 |
|
q.drainTo(l, i); |
715 |
|
int k = (i < SIZE) ? i : SIZE; |
716 |
|
assertEquals(k, l.size()); |
717 |
< |
assertEquals(SIZE-k, q.size()); |
717 |
> |
assertEquals(SIZE - k, q.size()); |
718 |
|
for (int j = 0; j < k; ++j) |
719 |
|
assertEquals(l.get(j), new Integer(j)); |
720 |
|
do {} while (q.poll() != null); |