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.15 by jsr166, Wed Sep 1 20:12:39 2010 UTC vs.
Revision 1.42 by jsr166, Sun May 24 01:42:14 2015 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7 < import junit.framework.*;
8 < import java.util.*;
9 < import java.util.concurrent.*;
10 < import java.io.*;
7 > import java.util.Arrays;
8 > import java.util.BitSet;
9 > import java.util.Collection;
10 > import java.util.Comparator;
11 > import java.util.Iterator;
12 > import java.util.NavigableSet;
13 > import java.util.NoSuchElementException;
14 > import java.util.Random;
15 > import java.util.Set;
16 > import java.util.SortedSet;
17 > import java.util.concurrent.ConcurrentSkipListSet;
18 >
19 > import junit.framework.Test;
20 > import junit.framework.TestSuite;
21  
22   public class ConcurrentSkipListSetTest extends JSR166TestCase {
23      public static void main(String[] args) {
24 <        junit.textui.TestRunner.run(suite());
24 >        main(suite(), args);
25      }
26      public static Test suite() {
27          return new TestSuite(ConcurrentSkipListSetTest.class);
# Line 24 | Line 34 | public class ConcurrentSkipListSetTest e
34      }
35  
36      /**
37 <     * Create a set of given size containing consecutive
37 >     * Returns a new set of given size containing consecutive
38       * Integers 0 ... n.
39       */
40 <    private ConcurrentSkipListSet populatedSet(int n) {
41 <        ConcurrentSkipListSet q = new ConcurrentSkipListSet();
40 >    private ConcurrentSkipListSet<Integer> populatedSet(int n) {
41 >        ConcurrentSkipListSet<Integer> q =
42 >            new ConcurrentSkipListSet<Integer>();
43          assertTrue(q.isEmpty());
44 <        for (int i = n-1; i >= 0; i-=2)
44 >        for (int i = n - 1; i >= 0; i -= 2)
45              assertTrue(q.add(new Integer(i)));
46 <        for (int i = (n & 1); i < n; i+=2)
46 >        for (int i = (n & 1); i < n; i += 2)
47              assertTrue(q.add(new Integer(i)));
48          assertFalse(q.isEmpty());
49          assertEquals(n, q.size());
# Line 40 | Line 51 | public class ConcurrentSkipListSetTest e
51      }
52  
53      /**
54 <     * Create set of first 5 ints
54 >     * Returns a new set of first 5 ints.
55       */
56      private ConcurrentSkipListSet set5() {
57          ConcurrentSkipListSet q = new ConcurrentSkipListSet();
# Line 66 | Line 77 | public class ConcurrentSkipListSetTest e
77       */
78      public void testConstructor3() {
79          try {
80 <            ConcurrentSkipListSet q = new ConcurrentSkipListSet((Collection)null);
80 >            new ConcurrentSkipListSet((Collection)null);
81              shouldThrow();
82          } catch (NullPointerException success) {}
83      }
# Line 76 | Line 87 | public class ConcurrentSkipListSetTest e
87       */
88      public void testConstructor4() {
89          try {
90 <            Integer[] ints = new Integer[SIZE];
80 <            ConcurrentSkipListSet q = new ConcurrentSkipListSet(Arrays.asList(ints));
90 >            new ConcurrentSkipListSet(Arrays.asList(new Integer[SIZE]));
91              shouldThrow();
92          } catch (NullPointerException success) {}
93      }
# Line 86 | Line 96 | public class ConcurrentSkipListSetTest e
96       * Initializing from Collection with some null elements throws NPE
97       */
98      public void testConstructor5() {
99 +        Integer[] ints = new Integer[SIZE];
100 +        for (int i = 0; i < SIZE - 1; ++i)
101 +            ints[i] = new Integer(i);
102          try {
103 <            Integer[] ints = new Integer[SIZE];
91 <            for (int i = 0; i < SIZE-1; ++i)
92 <                ints[i] = new Integer(i);
93 <            ConcurrentSkipListSet q = new ConcurrentSkipListSet(Arrays.asList(ints));
103 >            new ConcurrentSkipListSet(Arrays.asList(ints));
104              shouldThrow();
105          } catch (NullPointerException success) {}
106      }
# Line 118 | Line 128 | public class ConcurrentSkipListSetTest e
128          for (int i = 0; i < SIZE; ++i)
129              ints[i] = new Integer(i);
130          q.addAll(Arrays.asList(ints));
131 <        for (int i = SIZE-1; i >= 0; --i)
131 >        for (int i = SIZE - 1; i >= 0; --i)
132              assertEquals(ints[i], q.pollFirst());
133      }
134  
# Line 142 | Line 152 | public class ConcurrentSkipListSetTest e
152      public void testSize() {
153          ConcurrentSkipListSet q = populatedSet(SIZE);
154          for (int i = 0; i < SIZE; ++i) {
155 <            assertEquals(SIZE-i, q.size());
155 >            assertEquals(SIZE - i, q.size());
156              q.pollFirst();
157          }
158          for (int i = 0; i < SIZE; ++i) {
# Line 155 | Line 165 | public class ConcurrentSkipListSetTest e
165       * add(null) throws NPE
166       */
167      public void testAddNull() {
168 +        ConcurrentSkipListSet q = new ConcurrentSkipListSet();
169          try {
159            ConcurrentSkipListSet q = new ConcurrentSkipListSet();
170              q.add(null);
171              shouldThrow();
172          } catch (NullPointerException success) {}
# Line 184 | Line 194 | public class ConcurrentSkipListSetTest e
194       * Add of non-Comparable throws CCE
195       */
196      public void testAddNonComparable() {
197 +        ConcurrentSkipListSet q = new ConcurrentSkipListSet();
198          try {
188            ConcurrentSkipListSet q = new ConcurrentSkipListSet();
189            q.add(new Object());
199              q.add(new Object());
200              q.add(new Object());
201              shouldThrow();
# Line 197 | Line 206 | public class ConcurrentSkipListSetTest e
206       * addAll(null) throws NPE
207       */
208      public void testAddAll1() {
209 +        ConcurrentSkipListSet q = new ConcurrentSkipListSet();
210          try {
201            ConcurrentSkipListSet q = new ConcurrentSkipListSet();
211              q.addAll(null);
212              shouldThrow();
213          } catch (NullPointerException success) {}
# Line 208 | Line 217 | public class ConcurrentSkipListSetTest e
217       * addAll of a collection with null elements throws NPE
218       */
219      public void testAddAll2() {
220 +        ConcurrentSkipListSet q = new ConcurrentSkipListSet();
221 +        Integer[] ints = new Integer[SIZE];
222          try {
212            ConcurrentSkipListSet q = new ConcurrentSkipListSet();
213            Integer[] ints = new Integer[SIZE];
223              q.addAll(Arrays.asList(ints));
224              shouldThrow();
225          } catch (NullPointerException success) {}
# Line 221 | Line 230 | public class ConcurrentSkipListSetTest e
230       * possibly adding some elements
231       */
232      public void testAddAll3() {
233 +        ConcurrentSkipListSet q = new ConcurrentSkipListSet();
234 +        Integer[] ints = new Integer[SIZE];
235 +        for (int i = 0; i < SIZE - 1; ++i)
236 +            ints[i] = new Integer(i);
237          try {
225            ConcurrentSkipListSet q = new ConcurrentSkipListSet();
226            Integer[] ints = new Integer[SIZE];
227            for (int i = 0; i < SIZE-1; ++i)
228                ints[i] = new Integer(i);
238              q.addAll(Arrays.asList(ints));
239              shouldThrow();
240          } catch (NullPointerException success) {}
# Line 238 | Line 247 | public class ConcurrentSkipListSetTest e
247          Integer[] empty = new Integer[0];
248          Integer[] ints = new Integer[SIZE];
249          for (int i = 0; i < SIZE; ++i)
250 <            ints[i] = new Integer(SIZE-1-i);
250 >            ints[i] = new Integer(SIZE - 1 - i);
251          ConcurrentSkipListSet q = new ConcurrentSkipListSet();
252          assertFalse(q.addAll(Arrays.asList(empty)));
253          assertTrue(q.addAll(Arrays.asList(ints)));
# Line 262 | Line 271 | public class ConcurrentSkipListSetTest e
271       */
272      public void testPollLast() {
273          ConcurrentSkipListSet q = populatedSet(SIZE);
274 <        for (int i = SIZE-1; i >= 0; --i) {
274 >        for (int i = SIZE - 1; i >= 0; --i) {
275              assertEquals(i, q.pollLast());
276          }
277          assertNull(q.pollFirst());
278      }
279  
271
280      /**
281       * remove(x) removes x and returns true if present
282       */
283      public void testRemoveElement() {
284          ConcurrentSkipListSet q = populatedSet(SIZE);
285 <        for (int i = 1; i < SIZE; i+=2) {
286 <            assertTrue(q.remove(new Integer(i)));
287 <        }
288 <        for (int i = 0; i < SIZE; i+=2) {
289 <            assertTrue(q.remove(new Integer(i)));
290 <            assertFalse(q.remove(new Integer(i+1)));
285 >        for (int i = 1; i < SIZE; i += 2) {
286 >            assertTrue(q.contains(i));
287 >            assertTrue(q.remove(i));
288 >            assertFalse(q.contains(i));
289 >            assertTrue(q.contains(i - 1));
290 >        }
291 >        for (int i = 0; i < SIZE; i += 2) {
292 >            assertTrue(q.contains(i));
293 >            assertTrue(q.remove(i));
294 >            assertFalse(q.contains(i));
295 >            assertFalse(q.remove(i + 1));
296 >            assertFalse(q.contains(i + 1));
297          }
298          assertTrue(q.isEmpty());
299      }
# Line 338 | Line 352 | public class ConcurrentSkipListSetTest e
352                  assertTrue(changed);
353  
354              assertTrue(q.containsAll(p));
355 <            assertEquals(SIZE-i, q.size());
355 >            assertEquals(SIZE - i, q.size());
356              p.pollFirst();
357          }
358      }
# Line 351 | Line 365 | public class ConcurrentSkipListSetTest e
365              ConcurrentSkipListSet q = populatedSet(SIZE);
366              ConcurrentSkipListSet p = populatedSet(i);
367              assertTrue(q.removeAll(p));
368 <            assertEquals(SIZE-i, q.size());
368 >            assertEquals(SIZE - i, q.size());
369              for (int j = 0; j < i; ++j) {
370 <                Integer I = (Integer)(p.pollFirst());
371 <                assertFalse(q.contains(I));
370 >                Integer x = (Integer)(p.pollFirst());
371 >                assertFalse(q.contains(x));
372              }
373          }
374      }
375  
362
363
376      /**
377       * lower returns preceding element
378       */
# Line 434 | Line 446 | public class ConcurrentSkipListSetTest e
446      }
447  
448      /**
449 <     * toArray contains all elements
449 >     * toArray contains all elements in sorted order
450       */
451      public void testToArray() {
452          ConcurrentSkipListSet q = populatedSet(SIZE);
453          Object[] o = q.toArray();
442        Arrays.sort(o);
454          for (int i = 0; i < o.length; i++)
455 <            assertEquals(o[i], q.pollFirst());
455 >            assertSame(o[i], q.pollFirst());
456      }
457  
458      /**
459 <     * toArray(a) contains all elements
459 >     * toArray(a) contains all elements in sorted order
460       */
461      public void testToArray2() {
462 <        ConcurrentSkipListSet q = populatedSet(SIZE);
462 >        ConcurrentSkipListSet<Integer> q = populatedSet(SIZE);
463          Integer[] ints = new Integer[SIZE];
464 <        ints = (Integer[])q.toArray(ints);
454 <        Arrays.sort(ints);
464 >        assertSame(ints, q.toArray(ints));
465          for (int i = 0; i < ints.length; i++)
466 <            assertEquals(ints[i], q.pollFirst());
466 >            assertSame(ints[i], q.pollFirst());
467      }
468  
469      /**
# Line 461 | Line 471 | public class ConcurrentSkipListSetTest e
471       */
472      public void testIterator() {
473          ConcurrentSkipListSet q = populatedSet(SIZE);
464        int i = 0;
474          Iterator it = q.iterator();
475 <        while (it.hasNext()) {
475 >        int i;
476 >        for (i = 0; it.hasNext(); i++)
477              assertTrue(q.contains(it.next()));
468            ++i;
469        }
478          assertEquals(i, SIZE);
479 +        assertIteratorExhausted(it);
480      }
481  
482      /**
483       * iterator of empty set has no elements
484       */
485      public void testEmptyIterator() {
486 <        ConcurrentSkipListSet q = new ConcurrentSkipListSet();
487 <        int i = 0;
488 <        Iterator it = q.iterator();
480 <        while (it.hasNext()) {
481 <            assertTrue(q.contains(it.next()));
482 <            ++i;
483 <        }
484 <        assertEquals(i, 0);
486 >        NavigableSet s = new ConcurrentSkipListSet();
487 >        assertIteratorExhausted(s.iterator());
488 >        assertIteratorExhausted(s.descendingSet().iterator());
489      }
490  
491      /**
# Line 503 | Line 507 | public class ConcurrentSkipListSetTest e
507          assertFalse(it.hasNext());
508      }
509  
506
510      /**
511       * toString contains toStrings of elements
512       */
# Line 511 | Line 514 | public class ConcurrentSkipListSetTest e
514          ConcurrentSkipListSet q = populatedSet(SIZE);
515          String s = q.toString();
516          for (int i = 0; i < SIZE; ++i) {
517 <            assertTrue(s.indexOf(String.valueOf(i)) >= 0);
517 >            assertTrue(s.contains(String.valueOf(i)));
518          }
519      }
520  
# Line 519 | Line 522 | public class ConcurrentSkipListSetTest e
522       * A deserialized serialized set has same elements
523       */
524      public void testSerialization() throws Exception {
525 <        ConcurrentSkipListSet q = populatedSet(SIZE);
526 <        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
527 <        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
528 <        out.writeObject(q);
529 <        out.close();
530 <
531 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
532 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
533 <        ConcurrentSkipListSet r = (ConcurrentSkipListSet)in.readObject();
534 <        assertEquals(q.size(), r.size());
535 <        while (!q.isEmpty())
536 <            assertEquals(q.pollFirst(), r.pollFirst());
525 >        NavigableSet x = populatedSet(SIZE);
526 >        NavigableSet y = serialClone(x);
527 >
528 >        assertNotSame(x, y);
529 >        assertEquals(x.size(), y.size());
530 >        assertEquals(x, y);
531 >        assertEquals(y, x);
532 >        while (!x.isEmpty()) {
533 >            assertFalse(y.isEmpty());
534 >            assertEquals(x.pollFirst(), y.pollFirst());
535 >        }
536 >        assertTrue(y.isEmpty());
537      }
538  
539      /**
# Line 653 | Line 656 | public class ConcurrentSkipListSetTest e
656      }
657  
658      Random rnd = new Random(666);
656    BitSet bs;
659  
660      /**
661       * Subsets of subsets subdivide correctly
662       */
663      public void testRecursiveSubSets() throws Exception {
664 <        int setSize = 1000;
664 >        int setSize = expensiveTests ? 1000 : 100;
665          Class cl = ConcurrentSkipListSet.class;
666  
667          NavigableSet<Integer> set = newSet(cl);
668 <        bs = new BitSet(setSize);
668 >        BitSet bs = new BitSet(setSize);
669  
670 <        populate(set, setSize);
671 <        check(set,                 0, setSize - 1, true);
672 <        check(set.descendingSet(), 0, setSize - 1, false);
673 <
674 <        mutateSet(set, 0, setSize - 1);
675 <        check(set,                 0, setSize - 1, true);
676 <        check(set.descendingSet(), 0, setSize - 1, false);
670 >        populate(set, setSize, bs);
671 >        check(set,                 0, setSize - 1, true, bs);
672 >        check(set.descendingSet(), 0, setSize - 1, false, bs);
673 >
674 >        mutateSet(set, 0, setSize - 1, bs);
675 >        check(set,                 0, setSize - 1, true, bs);
676 >        check(set.descendingSet(), 0, setSize - 1, false, bs);
677  
678          bashSubSet(set.subSet(0, true, setSize, false),
679 <                   0, setSize - 1, true);
679 >                   0, setSize - 1, true, bs);
680 >    }
681 >
682 >    /**
683 >     * addAll is idempotent
684 >     */
685 >    public void testAddAll_idempotent() throws Exception {
686 >        Set x = populatedSet(SIZE);
687 >        Set y = new ConcurrentSkipListSet(x);
688 >        y.addAll(x);
689 >        assertEquals(x, y);
690 >        assertEquals(y, x);
691      }
692  
693      static NavigableSet<Integer> newSet(Class cl) throws Exception {
694          NavigableSet<Integer> result = (NavigableSet<Integer>) cl.newInstance();
695 <        assertEquals(result.size(), 0);
695 >        assertEquals(0, result.size());
696          assertFalse(result.iterator().hasNext());
697          return result;
698      }
699  
700 <    void populate(NavigableSet<Integer> set, int limit) {
700 >    void populate(NavigableSet<Integer> set, int limit, BitSet bs) {
701          for (int i = 0, n = 2 * limit / 3; i < n; i++) {
702              int element = rnd.nextInt(limit);
703 <            put(set, element);
703 >            put(set, element, bs);
704          }
705      }
706  
707 <    void mutateSet(NavigableSet<Integer> set, int min, int max) {
707 >    void mutateSet(NavigableSet<Integer> set, int min, int max, BitSet bs) {
708          int size = set.size();
709          int rangeSize = max - min + 1;
710  
711          // Remove a bunch of entries directly
712          for (int i = 0, n = rangeSize / 2; i < n; i++) {
713 <            remove(set, min - 5 + rnd.nextInt(rangeSize + 10));
713 >            remove(set, min - 5 + rnd.nextInt(rangeSize + 10), bs);
714          }
715  
716          // Remove a bunch of entries with iterator
# Line 711 | Line 724 | public class ConcurrentSkipListSetTest e
724          // Add entries till we're back to original size
725          while (set.size() < size) {
726              int element = min + rnd.nextInt(rangeSize);
727 <            assertTrue(element >= min && element<= max);
728 <            put(set, element);
727 >            assertTrue(element >= min && element <= max);
728 >            put(set, element, bs);
729          }
730      }
731  
732 <    void mutateSubSet(NavigableSet<Integer> set, int min, int max) {
732 >    void mutateSubSet(NavigableSet<Integer> set, int min, int max,
733 >                      BitSet bs) {
734          int size = set.size();
735          int rangeSize = max - min + 1;
736  
737          // Remove a bunch of entries directly
738          for (int i = 0, n = rangeSize / 2; i < n; i++) {
739 <            remove(set, min - 5 + rnd.nextInt(rangeSize + 10));
739 >            remove(set, min - 5 + rnd.nextInt(rangeSize + 10), bs);
740          }
741  
742          // Remove a bunch of entries with iterator
# Line 736 | Line 750 | public class ConcurrentSkipListSetTest e
750          // Add entries till we're back to original size
751          while (set.size() < size) {
752              int element = min - 5 + rnd.nextInt(rangeSize + 10);
753 <            if (element >= min && element<= max) {
754 <                put(set, element);
753 >            if (element >= min && element <= max) {
754 >                put(set, element, bs);
755              } else {
756                  try {
757                      set.add(element);
# Line 747 | Line 761 | public class ConcurrentSkipListSetTest e
761          }
762      }
763  
764 <    void put(NavigableSet<Integer> set, int element) {
764 >    void put(NavigableSet<Integer> set, int element, BitSet bs) {
765          if (set.add(element))
766              bs.set(element);
767      }
768  
769 <    void remove(NavigableSet<Integer> set, int element) {
769 >    void remove(NavigableSet<Integer> set, int element, BitSet bs) {
770          if (set.remove(element))
771              bs.clear(element);
772      }
773  
774      void bashSubSet(NavigableSet<Integer> set,
775 <                    int min, int max, boolean ascending) {
776 <        check(set, min, max, ascending);
777 <        check(set.descendingSet(), min, max, !ascending);
778 <
779 <        mutateSubSet(set, min, max);
780 <        check(set, min, max, ascending);
781 <        check(set.descendingSet(), min, max, !ascending);
775 >                    int min, int max, boolean ascending,
776 >                    BitSet bs) {
777 >        check(set, min, max, ascending, bs);
778 >        check(set.descendingSet(), min, max, !ascending, bs);
779 >
780 >        mutateSubSet(set, min, max, bs);
781 >        check(set, min, max, ascending, bs);
782 >        check(set.descendingSet(), min, max, !ascending, bs);
783  
784          // Recurse
785          if (max - min < 2)
# Line 776 | Line 791 | public class ConcurrentSkipListSetTest e
791          NavigableSet<Integer> hm = set.headSet(midPoint, incl);
792          if (ascending) {
793              if (rnd.nextBoolean())
794 <                bashSubSet(hm, min, midPoint - (incl ? 0 : 1), true);
794 >                bashSubSet(hm, min, midPoint - (incl ? 0 : 1), true, bs);
795              else
796                  bashSubSet(hm.descendingSet(), min, midPoint - (incl ? 0 : 1),
797 <                           false);
797 >                           false, bs);
798          } else {
799              if (rnd.nextBoolean())
800 <                bashSubSet(hm, midPoint + (incl ? 0 : 1), max, false);
800 >                bashSubSet(hm, midPoint + (incl ? 0 : 1), max, false, bs);
801              else
802                  bashSubSet(hm.descendingSet(), midPoint + (incl ? 0 : 1), max,
803 <                           true);
803 >                           true, bs);
804          }
805  
806          // tailSet - pick direction and endpoint inclusion randomly
# Line 793 | Line 808 | public class ConcurrentSkipListSetTest e
808          NavigableSet<Integer> tm = set.tailSet(midPoint,incl);
809          if (ascending) {
810              if (rnd.nextBoolean())
811 <                bashSubSet(tm, midPoint + (incl ? 0 : 1), max, true);
811 >                bashSubSet(tm, midPoint + (incl ? 0 : 1), max, true, bs);
812              else
813                  bashSubSet(tm.descendingSet(), midPoint + (incl ? 0 : 1), max,
814 <                           false);
814 >                           false, bs);
815          } else {
816              if (rnd.nextBoolean()) {
817 <                bashSubSet(tm, min, midPoint - (incl ? 0 : 1), false);
817 >                bashSubSet(tm, min, midPoint - (incl ? 0 : 1), false, bs);
818              } else {
819                  bashSubSet(tm.descendingSet(), min, midPoint - (incl ? 0 : 1),
820 <                           true);
820 >                           true, bs);
821              }
822          }
823  
# Line 819 | Line 834 | public class ConcurrentSkipListSetTest e
834                  endpoints[0], lowIncl, endpoints[1], highIncl);
835              if (rnd.nextBoolean())
836                  bashSubSet(sm, endpoints[0] + (lowIncl ? 0 : 1),
837 <                           endpoints[1] - (highIncl ? 0 : 1), true);
837 >                           endpoints[1] - (highIncl ? 0 : 1), true, bs);
838              else
839                  bashSubSet(sm.descendingSet(), endpoints[0] + (lowIncl ? 0 : 1),
840 <                           endpoints[1] - (highIncl ? 0 : 1), false);
840 >                           endpoints[1] - (highIncl ? 0 : 1), false, bs);
841          } else {
842              NavigableSet<Integer> sm = set.subSet(
843                  endpoints[1], highIncl, endpoints[0], lowIncl);
844              if (rnd.nextBoolean())
845                  bashSubSet(sm, endpoints[0] + (lowIncl ? 0 : 1),
846 <                           endpoints[1] - (highIncl ? 0 : 1), false);
846 >                           endpoints[1] - (highIncl ? 0 : 1), false, bs);
847              else
848                  bashSubSet(sm.descendingSet(), endpoints[0] + (lowIncl ? 0 : 1),
849 <                           endpoints[1] - (highIncl ? 0 : 1), true);
849 >                           endpoints[1] - (highIncl ? 0 : 1), true, bs);
850          }
851      }
852  
# Line 839 | Line 854 | public class ConcurrentSkipListSetTest e
854       * min and max are both inclusive.  If max < min, interval is empty.
855       */
856      void check(NavigableSet<Integer> set,
857 <                      final int min, final int max, final boolean ascending) {
858 <       class ReferenceSet {
857 >               final int min, final int max, final boolean ascending,
858 >               final BitSet bs) {
859 >        class ReferenceSet {
860              int lower(int element) {
861                  return ascending ?
862                      lowerAscending(element) : higherAscending(element);
# Line 910 | Line 926 | public class ConcurrentSkipListSetTest e
926              if (bsContainsI)
927                  size++;
928          }
929 <        assertEquals(set.size(), size);
929 >        assertEquals(size, set.size());
930  
931          // Test contents using contains elementSet iterator
932          int size2 = 0;
# Line 958 | Line 974 | public class ConcurrentSkipListSetTest e
974      }
975  
976      static boolean eq(Integer i, int j) {
977 <        return i == null ? j == -1 : i == j;
977 >        return (i == null) ? j == -1 : i == j;
978      }
979  
980   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines