24 |
|
private ArrayDeque populatedDeque(int n) { |
25 |
|
ArrayDeque q = new ArrayDeque(); |
26 |
|
assertTrue(q.isEmpty()); |
27 |
< |
for(int i = 0; i < n; ++i) |
27 |
> |
for (int i = 0; i < n; ++i) |
28 |
|
assertTrue(q.offerLast(new Integer(i))); |
29 |
|
assertFalse(q.isEmpty()); |
30 |
|
assertEquals(n, q.size()); |
452 |
|
ArrayDeque q = populatedDeque(SIZE); |
453 |
|
Object[] o = q.toArray(); |
454 |
|
Arrays.sort(o); |
455 |
< |
for(int i = 0; i < o.length; i++) |
455 |
> |
for (int i = 0; i < o.length; i++) |
456 |
|
assertEquals(o[i], q.pollFirst()); |
457 |
|
} |
458 |
|
|
464 |
|
Integer[] ints = new Integer[SIZE]; |
465 |
|
ints = (Integer[])q.toArray(ints); |
466 |
|
Arrays.sort(ints); |
467 |
< |
for(int i = 0; i < ints.length; i++) |
467 |
> |
for (int i = 0; i < ints.length; i++) |
468 |
|
assertEquals(ints[i], q.pollFirst()); |
469 |
|
} |
470 |
|
|
477 |
|
l.add(new Object()); |
478 |
|
Object o[] = l.toArray(null); |
479 |
|
shouldThrow(); |
480 |
< |
} catch(NullPointerException success){} |
480 |
> |
} catch (NullPointerException success){} |
481 |
|
} |
482 |
|
|
483 |
|
/** |
489 |
|
l.add(new Integer(5)); |
490 |
|
Object o[] = l.toArray(new String[10] ); |
491 |
|
shouldThrow(); |
492 |
< |
} catch(ArrayStoreException success){} |
492 |
> |
} catch (ArrayStoreException success){} |
493 |
|
} |
494 |
|
|
495 |
|
/** |
499 |
|
ArrayDeque q = populatedDeque(SIZE); |
500 |
|
int i = 0; |
501 |
|
Iterator it = q.iterator(); |
502 |
< |
while(it.hasNext()) { |
502 |
> |
while (it.hasNext()) { |
503 |
|
assertTrue(q.contains(it.next())); |
504 |
|
++i; |
505 |
|
} |
558 |
|
ArrayDeque q = populatedDeque(SIZE); |
559 |
|
int i = 0; |
560 |
|
Iterator it = q.descendingIterator(); |
561 |
< |
while(it.hasNext()) { |
561 |
> |
while (it.hasNext()) { |
562 |
|
assertTrue(q.contains(it.next())); |
563 |
|
++i; |
564 |
|
} |
566 |
|
assertFalse(it.hasNext()); |
567 |
|
try { |
568 |
|
it.next(); |
569 |
< |
} catch(NoSuchElementException success) { |
569 |
> |
} catch (NoSuchElementException success) { |
570 |
|
} |
571 |
|
} |
572 |
|
|