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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines