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

Comparing jsr166/src/test/tck/ConcurrentSkipListSetTest.java (file contents):
Revision 1.42 by jsr166, Sun May 24 01:42:14 2015 UTC vs.
Revision 1.49 by jsr166, Sun Jan 7 22:59:18 2018 UTC

# Line 35 | Line 35 | public class ConcurrentSkipListSetTest e
35  
36      /**
37       * Returns a new set of given size containing consecutive
38 <     * Integers 0 ... n.
38 >     * Integers 0 ... n - 1.
39       */
40 <    private ConcurrentSkipListSet<Integer> populatedSet(int n) {
41 <        ConcurrentSkipListSet<Integer> q =
42 <            new ConcurrentSkipListSet<Integer>();
40 >    private static ConcurrentSkipListSet<Integer> populatedSet(int n) {
41 >        ConcurrentSkipListSet<Integer> q = new ConcurrentSkipListSet<>();
42          assertTrue(q.isEmpty());
43          for (int i = n - 1; i >= 0; i -= 2)
44              assertTrue(q.add(new Integer(i)));
# Line 53 | Line 52 | public class ConcurrentSkipListSetTest e
52      /**
53       * Returns a new set of first 5 ints.
54       */
55 <    private ConcurrentSkipListSet set5() {
55 >    private static ConcurrentSkipListSet set5() {
56          ConcurrentSkipListSet q = new ConcurrentSkipListSet();
57          assertTrue(q.isEmpty());
58          q.add(one);
# Line 199 | Line 198 | public class ConcurrentSkipListSetTest e
198              q.add(new Object());
199              q.add(new Object());
200              shouldThrow();
201 <        } catch (ClassCastException success) {}
201 >        } catch (ClassCastException success) {
202 >            assertTrue(q.size() < 2);
203 >            for (int i = 0, size = q.size(); i < size; i++)
204 >                assertSame(Object.class, q.pollFirst().getClass());
205 >            assertNull(q.pollFirst());
206 >            assertTrue(q.isEmpty());
207 >            assertEquals(0, q.size());
208 >        }
209      }
210  
211      /**
# Line 519 | Line 525 | public class ConcurrentSkipListSetTest e
525      }
526  
527      /**
528 <     * A deserialized serialized set has same elements
528 >     * A cloned set equals original
529 >     */
530 >    public void testClone() {
531 >        ConcurrentSkipListSet x = populatedSet(SIZE);
532 >        ConcurrentSkipListSet y = x.clone();
533 >
534 >        assertNotSame(x, y);
535 >        assertEquals(x.size(), y.size());
536 >        assertEquals(x, y);
537 >        assertEquals(y, x);
538 >        while (!x.isEmpty()) {
539 >            assertFalse(y.isEmpty());
540 >            assertEquals(x.pollFirst(), y.pollFirst());
541 >        }
542 >        assertTrue(y.isEmpty());
543 >    }
544 >
545 >    /**
546 >     * A deserialized/reserialized set equals original
547       */
548      public void testSerialization() throws Exception {
549          NavigableSet x = populatedSet(SIZE);
# Line 691 | Line 715 | public class ConcurrentSkipListSetTest e
715      }
716  
717      static NavigableSet<Integer> newSet(Class cl) throws Exception {
718 <        NavigableSet<Integer> result = (NavigableSet<Integer>) cl.newInstance();
718 >        NavigableSet<Integer> result =
719 >            (NavigableSet<Integer>) cl.getConstructor().newInstance();
720          assertEquals(0, result.size());
721          assertFalse(result.iterator().hasNext());
722          return result;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines