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

Comparing jsr166/src/test/tck/TreeSetTest.java (file contents):
Revision 1.13 by jsr166, Wed Aug 25 00:07:03 2010 UTC vs.
Revision 1.18 by jsr166, Fri Nov 5 00:17:22 2010 UTC

# Line 32 | Line 32 | public class TreeSetTest extends JSR166T
32       * Create a set of given size containing consecutive
33       * Integers 0 ... n.
34       */
35 <    private TreeSet populatedSet(int n) {
36 <        TreeSet q = new TreeSet();
35 >    private TreeSet<Integer> populatedSet(int n) {
36 >        TreeSet<Integer> q = new TreeSet<Integer>();
37          assertTrue(q.isEmpty());
38          for (int i = n-1; i >= 0; i-=2)
39              assertTrue(q.add(new Integer(i)));
# Line 208 | Line 208 | public class TreeSetTest extends JSR166T
208              shouldThrow();
209          } catch (NullPointerException success) {}
210      }
211 +
212      /**
213       * addAll of a collection with null elements throws NPE
214       */
# Line 219 | Line 220 | public class TreeSetTest extends JSR166T
220              shouldThrow();
221          } catch (NullPointerException success) {}
222      }
223 +
224      /**
225       * addAll of a collection with any null elements throws NPE after
226       * possibly adding some elements
# Line 437 | Line 439 | public class TreeSetTest extends JSR166T
439      }
440  
441      /**
442 <     * toArray contains all elements
442 >     * toArray contains all elements in sorted order
443       */
444      public void testToArray() {
445          TreeSet q = populatedSet(SIZE);
446          Object[] o = q.toArray();
445        Arrays.sort(o);
447          for (int i = 0; i < o.length; i++)
448 <            assertEquals(o[i], q.pollFirst());
448 >            assertSame(o[i], q.pollFirst());
449      }
450  
451      /**
452 <     * toArray(a) contains all elements
452 >     * toArray(a) contains all elements in sorted order
453       */
454      public void testToArray2() {
455 <        TreeSet q = populatedSet(SIZE);
455 >        TreeSet<Integer> q = populatedSet(SIZE);
456          Integer[] ints = new Integer[SIZE];
457 <        ints = (Integer[])q.toArray(ints);
458 <        Arrays.sort(ints);
457 >        Integer[] array = q.toArray(ints);
458 >        assertSame(ints, array);
459          for (int i = 0; i < ints.length; i++)
460 <            assertEquals(ints[i], q.pollFirst());
460 >            assertSame(ints[i], q.pollFirst());
461      }
462  
463      /**
# Line 662 | Line 663 | public class TreeSetTest extends JSR166T
663       * Subsets of subsets subdivide correctly
664       */
665      public void testRecursiveSubSets() throws Exception {
666 <        int setSize = 1000;
666 >        int setSize = expensiveTests ? 1000 : 100;
667          Class cl = TreeSet.class;
668  
669          NavigableSet<Integer> set = newSet(cl);
# Line 878 | Line 879 | public class TreeSetTest extends JSR166T
879                  // BitSet should support this! Test would run much faster
880                  while (element >= min) {
881                      if (bs.get(element))
882 <                        return(element);
882 >                        return element;
883                      element--;
884                  }
885                  return -1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines