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

Comparing jsr166/src/test/tck/LinkedListTest.java (file contents):
Revision 1.19 by jsr166, Wed Aug 25 00:07:03 2010 UTC vs.
Revision 1.24 by jsr166, Fri Nov 5 00:17:22 2010 UTC

# Line 23 | Line 23 | public class LinkedListTest extends JSR1
23       * Create a queue of given size containing consecutive
24       * Integers 0 ... n.
25       */
26 <    private LinkedList populatedQueue(int n) {
27 <        LinkedList q = new LinkedList();
26 >    private LinkedList<Integer> populatedQueue(int n) {
27 >        LinkedList<Integer> q = new LinkedList<Integer>();
28          assertTrue(q.isEmpty());
29          for (int i = 0; i < n; ++i)
30              assertTrue(q.offer(new Integer(i)));
# Line 174 | Line 174 | public class LinkedListTest extends JSR1
174      }
175  
176      /**
177 <     *  poll succeeds unless empty
177 >     * poll succeeds unless empty
178       */
179      public void testPoll() {
180          LinkedList q = populatedQueue(SIZE);
# Line 185 | Line 185 | public class LinkedListTest extends JSR1
185      }
186  
187      /**
188 <     *  peek returns next element, or null if empty
188 >     * peek returns next element, or null if empty
189       */
190      public void testPeek() {
191          LinkedList q = populatedQueue(SIZE);
# Line 214 | Line 214 | public class LinkedListTest extends JSR1
214      }
215  
216      /**
217 <     *  remove removes next element, or throws NSEE if empty
217 >     * remove removes next element, or throws NSEE if empty
218       */
219      public void testRemove() {
220          LinkedList q = populatedQueue(SIZE);
# Line 318 | Line 318 | public class LinkedListTest extends JSR1
318      }
319  
320      /**
321 <     *  toArray contains all elements
321 >     * toArray contains all elements in FIFO order
322       */
323      public void testToArray() {
324          LinkedList q = populatedQueue(SIZE);
325          Object[] o = q.toArray();
326        Arrays.sort(o);
326          for (int i = 0; i < o.length; i++)
327 <            assertEquals(o[i], q.poll());
327 >            assertSame(o[i], q.poll());
328      }
329  
330      /**
331 <     *  toArray(a) contains all elements
331 >     * toArray(a) contains all elements in FIFO order
332       */
333      public void testToArray2() {
334 <        LinkedList q = populatedQueue(SIZE);
334 >        LinkedList<Integer> q = populatedQueue(SIZE);
335          Integer[] ints = new Integer[SIZE];
336 <        ints = (Integer[])q.toArray(ints);
337 <        Arrays.sort(ints);
336 >        Integer[] array = q.toArray(ints);
337 >        assertSame(ints, array);
338          for (int i = 0; i < ints.length; i++)
339 <            assertEquals(ints[i], q.poll());
339 >            assertSame(ints[i], q.poll());
340      }
341  
342      /**
343 <     * toArray(null) throws NPE
343 >     * toArray(null) throws NullPointerException
344       */
345 <    public void testToArray_BadArg() {
345 >    public void testToArray_NullArg() {
346          LinkedList l = new LinkedList();
347          l.add(new Object());
348          try {
349 <            Object o[] = l.toArray(null);
349 >            l.toArray(null);
350              shouldThrow();
351          } catch (NullPointerException success) {}
352      }
353  
354      /**
355 <     * toArray with incompatible array type throws CCE
355 >     * toArray(incompatible array type) throws ArrayStoreException
356       */
357      public void testToArray1_BadArg() {
358          LinkedList l = new LinkedList();
359          l.add(new Integer(5));
360          try {
361 <            Object o[] = l.toArray(new String[10]);
361 >            l.toArray(new String[10]);
362              shouldThrow();
363          } catch (ArrayStoreException success) {}
364      }
365  
366      /**
367 <     *  iterator iterates through all elements
367 >     * iterator iterates through all elements
368       */
369      public void testIterator() {
370          LinkedList q = populatedQueue(SIZE);
# Line 379 | Line 378 | public class LinkedListTest extends JSR1
378      }
379  
380      /**
381 <     *  iterator ordering is FIFO
381 >     * iterator ordering is FIFO
382       */
383      public void testIteratorOrdering() {
384          final LinkedList q = new LinkedList();
# Line 412 | Line 411 | public class LinkedListTest extends JSR1
411      }
412  
413      /**
414 <     *  Descending iterator iterates through all elements
414 >     * Descending iterator iterates through all elements
415       */
416      public void testDescendingIterator() {
417          LinkedList q = populatedQueue(SIZE);
# Line 431 | Line 430 | public class LinkedListTest extends JSR1
430      }
431  
432      /**
433 <     *  Descending iterator ordering is reverse FIFO
433 >     * Descending iterator ordering is reverse FIFO
434       */
435      public void testDescendingIteratorOrdering() {
436          final LinkedList q = new LinkedList();
# Line 494 | Line 493 | public class LinkedListTest extends JSR1
493      }
494  
495      /**
496 <     *  pop removes next element, or throws NSEE if empty
496 >     * pop removes next element, or throws NSEE if empty
497       */
498      public void testPop() {
499          LinkedList q = populatedQueue(SIZE);
# Line 526 | Line 525 | public class LinkedListTest extends JSR1
525      }
526  
527      /**
528 <     *  pollLast succeeds unless empty
528 >     * pollLast succeeds unless empty
529       */
530      public void testPollLast() {
531          LinkedList q = populatedQueue(SIZE);
# Line 537 | Line 536 | public class LinkedListTest extends JSR1
536      }
537  
538      /**
539 <     *  peekFirst returns next element, or null if empty
539 >     * peekFirst returns next element, or null if empty
540       */
541      public void testPeekFirst() {
542          LinkedList q = populatedQueue(SIZE);
# Line 552 | Line 551 | public class LinkedListTest extends JSR1
551  
552  
553      /**
554 <     *  peekLast returns next element, or null if empty
554 >     * peekLast returns next element, or null if empty
555       */
556      public void testPeekLast() {
557          LinkedList q = populatedQueue(SIZE);
# Line 578 | Line 577 | public class LinkedListTest extends JSR1
577      }
578  
579      /**
580 <     *  getLast returns next element, or throws NSEE if empty
580 >     * getLast returns next element, or throws NSEE if empty
581       */
582      public void testLastElement() {
583          LinkedList q = populatedQueue(SIZE);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines