6 |
|
|
7 |
|
import junit.framework.*; |
8 |
|
import java.util.*; |
9 |
– |
import java.util.concurrent.*; |
10 |
– |
import java.io.*; |
9 |
|
|
10 |
|
public class TreeMapTest extends JSR166TestCase { |
11 |
|
public static void main(String[] args) { |
117 |
|
assertEquals(five, map.lastKey()); |
118 |
|
} |
119 |
|
|
122 |
– |
|
120 |
|
/** |
121 |
|
* keySet.toArray returns contains all keys |
122 |
|
*/ |
410 |
|
assertNull(e4); |
411 |
|
} |
412 |
|
|
416 |
– |
|
413 |
|
/** |
414 |
|
* lowerKey returns preceding element |
415 |
|
*/ |
553 |
|
TreeMap map = map5(); |
554 |
|
String s = map.toString(); |
555 |
|
for (int i = 1; i <= 5; ++i) { |
556 |
< |
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
556 |
> |
assertTrue(s.contains(String.valueOf(i))); |
557 |
|
} |
558 |
|
} |
559 |
|
|
597 |
|
* A deserialized map equals original |
598 |
|
*/ |
599 |
|
public void testSerialization() throws Exception { |
600 |
< |
TreeMap q = map5(); |
600 |
> |
NavigableMap x = map5(); |
601 |
> |
NavigableMap y = serialClone(x); |
602 |
|
|
603 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
604 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
605 |
< |
out.writeObject(q); |
606 |
< |
out.close(); |
607 |
< |
|
611 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
612 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
613 |
< |
TreeMap r = (TreeMap)in.readObject(); |
614 |
< |
assertEquals(q.size(), r.size()); |
615 |
< |
assertTrue(q.equals(r)); |
616 |
< |
assertTrue(r.equals(q)); |
603 |
> |
assertTrue(x != y); |
604 |
> |
assertEquals(x.size(), y.size()); |
605 |
> |
assertEquals(x.toString(), y.toString()); |
606 |
> |
assertEquals(x, y); |
607 |
> |
assertEquals(y, x); |
608 |
|
} |
609 |
|
|
610 |
|
/** |
952 |
|
*/ |
953 |
|
void check(NavigableMap<Integer, Integer> map, |
954 |
|
final int min, final int max, final boolean ascending) { |
955 |
< |
class ReferenceSet { |
955 |
> |
class ReferenceSet { |
956 |
|
int lower(int key) { |
957 |
|
return ascending ? lowerAscending(key) : higherAscending(key); |
958 |
|
} |