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.11 by jsr166, Tue Dec 1 09:43:19 2009 UTC vs.
Revision 1.16 by jsr166, Fri Nov 5 00:17:22 2010 UTC

# Line 11 | Line 11 | import java.io.*;
11  
12   public class TreeSubSetTest 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(TreeSubSetTest.class);
# Line 27 | Line 27 | public class TreeSubSetTest extends JSR1
27       * Create a set of given size containing consecutive
28       * Integers 0 ... n.
29       */
30 <    private NavigableSet populatedSet(int n) {
31 <        TreeSet q = new TreeSet();
30 >    private NavigableSet<Integer> populatedSet(int n) {
31 >        TreeSet<Integer> q = new TreeSet<Integer>();
32          assertTrue(q.isEmpty());
33  
34          for (int i = n-1; i >= 0; i-=2)
# Line 175 | Line 175 | public class TreeSubSetTest extends JSR1
175              shouldThrow();
176          } catch (NullPointerException success) {}
177      }
178 +
179      /**
180       * addAll of a collection with null elements throws NPE
181       */
# Line 186 | Line 187 | public class TreeSubSetTest extends JSR1
187              shouldThrow();
188          } catch (NullPointerException success) {}
189      }
190 +
191      /**
192       * addAll of a collection with any null elements throws NPE after
193       * possibly adding some elements
# Line 392 | Line 394 | public class TreeSubSetTest extends JSR1
394      }
395  
396      /**
397 <     * toArray contains all elements
397 >     * toArray contains all elements in sorted order
398       */
399      public void testToArray() {
400          NavigableSet q = populatedSet(SIZE);
401          Object[] o = q.toArray();
400        Arrays.sort(o);
402          for (int i = 0; i < o.length; i++)
403 <            assertEquals(o[i], q.pollFirst());
403 >            assertSame(o[i], q.pollFirst());
404      }
405  
406      /**
407 <     * toArray(a) contains all elements
407 >     * toArray(a) contains all elements in sorted order
408       */
409      public void testToArray2() {
410 <        NavigableSet q = populatedSet(SIZE);
410 >        NavigableSet<Integer> q = populatedSet(SIZE);
411          Integer[] ints = new Integer[SIZE];
412 <        ints = (Integer[])q.toArray(ints);
413 <        Arrays.sort(ints);
412 >        Integer[] array = q.toArray(ints);
413 >        assertSame(ints, array);
414          for (int i = 0; i < ints.length; i++)
415 <            assertEquals(ints[i], q.pollFirst());
415 >            assertSame(ints[i], q.pollFirst());
416      }
417  
418      /**
# Line 445 | Line 446 | public class TreeSubSetTest extends JSR1
446      /**
447       * iterator.remove removes current element
448       */
449 <    public void testIteratorRemove () {
449 >    public void testIteratorRemove() {
450          final NavigableSet q = set0();
451          q.add(new Integer(2));
452          q.add(new Integer(1));
# Line 666 | Line 667 | public class TreeSubSetTest extends JSR1
667              shouldThrow();
668          } catch (NullPointerException success) {}
669      }
670 +
671      /**
672       * addAll of a collection with null elements throws NPE
673       */
# Line 677 | Line 679 | public class TreeSubSetTest extends JSR1
679              shouldThrow();
680          } catch (NullPointerException success) {}
681      }
682 +
683      /**
684       * addAll of a collection with any null elements throws NPE after
685       * possibly adding some elements
# Line 899 | Line 902 | public class TreeSubSetTest extends JSR1
902      public void testDescendingToArray2() {
903          NavigableSet q = populatedSet(SIZE);
904          Integer[] ints = new Integer[SIZE];
905 <        ints = (Integer[])q.toArray(ints);
905 >        assertSame(ints, q.toArray(ints));
906          Arrays.sort(ints);
907          for (int i = 0; i < ints.length; i++)
908              assertEquals(ints[i], q.pollFirst());
# Line 936 | Line 939 | public class TreeSubSetTest extends JSR1
939      /**
940       * iterator.remove removes current element
941       */
942 <    public void testDescendingIteratorRemove () {
942 >    public void testDescendingIteratorRemove() {
943          final NavigableSet q = dset0();
944          q.add(new Integer(2));
945          q.add(new Integer(1));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines