[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.35, Sat Jan 17 22:55:06 2015 UTC revision 1.44, Wed Jan 4 06:09:58 2017 UTC
# Line 17  Line 17 
17    
18  public class LinkedListTest extends JSR166TestCase {  public class LinkedListTest extends JSR166TestCase {
19      public static void main(String[] args) {      public static void main(String[] args) {
20          junit.textui.TestRunner.run(suite());          main(suite(), args);
21      }      }
22    
23      public static Test suite() {      public static Test suite() {
24          return new TestSuite(LinkedListTest.class);          class Implementation implements CollectionImplementation {
25                public Class<?> klazz() { return LinkedList.class; }
26                public Collection emptyCollection() { return new LinkedList(); }
27                public Object makeElement(int i) { return i; }
28                public boolean isConcurrent() { return false; }
29                public boolean permitsNulls() { return true; }
30            }
31            class SubListImplementation extends Implementation {
32                public Collection emptyCollection() {
33                    return new LinkedList().subList(0, 0);
34                }
35            }
36            return newTestSuite(
37                    LinkedListTest.class,
38                    CollectionTest.testSuite(new Implementation()),
39                    CollectionTest.testSuite(new SubListImplementation()));
40      }      }
41    
42      /**      /**
43       * Returns a new queue of given size containing consecutive       * Returns a new queue of given size containing consecutive
44       * Integers 0 ... n.       * Integers 0 ... n - 1.
45       */       */
46      private LinkedList<Integer> populatedQueue(int n) {      private LinkedList<Integer> populatedQueue(int n) {
47          LinkedList<Integer> q = new LinkedList<Integer>();          LinkedList<Integer> q = new LinkedList<>();
48          assertTrue(q.isEmpty());          assertTrue(q.isEmpty());
49          for (int i = 0; i < n; ++i)          for (int i = 0; i < n; ++i)
50              assertTrue(q.offer(new Integer(i)));              assertTrue(q.offer(new Integer(i)));
51          assertFalse(q.isEmpty());          assertFalse(q.isEmpty());
52          assertEquals(n, q.size());          assertEquals(n, q.size());
53            assertEquals((Integer) 0, q.peekFirst());
54            assertEquals((Integer) (n - 1), q.peekLast());
55          return q;          return q;
56      }      }
57    
# Line 50  Line 67 
67       */       */
68      public void testConstructor3() {      public void testConstructor3() {
69          try {          try {
70              LinkedList q = new LinkedList((Collection)null);              new LinkedList((Collection)null);
71              shouldThrow();              shouldThrow();
72          } catch (NullPointerException success) {}          } catch (NullPointerException success) {}
73      }      }
# Line 102  Line 119 
119      public void testOfferNull() {      public void testOfferNull() {
120          LinkedList q = new LinkedList();          LinkedList q = new LinkedList();
121          q.offer(null);          q.offer(null);
122            assertNull(q.get(0));
123            assertTrue(q.contains(null));
124      }      }
125    
126      /**      /**
# Line 128  Line 147 
147       * addAll(null) throws NPE       * addAll(null) throws NPE
148       */       */
149      public void testAddAll1() {      public void testAddAll1() {
         try {  
150              LinkedList q = new LinkedList();              LinkedList q = new LinkedList();
151            try {
152              q.addAll(null);              q.addAll(null);
153              shouldThrow();              shouldThrow();
154          } catch (NullPointerException success) {}          } catch (NullPointerException success) {}

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.44

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8