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.45 by jsr166, Sun Oct 16 20:44:18 2016 UTC vs.
Revision 1.50 by jsr166, Mon May 28 21:36:13 2018 UTC

# Line 37 | Line 37 | public class ConcurrentSkipListSetTest e
37       * Returns a new set of given size containing consecutive
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 202 | Line 201 | public class ConcurrentSkipListSetTest e
201          } catch (ClassCastException success) {
202              assertTrue(q.size() < 2);
203              for (int i = 0, size = q.size(); i < size; i++)
204 <                assertTrue(q.pollFirst().getClass() == Object.class);
204 >                assertSame(Object.class, q.pollFirst().getClass());
205              assertNull(q.pollFirst());
206              assertTrue(q.isEmpty());
207              assertEquals(0, q.size());
# Line 457 | Line 456 | public class ConcurrentSkipListSetTest e
456       */
457      public void testToArray() {
458          ConcurrentSkipListSet q = populatedSet(SIZE);
459 <        Object[] o = q.toArray();
460 <        for (int i = 0; i < o.length; i++)
461 <            assertSame(o[i], q.pollFirst());
459 >        Object[] a = q.toArray();
460 >        assertSame(Object[].class, a.getClass());
461 >        for (Object o : a)
462 >            assertSame(o, q.pollFirst());
463 >        assertTrue(q.isEmpty());
464      }
465  
466      /**
# Line 469 | Line 470 | public class ConcurrentSkipListSetTest e
470          ConcurrentSkipListSet<Integer> q = populatedSet(SIZE);
471          Integer[] ints = new Integer[SIZE];
472          assertSame(ints, q.toArray(ints));
473 <        for (int i = 0; i < ints.length; i++)
474 <            assertSame(ints[i], q.pollFirst());
473 >        for (Integer o : ints)
474 >            assertSame(o, q.pollFirst());
475 >        assertTrue(q.isEmpty());
476      }
477  
478      /**
# Line 526 | Line 528 | public class ConcurrentSkipListSetTest e
528      }
529  
530      /**
531 <     * A deserialized serialized set has same elements
531 >     * A cloned set equals original
532 >     */
533 >    public void testClone() {
534 >        ConcurrentSkipListSet x = populatedSet(SIZE);
535 >        ConcurrentSkipListSet y = x.clone();
536 >
537 >        assertNotSame(x, y);
538 >        assertEquals(x.size(), y.size());
539 >        assertEquals(x, y);
540 >        assertEquals(y, x);
541 >        while (!x.isEmpty()) {
542 >            assertFalse(y.isEmpty());
543 >            assertEquals(x.pollFirst(), y.pollFirst());
544 >        }
545 >        assertTrue(y.isEmpty());
546 >    }
547 >
548 >    /**
549 >     * A deserialized/reserialized set equals original
550       */
551      public void testSerialization() throws Exception {
552          NavigableSet x = populatedSet(SIZE);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines