--- jsr166/src/test/tck/ArrayDequeTest.java 2010/08/25 01:46:24 1.16 +++ jsr166/src/test/tck/ArrayDequeTest.java 2010/11/05 00:17:22 1.20 @@ -26,8 +26,8 @@ public class ArrayDequeTest extends JSR1 * Create a deque of given size containing consecutive * Integers 0 ... n. */ - private ArrayDeque populatedDeque(int n) { - ArrayDeque q = new ArrayDeque(); + private ArrayDeque populatedDeque(int n) { + ArrayDeque q = new ArrayDeque(); assertTrue(q.isEmpty()); for (int i = 0; i < n; ++i) assertTrue(q.offerLast(new Integer(i))); @@ -620,48 +620,47 @@ public class ArrayDequeTest extends JSR1 } /** - * toArray() contains all elements + * toArray() contains all elements in FIFO order */ public void testToArray() { ArrayDeque q = populatedDeque(SIZE); Object[] o = q.toArray(); - Arrays.sort(o); for (int i = 0; i < o.length; i++) - assertEquals(o[i], q.pollFirst()); + assertSame(o[i], q.pollFirst()); } /** - * toArray(a) contains all elements + * toArray(a) contains all elements in FIFO order */ public void testToArray2() { - ArrayDeque q = populatedDeque(SIZE); + ArrayDeque q = populatedDeque(SIZE); Integer[] ints = new Integer[SIZE]; - ints = (Integer[])q.toArray(ints); - Arrays.sort(ints); + Integer[] array = q.toArray(ints); + assertSame(ints, array); for (int i = 0; i < ints.length; i++) - assertEquals(ints[i], q.pollFirst()); + assertSame(ints[i], q.remove()); } /** - * toArray(null) throws NPE + * toArray(null) throws NullPointerException */ - public void testToArray_BadArg() { + public void testToArray_NullArg() { ArrayDeque l = new ArrayDeque(); l.add(new Object()); try { - Object o[] = l.toArray(null); + l.toArray(null); shouldThrow(); } catch (NullPointerException success) {} } /** - * toArray with incompatible array type throws CCE + * toArray(incompatible array type) throws ArrayStoreException */ public void testToArray1_BadArg() { ArrayDeque l = new ArrayDeque(); l.add(new Integer(5)); try { - Object o[] = l.toArray(new String[10]); + l.toArray(new String[10]); shouldThrow(); } catch (ArrayStoreException success) {} }