500 /** |
500 /** |
501 * toArray() contains all elements in FIFO order |
501 * toArray() contains all elements in FIFO order |
502 */ |
502 */ |
503 public void testToArray() { |
503 public void testToArray() { |
504 LinkedTransferQueue q = populatedQueue(SIZE); |
504 LinkedTransferQueue q = populatedQueue(SIZE); |
505 Object[] o = q.toArray(); |
505 Object[] a = q.toArray(); |
506 for (int i = 0; i < o.length; i++) { |
506 assertSame(Object[].class, a.getClass()); |
507 assertSame(o[i], q.poll()); |
507 for (Object o : a) |
508 } |
508 assertSame(o, q.poll()); |
|
509 assertTrue(q.isEmpty()); |
509 } |
510 } |
510 |
511 |
511 /** |
512 /** |
512 * toArray(a) contains all elements in FIFO order |
513 * toArray(a) contains all elements in FIFO order |
513 */ |
514 */ |
514 public void testToArray2() { |
515 public void testToArray2() { |
515 LinkedTransferQueue<Integer> q = populatedQueue(SIZE); |
516 LinkedTransferQueue<Integer> q = populatedQueue(SIZE); |
516 Integer[] ints = new Integer[SIZE]; |
517 Integer[] ints = new Integer[SIZE]; |
517 Integer[] array = q.toArray(ints); |
518 Integer[] array = q.toArray(ints); |
518 assertSame(ints, array); |
519 assertSame(ints, array); |
519 for (int i = 0; i < ints.length; i++) { |
520 for (Integer o : ints) |
520 assertSame(ints[i], q.poll()); |
521 assertSame(o, q.poll()); |
521 } |
522 assertTrue(q.isEmpty()); |
522 } |
523 } |
523 |
524 |
524 /** |
525 /** |
525 * toArray(incompatible array type) throws ArrayStoreException |
526 * toArray(incompatible array type) throws ArrayStoreException |
526 */ |
527 */ |