59 |
|
*/ |
60 |
|
public void testConstructor2() { |
61 |
|
try { |
62 |
< |
PriorityQueue q = new PriorityQueue(0); |
62 |
> |
new PriorityQueue(0); |
63 |
|
shouldThrow(); |
64 |
|
} catch (IllegalArgumentException success) {} |
65 |
|
} |
69 |
|
*/ |
70 |
|
public void testConstructor3() { |
71 |
|
try { |
72 |
< |
PriorityQueue q = new PriorityQueue((Collection)null); |
72 |
> |
new PriorityQueue((Collection)null); |
73 |
|
shouldThrow(); |
74 |
|
} catch (NullPointerException success) {} |
75 |
|
} |
80 |
|
public void testConstructor4() { |
81 |
|
try { |
82 |
|
Integer[] ints = new Integer[SIZE]; |
83 |
< |
PriorityQueue q = new PriorityQueue(Arrays.asList(ints)); |
83 |
> |
new PriorityQueue(Arrays.asList(ints)); |
84 |
|
shouldThrow(); |
85 |
|
} catch (NullPointerException success) {} |
86 |
|
} |
93 |
|
Integer[] ints = new Integer[SIZE]; |
94 |
|
for (int i = 0; i < SIZE-1; ++i) |
95 |
|
ints[i] = new Integer(i); |
96 |
< |
PriorityQueue q = new PriorityQueue(Arrays.asList(ints)); |
96 |
> |
new PriorityQueue(Arrays.asList(ints)); |
97 |
|
shouldThrow(); |
98 |
|
} catch (NullPointerException success) {} |
99 |
|
} |
406 |
|
assertTrue(q.removeAll(p)); |
407 |
|
assertEquals(SIZE-i, q.size()); |
408 |
|
for (int j = 0; j < i; ++j) { |
409 |
< |
Integer I = (Integer)(p.remove()); |
410 |
< |
assertFalse(q.contains(I)); |
409 |
> |
Integer x = (Integer)(p.remove()); |
410 |
> |
assertFalse(q.contains(x)); |
411 |
|
} |
412 |
|
} |
413 |
|
} |
441 |
|
*/ |
442 |
|
public void testIterator() { |
443 |
|
PriorityQueue q = populatedQueue(SIZE); |
444 |
– |
int i = 0; |
444 |
|
Iterator it = q.iterator(); |
445 |
< |
while (it.hasNext()) { |
445 |
> |
int i; |
446 |
> |
for (i = 0; it.hasNext(); i++) |
447 |
|
assertTrue(q.contains(it.next())); |
448 |
– |
++i; |
449 |
– |
} |
448 |
|
assertEquals(i, SIZE); |
449 |
+ |
assertIteratorExhausted(it); |
450 |
+ |
} |
451 |
+ |
|
452 |
+ |
/** |
453 |
+ |
* iterator of empty collection has no elements |
454 |
+ |
*/ |
455 |
+ |
public void testEmptyIterator() { |
456 |
+ |
assertIteratorExhausted(new PriorityQueue().iterator()); |
457 |
|
} |
458 |
|
|
459 |
|
/** |