ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ConcurrentLinkedDequeTest.java
(Generate patch)

Comparing jsr166/src/test/tck/ConcurrentLinkedDequeTest.java (file contents):
Revision 1.1 by jsr166, Wed Aug 25 21:40:03 2010 UTC vs.
Revision 1.5 by jsr166, Fri Nov 5 00:17:22 2010 UTC

# Line 25 | Line 25 | public class ConcurrentLinkedDequeTest e
25       * Create a deque of given size containing consecutive
26       * Integers 0 ... n.
27       */
28 <    private ConcurrentLinkedDeque populatedDeque(int n) {
29 <        ConcurrentLinkedDeque q = new ConcurrentLinkedDeque();
28 >    private ConcurrentLinkedDeque<Integer> populatedDeque(int n) {
29 >        ConcurrentLinkedDeque<Integer> q = new ConcurrentLinkedDeque<Integer>();
30          assertTrue(q.isEmpty());
31          for (int i = 0; i < n; ++i)
32              assertTrue(q.offer(new Integer(i)));
# Line 635 | Line 635 | public class ConcurrentLinkedDequeTest e
635      }
636  
637      /**
638 <     * toArray() contains all elements
638 >     * toArray() contains all elements in FIFO order
639       */
640      public void testToArray() {
641          ConcurrentLinkedDeque q = populatedDeque(SIZE);
642          Object[] o = q.toArray();
643        Arrays.sort(o);
643          for (int i = 0; i < o.length; i++)
644 <            assertEquals(o[i], q.poll());
644 >            assertSame(o[i], q.poll());
645      }
646  
647      /**
648 <     * toArray(a) contains all elements
648 >     * toArray(a) contains all elements in FIFO order
649       */
650      public void testToArray2() {
651 <        ConcurrentLinkedDeque q = populatedDeque(SIZE);
651 >        ConcurrentLinkedDeque<Integer> q = populatedDeque(SIZE);
652          Integer[] ints = new Integer[SIZE];
653 <        ints = (Integer[])q.toArray(ints);
654 <        Arrays.sort(ints);
653 >        Integer[] array = q.toArray(ints);
654 >        assertSame(ints, array);
655          for (int i = 0; i < ints.length; i++)
656 <            assertEquals(ints[i], q.poll());
656 >            assertSame(ints[i], q.poll());
657      }
658  
659      /**
660 <     * toArray(null) throws NPE
660 >     * toArray(null) throws NullPointerException
661       */
662 <    public void testToArray_BadArg() {
662 >    public void testToArray_NullArg() {
663          ConcurrentLinkedDeque q = populatedDeque(SIZE);
664          try {
665 <            Object o[] = q.toArray(null);
665 >            q.toArray(null);
666              shouldThrow();
667          } catch (NullPointerException success) {}
668      }
669  
670      /**
671 <     * toArray() with incompatible array type throws ArrayStoreException
671 >     * toArray(incompatible array type) throws ArrayStoreException
672       */
673      public void testToArray1_BadArg() {
674          ConcurrentLinkedDeque q = populatedDeque(SIZE);
675          try {
676 <            Object o[] = q.toArray(new String[10]);
676 >            q.toArray(new String[10]);
677              shouldThrow();
678          } catch (ArrayStoreException success) {}
679      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines