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

Comparing jsr166/src/test/tck/CopyOnWriteArrayListTest.java (file contents):
Revision 1.33 by jsr166, Fri Feb 27 19:28:23 2015 UTC vs.
Revision 1.37 by jsr166, Tue May 26 19:22:09 2015 UTC

# Line 23 | Line 23 | import junit.framework.TestSuite;
23   public class CopyOnWriteArrayListTest extends JSR166TestCase {
24  
25      public static void main(String[] args) {
26 <        junit.textui.TestRunner.run(suite());
26 >        main(suite(), args);
27      }
28  
29      public static Test suite() {
# Line 63 | Line 63 | public class CopyOnWriteArrayListTest ex
63       */
64      public void testConstructor2() {
65          Integer[] ints = new Integer[SIZE];
66 <        for (int i = 0; i < SIZE-1; ++i)
66 >        for (int i = 0; i < SIZE - 1; ++i)
67              ints[i] = new Integer(i);
68          CopyOnWriteArrayList a = new CopyOnWriteArrayList(ints);
69          for (int i = 0; i < SIZE; ++i)
# Line 75 | Line 75 | public class CopyOnWriteArrayListTest ex
75       */
76      public void testConstructor3() {
77          Integer[] ints = new Integer[SIZE];
78 <        for (int i = 0; i < SIZE-1; ++i)
78 >        for (int i = 0; i < SIZE - 1; ++i)
79              ints[i] = new Integer(i);
80          CopyOnWriteArrayList a = new CopyOnWriteArrayList(Arrays.asList(ints));
81          for (int i = 0; i < SIZE; ++i)
# Line 177 | Line 177 | public class CopyOnWriteArrayListTest ex
177          CopyOnWriteArrayList b = populatedArray(3);
178          assertTrue(a.equals(b));
179          assertTrue(b.equals(a));
180 +        assertTrue(a.containsAll(b));
181 +        assertTrue(b.containsAll(a));
182          assertEquals(a.hashCode(), b.hashCode());
183          a.add(m1);
184          assertFalse(a.equals(b));
185          assertFalse(b.equals(a));
186 +        assertTrue(a.containsAll(b));
187 +        assertFalse(b.containsAll(a));
188          b.add(m1);
189          assertTrue(a.equals(b));
190          assertTrue(b.equals(a));
191 +        assertTrue(a.containsAll(b));
192 +        assertTrue(b.containsAll(a));
193          assertEquals(a.hashCode(), b.hashCode());
194 +
195 +        assertFalse(a.equals(null));
196      }
197  
198      /**
199 <     * containsAll returns true for collection with subset of elements
199 >     * containsAll returns true for collections with subset of elements
200       */
201      public void testContainsAll() {
202          CopyOnWriteArrayList full = populatedArray(3);
# Line 197 | Line 205 | public class CopyOnWriteArrayListTest ex
205          assertTrue(full.containsAll(Arrays.asList(one, two)));
206          assertFalse(full.containsAll(Arrays.asList(one, two, six)));
207          assertFalse(full.containsAll(Arrays.asList(six)));
208 +
209 +        try {
210 +            full.containsAll(null);
211 +            shouldThrow();
212 +        } catch (NullPointerException success) {}
213      }
214  
215      /**
# Line 338 | Line 351 | public class CopyOnWriteArrayListTest ex
351          ListIterator i = full.listIterator(1);
352          int j;
353          for (j = 0; i.hasNext(); j++)
354 <            assertEquals(j+1, i.next());
354 >            assertEquals(j + 1, i.next());
355          assertEquals(2, j);
356      }
357  
# Line 437 | Line 450 | public class CopyOnWriteArrayListTest ex
450          a = new Integer[0];
451          assertSame(a, empty.toArray(a));
452  
453 <        a = new Integer[SIZE/2];
453 >        a = new Integer[SIZE / 2];
454          Arrays.fill(a, 42);
455          assertSame(a, empty.toArray(a));
456          assertNull(a[0]);
# Line 461 | Line 474 | public class CopyOnWriteArrayListTest ex
474          assertSame(a, full.toArray(a));
475          assertTrue(Arrays.equals(elements, a));
476  
477 <        a = new Integer[2*SIZE];
477 >        a = new Integer[2 * SIZE];
478          Arrays.fill(a, 42);
479          assertSame(a, full.toArray(a));
480          assertTrue(Arrays.equals(elements, Arrays.copyOf(a, SIZE)));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines