ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ConcurrentSkipListSubSetTest.java
(Generate patch)

Comparing jsr166/src/test/tck/ConcurrentSkipListSubSetTest.java (file contents):
Revision 1.27 by jsr166, Wed Dec 31 20:09:08 2014 UTC vs.
Revision 1.30 by jsr166, Sat Feb 28 18:10:55 2015 UTC

# Line 135 | Line 135 | public class ConcurrentSkipListSubSetTes
135       * add(null) throws NPE
136       */
137      public void testAddNull() {
138 +        NavigableSet q = set0();
139          try {
139            NavigableSet q = set0();
140              q.add(null);
141              shouldThrow();
142          } catch (NullPointerException success) {}
# Line 163 | Line 163 | public class ConcurrentSkipListSubSetTes
163       * Add of non-Comparable throws CCE
164       */
165      public void testAddNonComparable() {
166 +        NavigableSet q = set0();
167          try {
167            NavigableSet q = set0();
168              q.add(new Object());
169              q.add(new Object());
170              q.add(new Object());
# Line 176 | Line 176 | public class ConcurrentSkipListSubSetTes
176       * addAll(null) throws NPE
177       */
178      public void testAddAll1() {
179 +        NavigableSet q = set0();
180          try {
180            NavigableSet q = set0();
181              q.addAll(null);
182              shouldThrow();
183          } catch (NullPointerException success) {}
# Line 187 | Line 187 | public class ConcurrentSkipListSubSetTes
187       * addAll of a collection with null elements throws NPE
188       */
189      public void testAddAll2() {
190 +        NavigableSet q = set0();
191 +        Integer[] ints = new Integer[SIZE];
192          try {
191            NavigableSet q = set0();
192            Integer[] ints = new Integer[SIZE];
193              q.addAll(Arrays.asList(ints));
194              shouldThrow();
195          } catch (NullPointerException success) {}
# Line 200 | Line 200 | public class ConcurrentSkipListSubSetTes
200       * possibly adding some elements
201       */
202      public void testAddAll3() {
203 +        NavigableSet q = set0();
204 +        Integer[] ints = new Integer[SIZE];
205 +        for (int i = 0; i < SIZE-1; ++i)
206 +            ints[i] = new Integer(i+SIZE);
207          try {
204            NavigableSet q = set0();
205            Integer[] ints = new Integer[SIZE];
206            for (int i = 0; i < SIZE-1; ++i)
207                ints[i] = new Integer(i+SIZE);
208              q.addAll(Arrays.asList(ints));
209              shouldThrow();
210          } catch (NullPointerException success) {}
# Line 326 | Line 326 | public class ConcurrentSkipListSubSetTes
326              assertTrue(q.removeAll(p));
327              assertEquals(SIZE-i, q.size());
328              for (int j = 0; j < i; ++j) {
329 <                Integer I = (Integer)(p.pollFirst());
330 <                assertFalse(q.contains(I));
329 >                Integer x = (Integer)(p.pollFirst());
330 >                assertFalse(q.contains(x));
331              }
332          }
333      }
# Line 431 | Line 431 | public class ConcurrentSkipListSubSetTes
431       */
432      public void testIterator() {
433          NavigableSet q = populatedSet(SIZE);
434        int i = 0;
434          Iterator it = q.iterator();
435 <        while (it.hasNext()) {
435 >        int i;
436 >        for (i = 0; it.hasNext(); i++)
437              assertTrue(q.contains(it.next()));
438            ++i;
439        }
438          assertEquals(i, SIZE);
439 +        assertIteratorExhausted(it);
440      }
441  
442      /**
443       * iterator of empty set has no elements
444       */
445      public void testEmptyIterator() {
446 <        NavigableSet q = set0();
448 <        int i = 0;
449 <        Iterator it = q.iterator();
450 <        while (it.hasNext()) {
451 <            assertTrue(q.contains(it.next()));
452 <            ++i;
453 <        }
454 <        assertEquals(0, i);
446 >        assertIteratorExhausted(set0().iterator());
447      }
448  
449      /**
# Line 640 | Line 632 | public class ConcurrentSkipListSubSetTes
632       * add(null) throws NPE
633       */
634      public void testDescendingAddNull() {
635 +        NavigableSet q = dset0();
636          try {
644            NavigableSet q = dset0();
637              q.add(null);
638              shouldThrow();
639          } catch (NullPointerException success) {}
# Line 668 | Line 660 | public class ConcurrentSkipListSubSetTes
660       * Add of non-Comparable throws CCE
661       */
662      public void testDescendingAddNonComparable() {
663 +        NavigableSet q = dset0();
664          try {
672            NavigableSet q = dset0();
665              q.add(new Object());
666              q.add(new Object());
667              q.add(new Object());
# Line 681 | Line 673 | public class ConcurrentSkipListSubSetTes
673       * addAll(null) throws NPE
674       */
675      public void testDescendingAddAll1() {
676 +        NavigableSet q = dset0();
677          try {
685            NavigableSet q = dset0();
678              q.addAll(null);
679              shouldThrow();
680          } catch (NullPointerException success) {}
# Line 692 | Line 684 | public class ConcurrentSkipListSubSetTes
684       * addAll of a collection with null elements throws NPE
685       */
686      public void testDescendingAddAll2() {
687 +        NavigableSet q = dset0();
688 +        Integer[] ints = new Integer[SIZE];
689          try {
696            NavigableSet q = dset0();
697            Integer[] ints = new Integer[SIZE];
690              q.addAll(Arrays.asList(ints));
691              shouldThrow();
692          } catch (NullPointerException success) {}
# Line 705 | Line 697 | public class ConcurrentSkipListSubSetTes
697       * possibly adding some elements
698       */
699      public void testDescendingAddAll3() {
700 +        NavigableSet q = dset0();
701 +        Integer[] ints = new Integer[SIZE];
702 +        for (int i = 0; i < SIZE-1; ++i)
703 +            ints[i] = new Integer(i+SIZE);
704          try {
709            NavigableSet q = dset0();
710            Integer[] ints = new Integer[SIZE];
711            for (int i = 0; i < SIZE-1; ++i)
712                ints[i] = new Integer(i+SIZE);
705              q.addAll(Arrays.asList(ints));
706              shouldThrow();
707          } catch (NullPointerException success) {}
# Line 825 | Line 817 | public class ConcurrentSkipListSubSetTes
817              assertTrue(q.removeAll(p));
818              assertEquals(SIZE-i, q.size());
819              for (int j = 0; j < i; ++j) {
820 <                Integer I = (Integer)(p.pollFirst());
821 <                assertFalse(q.contains(I));
820 >                Integer x = (Integer)(p.pollFirst());
821 >                assertFalse(q.contains(x));
822              }
823          }
824      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines