--- jsr166/src/test/tck/ConcurrentSkipListSetTest.java 2015/01/17 22:55:06 1.35 +++ jsr166/src/test/tck/ConcurrentSkipListSetTest.java 2015/05/24 01:23:17 1.41 @@ -21,7 +21,7 @@ import junit.framework.TestSuite; public class ConcurrentSkipListSetTest extends JSR166TestCase { public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); + main(suite(), args); } public static Test suite() { return new TestSuite(ConcurrentSkipListSetTest.class); @@ -77,7 +77,7 @@ public class ConcurrentSkipListSetTest e */ public void testConstructor3() { try { - ConcurrentSkipListSet q = new ConcurrentSkipListSet((Collection)null); + new ConcurrentSkipListSet((Collection)null); shouldThrow(); } catch (NullPointerException success) {} } @@ -87,8 +87,7 @@ public class ConcurrentSkipListSetTest e */ public void testConstructor4() { try { - Integer[] ints = new Integer[SIZE]; - ConcurrentSkipListSet q = new ConcurrentSkipListSet(Arrays.asList(ints)); + new ConcurrentSkipListSet(Arrays.asList(new Integer[SIZE])); shouldThrow(); } catch (NullPointerException success) {} } @@ -97,11 +96,11 @@ public class ConcurrentSkipListSetTest e * Initializing from Collection with some null elements throws NPE */ public void testConstructor5() { + Integer[] ints = new Integer[SIZE]; + for (int i = 0; i < SIZE - 1; ++i) + ints[i] = new Integer(i); try { - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); - ConcurrentSkipListSet q = new ConcurrentSkipListSet(Arrays.asList(ints)); + new ConcurrentSkipListSet(Arrays.asList(ints)); shouldThrow(); } catch (NullPointerException success) {} } @@ -129,7 +128,7 @@ public class ConcurrentSkipListSetTest e for (int i = 0; i < SIZE; ++i) ints[i] = new Integer(i); q.addAll(Arrays.asList(ints)); - for (int i = SIZE-1; i >= 0; --i) + for (int i = SIZE - 1; i >= 0; --i) assertEquals(ints[i], q.pollFirst()); } @@ -153,7 +152,7 @@ public class ConcurrentSkipListSetTest e public void testSize() { ConcurrentSkipListSet q = populatedSet(SIZE); for (int i = 0; i < SIZE; ++i) { - assertEquals(SIZE-i, q.size()); + assertEquals(SIZE - i, q.size()); q.pollFirst(); } for (int i = 0; i < SIZE; ++i) { @@ -166,8 +165,8 @@ public class ConcurrentSkipListSetTest e * add(null) throws NPE */ public void testAddNull() { + ConcurrentSkipListSet q = new ConcurrentSkipListSet(); try { - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); q.add(null); shouldThrow(); } catch (NullPointerException success) {} @@ -195,9 +194,8 @@ public class ConcurrentSkipListSetTest e * Add of non-Comparable throws CCE */ public void testAddNonComparable() { + ConcurrentSkipListSet q = new ConcurrentSkipListSet(); try { - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); - q.add(new Object()); q.add(new Object()); q.add(new Object()); shouldThrow(); @@ -208,8 +206,8 @@ public class ConcurrentSkipListSetTest e * addAll(null) throws NPE */ public void testAddAll1() { + ConcurrentSkipListSet q = new ConcurrentSkipListSet(); try { - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); q.addAll(null); shouldThrow(); } catch (NullPointerException success) {} @@ -219,9 +217,9 @@ public class ConcurrentSkipListSetTest e * addAll of a collection with null elements throws NPE */ public void testAddAll2() { + ConcurrentSkipListSet q = new ConcurrentSkipListSet(); + Integer[] ints = new Integer[SIZE]; try { - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); - Integer[] ints = new Integer[SIZE]; q.addAll(Arrays.asList(ints)); shouldThrow(); } catch (NullPointerException success) {} @@ -232,11 +230,11 @@ public class ConcurrentSkipListSetTest e * possibly adding some elements */ public void testAddAll3() { + ConcurrentSkipListSet q = new ConcurrentSkipListSet(); + Integer[] ints = new Integer[SIZE]; + for (int i = 0; i < SIZE - 1; ++i) + ints[i] = new Integer(i); try { - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); - Integer[] ints = new Integer[SIZE]; - for (int i = 0; i < SIZE-1; ++i) - ints[i] = new Integer(i); q.addAll(Arrays.asList(ints)); shouldThrow(); } catch (NullPointerException success) {} @@ -249,7 +247,7 @@ public class ConcurrentSkipListSetTest e Integer[] empty = new Integer[0]; Integer[] ints = new Integer[SIZE]; for (int i = 0; i < SIZE; ++i) - ints[i] = new Integer(SIZE-1-i); + ints[i] = new Integer(SIZE - 1 - i); ConcurrentSkipListSet q = new ConcurrentSkipListSet(); assertFalse(q.addAll(Arrays.asList(empty))); assertTrue(q.addAll(Arrays.asList(ints))); @@ -273,7 +271,7 @@ public class ConcurrentSkipListSetTest e */ public void testPollLast() { ConcurrentSkipListSet q = populatedSet(SIZE); - for (int i = SIZE-1; i >= 0; --i) { + for (int i = SIZE - 1; i >= 0; --i) { assertEquals(i, q.pollLast()); } assertNull(q.pollFirst()); @@ -354,7 +352,7 @@ public class ConcurrentSkipListSetTest e assertTrue(changed); assertTrue(q.containsAll(p)); - assertEquals(SIZE-i, q.size()); + assertEquals(SIZE - i, q.size()); p.pollFirst(); } } @@ -367,7 +365,7 @@ public class ConcurrentSkipListSetTest e ConcurrentSkipListSet q = populatedSet(SIZE); ConcurrentSkipListSet p = populatedSet(i); assertTrue(q.removeAll(p)); - assertEquals(SIZE-i, q.size()); + assertEquals(SIZE - i, q.size()); for (int j = 0; j < i; ++j) { Integer x = (Integer)(p.pollFirst()); assertFalse(q.contains(x)); @@ -976,7 +974,7 @@ public class ConcurrentSkipListSetTest e } static boolean eq(Integer i, int j) { - return i == null ? j == -1 : i == j; + return (i == null) ? j == -1 : i == j; } }