11 |
|
|
12 |
|
public class TreeSubMapTest 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(TreeSubMapTest.class); |
20 |
|
/** |
21 |
|
* Create a map from Integers 1-5 to Strings "A"-"E". |
22 |
|
*/ |
23 |
< |
private static NavigableMap map5() { |
23 |
> |
private static NavigableMap map5() { |
24 |
|
TreeMap map = new TreeMap(); |
25 |
|
assertTrue(map.isEmpty()); |
26 |
|
map.put(zero, "Z"); |
35 |
|
return map.subMap(one, true, seven, false); |
36 |
|
} |
37 |
|
|
38 |
< |
private static NavigableMap map0() { |
38 |
> |
private static NavigableMap map0() { |
39 |
|
TreeMap map = new TreeMap(); |
40 |
|
assertTrue(map.isEmpty()); |
41 |
|
return map.tailMap(one, true); |
44 |
|
/** |
45 |
|
* Create a map from Integers -5 to -1 to Strings "A"-"E". |
46 |
|
*/ |
47 |
< |
private static NavigableMap dmap5() { |
47 |
> |
private static NavigableMap dmap5() { |
48 |
|
TreeMap map = new TreeMap(); |
49 |
|
assertTrue(map.isEmpty()); |
50 |
|
map.put(m1, "A"); |
57 |
|
return map.descendingMap(); |
58 |
|
} |
59 |
|
|
60 |
< |
private static NavigableMap dmap0() { |
60 |
> |
private static NavigableMap dmap0() { |
61 |
|
TreeMap map = new TreeMap(); |
62 |
|
assertTrue(map.isEmpty()); |
63 |
|
return map; |
196 |
|
Iterator it = s.iterator(); |
197 |
|
while (it.hasNext()) { |
198 |
|
Map.Entry e = (Map.Entry) it.next(); |
199 |
< |
assertTrue( |
199 |
> |
assertTrue( |
200 |
|
(e.getKey().equals(one) && e.getValue().equals("A")) || |
201 |
|
(e.getKey().equals(two) && e.getValue().equals("B")) || |
202 |
|
(e.getKey().equals(three) && e.getValue().equals("C")) || |
384 |
|
for (int i = 1; i <= 5; ++i) { |
385 |
|
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
386 |
|
} |
387 |
< |
} |
387 |
> |
} |
388 |
|
|
389 |
|
// Exception tests |
390 |
|
|
396 |
|
NavigableMap c = map5(); |
397 |
|
c.get(null); |
398 |
|
shouldThrow(); |
399 |
< |
} catch(NullPointerException e){} |
399 |
> |
} catch (NullPointerException e){} |
400 |
|
} |
401 |
|
|
402 |
|
/** |
407 |
|
NavigableMap c = map5(); |
408 |
|
c.containsKey(null); |
409 |
|
shouldThrow(); |
410 |
< |
} catch(NullPointerException e){} |
410 |
> |
} catch (NullPointerException e){} |
411 |
|
} |
412 |
|
|
413 |
|
/** |
418 |
|
NavigableMap c = map5(); |
419 |
|
c.put(null, "whatever"); |
420 |
|
shouldThrow(); |
421 |
< |
} catch(NullPointerException e){} |
421 |
> |
} catch (NullPointerException e){} |
422 |
|
} |
423 |
|
|
424 |
|
/** |
429 |
|
NavigableMap c = map5(); |
430 |
|
c.remove(null); |
431 |
|
shouldThrow(); |
432 |
< |
} catch(NullPointerException e){} |
432 |
> |
} catch (NullPointerException e){} |
433 |
|
} |
434 |
|
|
435 |
|
/** |
451 |
|
assertEquals(q.size(), r.size()); |
452 |
|
assertTrue(q.equals(r)); |
453 |
|
assertTrue(r.equals(q)); |
454 |
< |
} catch(Exception e){ |
454 |
> |
} catch (Exception e){ |
455 |
|
e.printStackTrace(); |
456 |
|
unexpectedException(); |
457 |
|
} |
770 |
|
Iterator it = s.iterator(); |
771 |
|
while (it.hasNext()) { |
772 |
|
Map.Entry e = (Map.Entry) it.next(); |
773 |
< |
assertTrue( |
773 |
> |
assertTrue( |
774 |
|
(e.getKey().equals(m1) && e.getValue().equals("A")) || |
775 |
|
(e.getKey().equals(m2) && e.getValue().equals("B")) || |
776 |
|
(e.getKey().equals(m3) && e.getValue().equals("C")) || |
956 |
|
for (int i = 1; i <= 5; ++i) { |
957 |
|
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
958 |
|
} |
959 |
< |
} |
959 |
> |
} |
960 |
|
|
961 |
|
// Exception testDescendings |
962 |
|
|
968 |
|
NavigableMap c = dmap5(); |
969 |
|
c.get(null); |
970 |
|
shouldThrow(); |
971 |
< |
} catch(NullPointerException e){} |
971 |
> |
} catch (NullPointerException e){} |
972 |
|
} |
973 |
|
|
974 |
|
/** |
979 |
|
NavigableMap c = dmap5(); |
980 |
|
c.put(null, "whatever"); |
981 |
|
shouldThrow(); |
982 |
< |
} catch(NullPointerException e){} |
982 |
> |
} catch (NullPointerException e){} |
983 |
|
} |
984 |
|
|
985 |
|
/** |
987 |
|
*/ |
988 |
|
public void testDescendingSerialization() { |
989 |
|
NavigableMap q = dmap5(); |
990 |
< |
|
990 |
> |
|
991 |
|
try { |
992 |
|
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
993 |
|
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
1000 |
|
assertEquals(q.size(), r.size()); |
1001 |
|
assertTrue(q.equals(r)); |
1002 |
|
assertTrue(r.equals(q)); |
1003 |
< |
} catch(Exception e){ |
1003 |
> |
} catch (Exception e){ |
1004 |
|
e.printStackTrace(); |
1005 |
|
unexpectedException(); |
1006 |
|
} |
1142 |
|
assertEquals(3, sm.size()); |
1143 |
|
assertEquals(4, map.size()); |
1144 |
|
} |
1145 |
< |
|
1145 |
> |
|
1146 |
|
} |