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

Comparing jsr166/src/test/tck/TreeSubSetTest.java (file contents):
Revision 1.29 by jsr166, Sat Jan 17 22:55:07 2015 UTC vs.
Revision 1.32 by jsr166, Sat May 23 00:53:08 2015 UTC

# Line 17 | Line 17 | import junit.framework.TestSuite;
17  
18   public class TreeSubSetTest extends JSR166TestCase {
19      public static void main(String[] args) {
20 <        junit.textui.TestRunner.run(suite());
20 >        main(suite(), args);
21      }
22      public static Test suite() {
23          return new TestSuite(TreeSubSetTest.class);
# Line 119 | Line 119 | public class TreeSubSetTest extends JSR1
119      public void testSize() {
120          NavigableSet q = populatedSet(SIZE);
121          for (int i = 0; i < SIZE; ++i) {
122 <            assertEquals(SIZE-i, q.size());
122 >            assertEquals(SIZE - i, q.size());
123              q.pollFirst();
124          }
125          for (int i = 0; i < SIZE; ++i) {
# Line 132 | Line 132 | public class TreeSubSetTest extends JSR1
132       * add(null) throws NPE
133       */
134      public void testAddNull() {
135 +        NavigableSet q = set0();
136          try {
136            NavigableSet q = set0();
137              q.add(null);
138              shouldThrow();
139          } catch (NullPointerException success) {}
# Line 160 | Line 160 | public class TreeSubSetTest extends JSR1
160       * Add of non-Comparable throws CCE
161       */
162      public void testAddNonComparable() {
163 +        NavigableSet q = set0();
164          try {
164            NavigableSet q = set0();
165            q.add(new Object());
165              q.add(new Object());
166              q.add(new Object());
167              shouldThrow();
# Line 173 | Line 172 | public class TreeSubSetTest extends JSR1
172       * addAll(null) throws NPE
173       */
174      public void testAddAll1() {
175 +        NavigableSet q = set0();
176          try {
177            NavigableSet q = set0();
177              q.addAll(null);
178              shouldThrow();
179          } catch (NullPointerException success) {}
# Line 184 | Line 183 | public class TreeSubSetTest extends JSR1
183       * addAll of a collection with null elements throws NPE
184       */
185      public void testAddAll2() {
186 +        NavigableSet q = set0();
187 +        Integer[] ints = new Integer[SIZE];
188          try {
188            NavigableSet q = set0();
189            Integer[] ints = new Integer[SIZE];
189              q.addAll(Arrays.asList(ints));
190              shouldThrow();
191          } catch (NullPointerException success) {}
# Line 197 | Line 196 | public class TreeSubSetTest extends JSR1
196       * possibly adding some elements
197       */
198      public void testAddAll3() {
199 +        NavigableSet q = set0();
200 +        Integer[] ints = new Integer[SIZE];
201 +        for (int i = 0; i < SIZE - 1; ++i)
202 +            ints[i] = new Integer(i + SIZE);
203          try {
201            NavigableSet q = set0();
202            Integer[] ints = new Integer[SIZE];
203            for (int i = 0; i < SIZE-1; ++i)
204                ints[i] = new Integer(i+SIZE);
204              q.addAll(Arrays.asList(ints));
205              shouldThrow();
206          } catch (NullPointerException success) {}
# Line 214 | Line 213 | public class TreeSubSetTest extends JSR1
213          Integer[] empty = new Integer[0];
214          Integer[] ints = new Integer[SIZE];
215          for (int i = 0; i < SIZE; ++i)
216 <            ints[i] = new Integer(SIZE-1- i);
216 >            ints[i] = new Integer(SIZE - 1 - i);
217          NavigableSet q = set0();
218          assertFalse(q.addAll(Arrays.asList(empty)));
219          assertTrue(q.addAll(Arrays.asList(ints)));
# Line 308 | Line 307 | public class TreeSubSetTest extends JSR1
307                  assertTrue(changed);
308  
309              assertTrue(q.containsAll(p));
310 <            assertEquals(SIZE-i, q.size());
310 >            assertEquals(SIZE - i, q.size());
311              p.pollFirst();
312          }
313      }
# Line 321 | Line 320 | public class TreeSubSetTest extends JSR1
320              NavigableSet q = populatedSet(SIZE);
321              NavigableSet p = populatedSet(i);
322              assertTrue(q.removeAll(p));
323 <            assertEquals(SIZE-i, q.size());
323 >            assertEquals(SIZE - i, q.size());
324              for (int j = 0; j < i; ++j) {
325                  Integer x = (Integer)(p.pollFirst());
326                  assertFalse(q.contains(x));
# Line 616 | Line 615 | public class TreeSubSetTest extends JSR1
615      public void testDescendingSize() {
616          NavigableSet q = populatedSet(SIZE);
617          for (int i = 0; i < SIZE; ++i) {
618 <            assertEquals(SIZE-i, q.size());
618 >            assertEquals(SIZE - i, q.size());
619              q.pollFirst();
620          }
621          for (int i = 0; i < SIZE; ++i) {
# Line 646 | Line 645 | public class TreeSubSetTest extends JSR1
645       * Add of non-Comparable throws CCE
646       */
647      public void testDescendingAddNonComparable() {
648 +        NavigableSet q = dset0();
649          try {
650            NavigableSet q = dset0();
651            q.add(new Object());
650              q.add(new Object());
651              q.add(new Object());
652              shouldThrow();
# Line 659 | Line 657 | public class TreeSubSetTest extends JSR1
657       * addAll(null) throws NPE
658       */
659      public void testDescendingAddAll1() {
660 +        NavigableSet q = dset0();
661          try {
663            NavigableSet q = dset0();
662              q.addAll(null);
663              shouldThrow();
664          } catch (NullPointerException success) {}
# Line 670 | Line 668 | public class TreeSubSetTest extends JSR1
668       * addAll of a collection with null elements throws NPE
669       */
670      public void testDescendingAddAll2() {
671 +        NavigableSet q = dset0();
672 +        Integer[] ints = new Integer[SIZE];
673          try {
674            NavigableSet q = dset0();
675            Integer[] ints = new Integer[SIZE];
674              q.addAll(Arrays.asList(ints));
675              shouldThrow();
676          } catch (NullPointerException success) {}
# Line 683 | Line 681 | public class TreeSubSetTest extends JSR1
681       * possibly adding some elements
682       */
683      public void testDescendingAddAll3() {
684 +        NavigableSet q = dset0();
685 +        Integer[] ints = new Integer[SIZE];
686 +        for (int i = 0; i < SIZE - 1; ++i)
687 +            ints[i] = new Integer(i + SIZE);
688          try {
687            NavigableSet q = dset0();
688            Integer[] ints = new Integer[SIZE];
689            for (int i = 0; i < SIZE-1; ++i)
690                ints[i] = new Integer(i+SIZE);
689              q.addAll(Arrays.asList(ints));
690              shouldThrow();
691          } catch (NullPointerException success) {}
# Line 700 | Line 698 | public class TreeSubSetTest extends JSR1
698          Integer[] empty = new Integer[0];
699          Integer[] ints = new Integer[SIZE];
700          for (int i = 0; i < SIZE; ++i)
701 <            ints[i] = new Integer(SIZE-1- i);
701 >            ints[i] = new Integer(SIZE - 1 - i);
702          NavigableSet q = dset0();
703          assertFalse(q.addAll(Arrays.asList(empty)));
704          assertTrue(q.addAll(Arrays.asList(ints)));
# Line 788 | Line 786 | public class TreeSubSetTest extends JSR1
786                  assertTrue(changed);
787  
788              assertTrue(q.containsAll(p));
789 <            assertEquals(SIZE-i, q.size());
789 >            assertEquals(SIZE - i, q.size());
790              p.pollFirst();
791          }
792      }
# Line 801 | Line 799 | public class TreeSubSetTest extends JSR1
799              NavigableSet q = populatedSet(SIZE);
800              NavigableSet p = populatedSet(i);
801              assertTrue(q.removeAll(p));
802 <            assertEquals(SIZE-i, q.size());
802 >            assertEquals(SIZE - i, q.size());
803              for (int j = 0; j < i; ++j) {
804                  Integer x = (Integer)(p.pollFirst());
805                  assertFalse(q.contains(x));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines