21 |
|
|
22 |
|
public class TreeMapTest 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(TreeMapTest.class); |
575 |
|
* get(null) of nonempty map throws NPE |
576 |
|
*/ |
577 |
|
public void testGet_NullPointerException() { |
578 |
+ |
TreeMap c = map5(); |
579 |
|
try { |
579 |
– |
TreeMap c = map5(); |
580 |
|
c.get(null); |
581 |
|
shouldThrow(); |
582 |
|
} catch (NullPointerException success) {} |
586 |
|
* containsKey(null) of nonempty map throws NPE |
587 |
|
*/ |
588 |
|
public void testContainsKey_NullPointerException() { |
589 |
+ |
TreeMap c = map5(); |
590 |
|
try { |
590 |
– |
TreeMap c = map5(); |
591 |
|
c.containsKey(null); |
592 |
|
shouldThrow(); |
593 |
|
} catch (NullPointerException success) {} |
597 |
|
* remove(null) throws NPE for nonempty map |
598 |
|
*/ |
599 |
|
public void testRemove1_NullPointerException() { |
600 |
+ |
TreeMap c = new TreeMap(); |
601 |
+ |
c.put("sadsdf", "asdads"); |
602 |
|
try { |
601 |
– |
TreeMap c = new TreeMap(); |
602 |
– |
c.put("sadsdf", "asdads"); |
603 |
|
c.remove(null); |
604 |
|
shouldThrow(); |
605 |
|
} catch (NullPointerException success) {} |
606 |
|
} |
607 |
|
|
608 |
|
/** |
609 |
< |
* A deserialized map equals original |
609 |
> |
* A deserialized/reserialized map equals original |
610 |
|
*/ |
611 |
|
public void testSerialization() throws Exception { |
612 |
|
NavigableMap x = map5(); |
802 |
|
|
803 |
|
static NavigableMap<Integer, Integer> newMap(Class cl) throws Exception { |
804 |
|
NavigableMap<Integer, Integer> result |
805 |
< |
= (NavigableMap<Integer, Integer>) cl.newInstance(); |
805 |
> |
= (NavigableMap<Integer, Integer>) cl.getConstructor().newInstance(); |
806 |
|
assertEquals(0, result.size()); |
807 |
|
assertFalse(result.keySet().iterator().hasNext()); |
808 |
|
return result; |
835 |
|
// Add entries till we're back to original size |
836 |
|
while (map.size() < size) { |
837 |
|
int key = min + rnd.nextInt(rangeSize); |
838 |
< |
assertTrue(key >= min && key<= max); |
838 |
> |
assertTrue(key >= min && key <= max); |
839 |
|
put(map, key); |
840 |
|
} |
841 |
|
} |
860 |
|
// Add entries till we're back to original size |
861 |
|
while (map.size() < size) { |
862 |
|
int key = min - 5 + rnd.nextInt(rangeSize + 10); |
863 |
< |
if (key >= min && key<= max) { |
863 |
> |
if (key >= min && key <= max) { |
864 |
|
put(map, key); |
865 |
|
} else { |
866 |
|
try { |