--- jsr166/src/test/tck/ConcurrentSkipListSetTest.java 2011/11/26 05:19:17 1.24 +++ jsr166/src/test/tck/ConcurrentSkipListSetTest.java 2014/12/31 19:05:42 1.31 @@ -4,7 +4,6 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import junit.framework.*; import java.util.Arrays; import java.util.BitSet; import java.util.Collection; @@ -17,6 +16,9 @@ import java.util.Set; import java.util.SortedSet; import java.util.concurrent.ConcurrentSkipListSet; +import junit.framework.Test; +import junit.framework.TestSuite; + public class ConcurrentSkipListSetTest extends JSR166TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(suite()); @@ -32,7 +34,7 @@ public class ConcurrentSkipListSetTest e } /** - * Create a set of given size containing consecutive + * Returns a new set of given size containing consecutive * Integers 0 ... n. */ private ConcurrentSkipListSet populatedSet(int n) { @@ -49,7 +51,7 @@ public class ConcurrentSkipListSetTest e } /** - * Create set of first 5 ints + * Returns a new set of first 5 ints. */ private ConcurrentSkipListSet set5() { ConcurrentSkipListSet q = new ConcurrentSkipListSet(); @@ -461,8 +463,7 @@ public class ConcurrentSkipListSetTest e public void testToArray2() { ConcurrentSkipListSet q = populatedSet(SIZE); Integer[] ints = new Integer[SIZE]; - Integer[] array = q.toArray(ints); - assertSame(ints, array); + assertSame(ints, q.toArray(ints)); for (int i = 0; i < ints.length; i++) assertSame(ints[i], q.pollFirst()); } @@ -532,7 +533,7 @@ public class ConcurrentSkipListSetTest e NavigableSet x = populatedSet(SIZE); NavigableSet y = serialClone(x); - assertTrue(x != y); + assertNotSame(x, y); assertEquals(x.size(), y.size()); assertEquals(x, y); assertEquals(y, x); @@ -686,6 +687,17 @@ public class ConcurrentSkipListSetTest e 0, setSize - 1, true, bs); } + /** + * addAll is idempotent + */ + public void testAddAll_idempotent() throws Exception { + Set x = populatedSet(SIZE); + Set y = new ConcurrentSkipListSet(x); + y.addAll(x); + assertEquals(x, y); + assertEquals(y, x); + } + static NavigableSet newSet(Class cl) throws Exception { NavigableSet result = (NavigableSet) cl.newInstance(); assertEquals(0, result.size()); @@ -922,7 +934,7 @@ public class ConcurrentSkipListSetTest e if (bsContainsI) size++; } - assertEquals(set.size(), size); + assertEquals(size, set.size()); // Test contents using contains elementSet iterator int size2 = 0;