--- jsr166/src/test/tck/ConcurrentSkipListSubSetTest.java 2009/11/22 18:57:17 1.11 +++ jsr166/src/test/tck/ConcurrentSkipListSubSetTest.java 2010/11/05 00:17:22 1.16 @@ -11,7 +11,7 @@ import java.io.*; public class ConcurrentSkipListSubSetTest extends JSR166TestCase { public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); + junit.textui.TestRunner.run(suite()); } public static Test suite() { return new TestSuite(ConcurrentSkipListSubSetTest.class); @@ -27,8 +27,9 @@ public class ConcurrentSkipListSubSetTes * Create a set of given size containing consecutive * Integers 0 ... n. */ - private NavigableSet populatedSet(int n) { - ConcurrentSkipListSet q = new ConcurrentSkipListSet(); + private NavigableSet populatedSet(int n) { + ConcurrentSkipListSet q = + new ConcurrentSkipListSet(); assertTrue(q.isEmpty()); for (int i = n-1; i >= 0; i-=2) @@ -178,6 +179,7 @@ public class ConcurrentSkipListSubSetTes shouldThrow(); } catch (NullPointerException success) {} } + /** * addAll of a collection with null elements throws NPE */ @@ -189,6 +191,7 @@ public class ConcurrentSkipListSubSetTes shouldThrow(); } catch (NullPointerException success) {} } + /** * addAll of a collection with any null elements throws NPE after * possibly adding some elements @@ -338,7 +341,6 @@ public class ConcurrentSkipListSubSetTes Object e4 = q.lower(zero); assertNull(e4); - } /** @@ -357,7 +359,6 @@ public class ConcurrentSkipListSubSetTes Object e4 = q.higher(six); assertNull(e4); - } /** @@ -376,7 +377,6 @@ public class ConcurrentSkipListSubSetTes Object e4 = q.floor(zero); assertNull(e4); - } /** @@ -395,30 +395,28 @@ public class ConcurrentSkipListSubSetTes Object e4 = q.ceiling(six); assertNull(e4); - } /** - * toArray contains all elements + * toArray contains all elements in sorted order */ public void testToArray() { NavigableSet q = populatedSet(SIZE); Object[] o = q.toArray(); - Arrays.sort(o); for (int i = 0; i < o.length; i++) - assertEquals(o[i], q.pollFirst()); + assertSame(o[i], q.pollFirst()); } /** - * toArray(a) contains all elements + * toArray(a) contains all elements in sorted order */ public void testToArray2() { - NavigableSet q = populatedSet(SIZE); + NavigableSet q = populatedSet(SIZE); Integer[] ints = new Integer[SIZE]; - ints = (Integer[])q.toArray(ints); - Arrays.sort(ints); + Integer[] array = q.toArray(ints); + assertSame(ints, array); for (int i = 0; i < ints.length; i++) - assertEquals(ints[i], q.pollFirst()); + assertSame(ints[i], q.pollFirst()); } /** @@ -452,7 +450,7 @@ public class ConcurrentSkipListSubSetTes /** * iterator.remove removes current element */ - public void testIteratorRemove () { + public void testIteratorRemove() { final NavigableSet q = set0(); q.add(new Integer(2)); q.add(new Integer(1)); @@ -684,6 +682,7 @@ public class ConcurrentSkipListSubSetTes shouldThrow(); } catch (NullPointerException success) {} } + /** * addAll of a collection with null elements throws NPE */ @@ -695,6 +694,7 @@ public class ConcurrentSkipListSubSetTes shouldThrow(); } catch (NullPointerException success) {} } + /** * addAll of a collection with any null elements throws NPE after * possibly adding some elements @@ -844,7 +844,6 @@ public class ConcurrentSkipListSubSetTes Object e4 = q.lower(zero); assertNull(e4); - } /** @@ -863,7 +862,6 @@ public class ConcurrentSkipListSubSetTes Object e4 = q.higher(m6); assertNull(e4); - } /** @@ -882,7 +880,6 @@ public class ConcurrentSkipListSubSetTes Object e4 = q.floor(zero); assertNull(e4); - } /** @@ -901,7 +898,6 @@ public class ConcurrentSkipListSubSetTes Object e4 = q.ceiling(m6); assertNull(e4); - } /** @@ -921,7 +917,7 @@ public class ConcurrentSkipListSubSetTes public void testDescendingToArray2() { NavigableSet q = populatedSet(SIZE); Integer[] ints = new Integer[SIZE]; - ints = (Integer[])q.toArray(ints); + assertSame(ints, q.toArray(ints)); Arrays.sort(ints); for (int i = 0; i < ints.length; i++) assertEquals(ints[i], q.pollFirst()); @@ -958,7 +954,7 @@ public class ConcurrentSkipListSubSetTes /** * iterator.remove removes current element */ - public void testDescendingIteratorRemove () { + public void testDescendingIteratorRemove() { final NavigableSet q = dset0(); q.add(new Integer(2)); q.add(new Integer(1));