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.16 by jsr166, Sun Nov 22 18:57:17 2009 UTC vs.
Revision 1.23 by jsr166, Thu Nov 4 01:04:54 2010 UTC

# Line 12 | Line 12 | import java.util.concurrent.*;
12  
13   public class LinkedListTest extends JSR166TestCase {
14      public static void main(String[] args) {
15 <        junit.textui.TestRunner.run (suite());
15 >        junit.textui.TestRunner.run(suite());
16      }
17  
18      public static Test suite() {
# 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);
335          Integer[] ints = new Integer[SIZE];
336 <        ints = (Integer[])q.toArray(ints);
338 <        Arrays.sort(ints);
336 >        assertSame(ints, q.toArray(ints));
337          for (int i = 0; i < ints.length; i++)
338 <            assertEquals(ints[i], q.poll());
338 >            assertSame(ints[i], q.poll());
339      }
340  
341      /**
342 <     * toArray(null) throws NPE
342 >     * toArray(null) throws NullPointerException
343       */
344 <    public void testToArray_BadArg() {
344 >    public void testToArray_NullArg() {
345          LinkedList l = new LinkedList();
346          l.add(new Object());
347          try {
348 <            Object o[] = l.toArray(null);
348 >            l.toArray(null);
349              shouldThrow();
350          } catch (NullPointerException success) {}
351      }
352  
353      /**
354 <     * toArray with incompatable aray type throws CCE
354 >     * toArray(incompatible array type) throws ArrayStoreException
355       */
356      public void testToArray1_BadArg() {
357          LinkedList l = new LinkedList();
358          l.add(new Integer(5));
359          try {
360 <            Object o[] = l.toArray(new String[10]);
360 >            l.toArray(new String[10]);
361              shouldThrow();
362          } catch (ArrayStoreException success) {}
363      }
364  
365      /**
366 <     *  iterator iterates through all elements
366 >     * iterator iterates through all elements
367       */
368      public void testIterator() {
369          LinkedList q = populatedQueue(SIZE);
# Line 379 | Line 377 | public class LinkedListTest extends JSR1
377      }
378  
379      /**
380 <     *  iterator ordering is FIFO
380 >     * iterator ordering is FIFO
381       */
382      public void testIteratorOrdering() {
383          final LinkedList q = new LinkedList();
# Line 397 | Line 395 | public class LinkedListTest extends JSR1
395      /**
396       * iterator.remove removes current element
397       */
398 <    public void testIteratorRemove () {
398 >    public void testIteratorRemove() {
399          final LinkedList q = new LinkedList();
400          q.add(new Integer(1));
401          q.add(new Integer(2));
# Line 412 | Line 410 | public class LinkedListTest extends JSR1
410      }
411  
412      /**
413 <     *  Descending iterator iterates through all elements
413 >     * Descending iterator iterates through all elements
414       */
415      public void testDescendingIterator() {
416          LinkedList q = populatedQueue(SIZE);
# Line 431 | Line 429 | public class LinkedListTest extends JSR1
429      }
430  
431      /**
432 <     *  Descending iterator ordering is reverse FIFO
432 >     * Descending iterator ordering is reverse FIFO
433       */
434      public void testDescendingIteratorOrdering() {
435          final LinkedList q = new LinkedList();
# Line 449 | Line 447 | public class LinkedListTest extends JSR1
447      /**
448       * descendingIterator.remove removes current element
449       */
450 <    public void testDescendingIteratorRemove () {
450 >    public void testDescendingIteratorRemove() {
451          final LinkedList q = new LinkedList();
452 <        q.add(new Integer(3));
453 <        q.add(new Integer(2));
454 <        q.add(new Integer(1));
452 >        q.add(three);
453 >        q.add(two);
454 >        q.add(one);
455          Iterator it = q.descendingIterator();
456          it.next();
457          it.remove();
458          it = q.descendingIterator();
459 <        assertEquals(it.next(), 2);
460 <        assertEquals(it.next(), 3);
459 >        assertSame(it.next(), two);
460 >        assertSame(it.next(), three);
461          assertFalse(it.hasNext());
462      }
463  
# Line 481 | Line 479 | public class LinkedListTest extends JSR1
479      public void testAddFirst() {
480          LinkedList q = populatedQueue(3);
481          q.addFirst(four);
482 <        assertEquals(four,q.peek());
482 >        assertSame(four, q.peek());
483      }
484  
485      /**
# Line 489 | Line 487 | public class LinkedListTest extends JSR1
487       */
488      public void testPush() {
489          LinkedList q = populatedQueue(3);
492        q.pollLast();
490          q.push(four);
491 <        assertEquals(four,q.peekFirst());
491 >        assertSame(four, q.peekFirst());
492      }
493  
494      /**
495 <     *  pop removes next element, or throws NSEE if empty
495 >     * pop removes next element, or throws NSEE if empty
496       */
497      public void testPop() {
498          LinkedList q = populatedQueue(SIZE);
# Line 527 | Line 524 | public class LinkedListTest extends JSR1
524      }
525  
526      /**
527 <     *  pollLast succeeds unless empty
527 >     * pollLast succeeds unless empty
528       */
529      public void testPollLast() {
530          LinkedList q = populatedQueue(SIZE);
# Line 538 | Line 535 | public class LinkedListTest extends JSR1
535      }
536  
537      /**
538 <     *  peekFirst returns next element, or null if empty
538 >     * peekFirst returns next element, or null if empty
539       */
540      public void testPeekFirst() {
541          LinkedList q = populatedQueue(SIZE);
# Line 553 | Line 550 | public class LinkedListTest extends JSR1
550  
551  
552      /**
553 <     *  peekLast returns next element, or null if empty
553 >     * peekLast returns next element, or null if empty
554       */
555      public void testPeekLast() {
556          LinkedList q = populatedQueue(SIZE);
# Line 579 | Line 576 | public class LinkedListTest extends JSR1
576      }
577  
578      /**
579 <     *  getLast returns next element, or throws NSEE if empty
579 >     * getLast returns next element, or throws NSEE if empty
580       */
581      public void testLastElement() {
582          LinkedList q = populatedQueue(SIZE);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines