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.24 by jsr166, Fri Nov 5 00:17:22 2010 UTC vs.
Revision 1.30 by jsr166, Tue Feb 21 01:54:04 2012 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   * Other contributors include Andrew Wright, Jeffrey Hayes,
6   * Pat Fisher, Mike Judd.
7   */
8  
9   import junit.framework.*;
10 < import java.util.*;
11 < import java.util.concurrent.*;
10 > import java.util.Arrays;
11 > import java.util.Collection;
12 > import java.util.Iterator;
13 > import java.util.LinkedList;
14 > import java.util.NoSuchElementException;
15  
16   public class LinkedListTest extends JSR166TestCase {
17      public static void main(String[] args) {
# Line 20 | Line 23 | public class LinkedListTest extends JSR1
23      }
24  
25      /**
26 <     * Create a queue of given size containing consecutive
26 >     * Creates a queue of given size containing consecutive
27       * Integers 0 ... n.
28       */
29      private LinkedList<Integer> populatedQueue(int n) {
# Line 233 | Line 236 | public class LinkedListTest extends JSR1
236      public void testRemoveElement() {
237          LinkedList q = populatedQueue(SIZE);
238          for (int i = 1; i < SIZE; i+=2) {
239 <            assertTrue(q.remove(new Integer(i)));
239 >            assertTrue(q.contains(i));
240 >            assertTrue(q.remove((Integer)i));
241 >            assertFalse(q.contains(i));
242 >            assertTrue(q.contains(i-1));
243          }
244          for (int i = 0; i < SIZE; i+=2) {
245 <            assertTrue(q.remove(new Integer(i)));
246 <            assertFalse(q.remove(new Integer(i+1)));
245 >            assertTrue(q.contains(i));
246 >            assertTrue(q.remove((Integer)i));
247 >            assertFalse(q.contains(i));
248 >            assertFalse(q.remove((Integer)(i+1)));
249 >            assertFalse(q.contains(i+1));
250          }
251          assertTrue(q.isEmpty());
252      }
# Line 402 | Line 411 | public class LinkedListTest extends JSR1
411          q.add(new Integer(2));
412          q.add(new Integer(3));
413          Iterator it = q.iterator();
414 <        assertEquals(it.next(), 1);
414 >        assertEquals(1, it.next());
415          it.remove();
416          it = q.iterator();
417 <        assertEquals(it.next(), 2);
418 <        assertEquals(it.next(), 3);
417 >        assertEquals(2, it.next());
418 >        assertEquals(3, it.next());
419          assertFalse(it.hasNext());
420      }
421  
# Line 462 | Line 471 | public class LinkedListTest extends JSR1
471          assertFalse(it.hasNext());
472      }
473  
465
474      /**
475       * toString contains toStrings of elements
476       */
# Line 470 | Line 478 | public class LinkedListTest extends JSR1
478          LinkedList q = populatedQueue(SIZE);
479          String s = q.toString();
480          for (int i = 0; i < SIZE; ++i) {
481 <            assertTrue(s.indexOf(String.valueOf(i)) >= 0);
481 >            assertTrue(s.contains(String.valueOf(i)));
482          }
483      }
484  
# Line 549 | Line 557 | public class LinkedListTest extends JSR1
557          assertNull(q.peekFirst());
558      }
559  
552
560      /**
561       * peekLast returns next element, or null if empty
562       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines