[cvs] / jsr166 / src / test / tck / LinkedListTest.java Repository:
ViewVC logotype

Diff of /jsr166/src/test/tck/LinkedListTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.22, Wed Nov 3 16:46:34 2010 UTC revision 1.24, Fri Nov 5 00:17:22 2010 UTC
# Line 23  Line 23 
23       * Create a queue of given size containing consecutive       * Create a queue of given size containing consecutive
24       * Integers 0 ... n.       * Integers 0 ... n.
25       */       */
26      private LinkedList populatedQueue(int n) {      private LinkedList<Integer> populatedQueue(int n) {
27          LinkedList q = new LinkedList();          LinkedList<Integer> q = new LinkedList<Integer>();
28          assertTrue(q.isEmpty());          assertTrue(q.isEmpty());
29          for (int i = 0; i < n; ++i)          for (int i = 0; i < n; ++i)
30              assertTrue(q.offer(new Integer(i)));              assertTrue(q.offer(new Integer(i)));
# Line 318  Line 318 
318      }      }
319    
320      /**      /**
321       * toArray contains all elements       * toArray contains all elements in FIFO order
322       */       */
323      public void testToArray() {      public void testToArray() {
324          LinkedList q = populatedQueue(SIZE);          LinkedList q = populatedQueue(SIZE);
325          Object[] o = q.toArray();          Object[] o = q.toArray();
         Arrays.sort(o);  
326          for (int i = 0; i < o.length; i++)          for (int i = 0; i < o.length; i++)
327              assertEquals(o[i], q.poll());              assertSame(o[i], q.poll());
328      }      }
329    
330      /**      /**
331       * toArray(a) contains all elements       * toArray(a) contains all elements in FIFO order
332       */       */
333      public void testToArray2() {      public void testToArray2() {
334          LinkedList q = populatedQueue(SIZE);          LinkedList<Integer> q = populatedQueue(SIZE);
335          Integer[] ints = new Integer[SIZE];          Integer[] ints = new Integer[SIZE];
336          ints = (Integer[])q.toArray(ints);          Integer[] array = q.toArray(ints);
337          Arrays.sort(ints);          assertSame(ints, array);
338          for (int i = 0; i < ints.length; i++)          for (int i = 0; i < ints.length; i++)
339              assertEquals(ints[i], q.poll());              assertSame(ints[i], q.poll());
340      }      }
341    
342      /**      /**

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.24

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8