11 |
|
|
12 |
|
public class TreeMapTest 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(TreeMapTest.class); |
20 |
|
/** |
21 |
|
* Create a map from Integers 1-5 to Strings "A"-"E". |
22 |
|
*/ |
23 |
< |
private static TreeMap map5() { |
23 |
> |
private static TreeMap map5() { |
24 |
|
TreeMap map = new TreeMap(); |
25 |
|
assertTrue(map.isEmpty()); |
26 |
|
map.put(one, "A"); |
43 |
|
} |
44 |
|
|
45 |
|
/** |
46 |
< |
* |
46 |
> |
* |
47 |
|
*/ |
48 |
|
public void testConstructFromSorted() { |
49 |
|
TreeMap map = map5(); |
260 |
|
Iterator it = s.iterator(); |
261 |
|
while (it.hasNext()) { |
262 |
|
Map.Entry e = (Map.Entry) it.next(); |
263 |
< |
assertTrue( |
263 |
> |
assertTrue( |
264 |
|
(e.getKey().equals(one) && e.getValue().equals("A")) || |
265 |
|
(e.getKey().equals(two) && e.getValue().equals("B")) || |
266 |
|
(e.getKey().equals(three) && e.getValue().equals("C")) || |
279 |
|
Iterator it = s.iterator(); |
280 |
|
while (it.hasNext()) { |
281 |
|
Map.Entry e = (Map.Entry) it.next(); |
282 |
< |
assertTrue( |
282 |
> |
assertTrue( |
283 |
|
(e.getKey().equals(one) && e.getValue().equals("A")) || |
284 |
|
(e.getKey().equals(two) && e.getValue().equals("B")) || |
285 |
|
(e.getKey().equals(three) && e.getValue().equals("C")) || |
569 |
|
for (int i = 1; i <= 5; ++i) { |
570 |
|
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
571 |
|
} |
572 |
< |
} |
572 |
> |
} |
573 |
|
|
574 |
|
// Exception tests |
575 |
|
|
658 |
|
k = (Integer)(r.next()); |
659 |
|
assertEquals(two, k); |
660 |
|
assertFalse(r.hasNext()); |
661 |
< |
|
661 |
> |
|
662 |
|
Iterator j = sm.keySet().iterator(); |
663 |
|
j.next(); |
664 |
|
j.remove(); |
692 |
|
k = (Integer)(r.next()); |
693 |
|
assertEquals(two, k); |
694 |
|
assertFalse(r.hasNext()); |
695 |
< |
|
695 |
> |
|
696 |
|
Iterator j = sm.keySet().iterator(); |
697 |
|
j.next(); |
698 |
|
j.remove(); |
1102 |
|
static boolean eq(Integer i, int j) { |
1103 |
|
return i == null ? j == -1 : i == j; |
1104 |
|
} |
1105 |
< |
|
1105 |
> |
|
1106 |
|
} |