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.12 by jsr166, Tue Dec 1 09:48:13 2009 UTC vs.
Revision 1.19 by jsr166, Thu Nov 18 20:21:53 2010 UTC

# Line 11 | Line 11 | import java.io.*;
11  
12   public class ConcurrentSkipListSetTest extends JSR166TestCase {
13      public static void main(String[] args) {
14 <        junit.textui.TestRunner.run (suite());
14 >        junit.textui.TestRunner.run(suite());
15      }
16      public static Test suite() {
17          return new TestSuite(ConcurrentSkipListSetTest.class);
# Line 27 | Line 27 | public class ConcurrentSkipListSetTest e
27       * Create a set of given size containing consecutive
28       * Integers 0 ... n.
29       */
30 <    private ConcurrentSkipListSet populatedSet(int n) {
31 <        ConcurrentSkipListSet q = new ConcurrentSkipListSet();
30 >    private ConcurrentSkipListSet<Integer> populatedSet(int n) {
31 >        ConcurrentSkipListSet<Integer> q =
32 >            new ConcurrentSkipListSet<Integer>();
33          assertTrue(q.isEmpty());
34          for (int i = n-1; i >= 0; i-=2)
35              assertTrue(q.add(new Integer(i)));
# Line 203 | Line 204 | public class ConcurrentSkipListSetTest e
204              shouldThrow();
205          } catch (NullPointerException success) {}
206      }
207 +
208      /**
209       * addAll of a collection with null elements throws NPE
210       */
# Line 214 | Line 216 | public class ConcurrentSkipListSetTest e
216              shouldThrow();
217          } catch (NullPointerException success) {}
218      }
219 +
220      /**
221       * addAll of a collection with any null elements throws NPE after
222       * possibly adding some elements
# Line 273 | Line 276 | public class ConcurrentSkipListSetTest e
276      public void testRemoveElement() {
277          ConcurrentSkipListSet q = populatedSet(SIZE);
278          for (int i = 1; i < SIZE; i+=2) {
279 <            assertTrue(q.remove(new Integer(i)));
279 >            assertTrue(q.contains(i));
280 >            assertTrue(q.remove(i));
281 >            assertFalse(q.contains(i));
282 >            assertTrue(q.contains(i-1));
283          }
284          for (int i = 0; i < SIZE; i+=2) {
285 <            assertTrue(q.remove(new Integer(i)));
286 <            assertFalse(q.remove(new Integer(i+1)));
285 >            assertTrue(q.contains(i));
286 >            assertTrue(q.remove(i));
287 >            assertFalse(q.contains(i));
288 >            assertFalse(q.remove(i+1));
289 >            assertFalse(q.contains(i+1));
290          }
291          assertTrue(q.isEmpty());
292      }
# Line 432 | Line 441 | public class ConcurrentSkipListSetTest e
441      }
442  
443      /**
444 <     * toArray contains all elements
444 >     * toArray contains all elements in sorted order
445       */
446      public void testToArray() {
447          ConcurrentSkipListSet q = populatedSet(SIZE);
448          Object[] o = q.toArray();
440        Arrays.sort(o);
449          for (int i = 0; i < o.length; i++)
450 <            assertEquals(o[i], q.pollFirst());
450 >            assertSame(o[i], q.pollFirst());
451      }
452  
453      /**
454 <     * toArray(a) contains all elements
454 >     * toArray(a) contains all elements in sorted order
455       */
456      public void testToArray2() {
457 <        ConcurrentSkipListSet q = populatedSet(SIZE);
457 >        ConcurrentSkipListSet<Integer> q = populatedSet(SIZE);
458          Integer[] ints = new Integer[SIZE];
459 <        ints = (Integer[])q.toArray(ints);
460 <        Arrays.sort(ints);
459 >        Integer[] array = q.toArray(ints);
460 >        assertSame(ints, array);
461          for (int i = 0; i < ints.length; i++)
462 <            assertEquals(ints[i], q.pollFirst());
462 >            assertSame(ints[i], q.pollFirst());
463      }
464  
465      /**
# Line 485 | Line 493 | public class ConcurrentSkipListSetTest e
493      /**
494       * iterator.remove removes current element
495       */
496 <    public void testIteratorRemove () {
496 >    public void testIteratorRemove() {
497          final ConcurrentSkipListSet q = new ConcurrentSkipListSet();
498          q.add(new Integer(2));
499          q.add(new Integer(1));
# Line 657 | Line 665 | public class ConcurrentSkipListSetTest e
665       * Subsets of subsets subdivide correctly
666       */
667      public void testRecursiveSubSets() throws Exception {
668 <        int setSize = 1000;
668 >        int setSize = expensiveTests ? 1000 : 100;
669          Class cl = ConcurrentSkipListSet.class;
670  
671          NavigableSet<Integer> set = newSet(cl);
# Line 873 | Line 881 | public class ConcurrentSkipListSetTest e
881                  // BitSet should support this! Test would run much faster
882                  while (element >= min) {
883                      if (bs.get(element))
884 <                        return(element);
884 >                        return element;
885                      element--;
886                  }
887                  return -1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines