6 |
|
|
7 |
|
import junit.framework.*; |
8 |
|
import java.util.*; |
9 |
– |
import java.util.concurrent.*; |
10 |
– |
import java.io.*; |
9 |
|
|
10 |
|
public class TreeSubMapTest extends JSR166TestCase { |
11 |
|
public static void main(String[] args) { |
67 |
|
public void testClear() { |
68 |
|
NavigableMap map = map5(); |
69 |
|
map.clear(); |
70 |
< |
assertEquals(map.size(), 0); |
70 |
> |
assertEquals(0, map.size()); |
71 |
|
} |
72 |
|
|
75 |
– |
|
73 |
|
/** |
74 |
|
* Maps with same contents are equal |
75 |
|
*/ |
138 |
|
assertEquals(five, map.lastKey()); |
139 |
|
} |
140 |
|
|
144 |
– |
|
141 |
|
/** |
142 |
|
* keySet returns a Set containing all the keys |
143 |
|
*/ |
426 |
|
* A deserialized map equals original |
427 |
|
*/ |
428 |
|
public void testSerialization() throws Exception { |
429 |
< |
NavigableMap q = map5(); |
429 |
> |
NavigableMap x = map5(); |
430 |
> |
NavigableMap y = serialClone(x); |
431 |
|
|
432 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
433 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
434 |
< |
out.writeObject(q); |
435 |
< |
out.close(); |
436 |
< |
|
440 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
441 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
442 |
< |
NavigableMap r = (NavigableMap)in.readObject(); |
443 |
< |
assertFalse(r.isEmpty()); |
444 |
< |
assertEquals(q.size(), r.size()); |
445 |
< |
assertTrue(q.equals(r)); |
446 |
< |
assertTrue(r.equals(q)); |
432 |
> |
assertTrue(x != y); |
433 |
> |
assertEquals(x.size(), y.size()); |
434 |
> |
assertEquals(x.toString(), y.toString()); |
435 |
> |
assertEquals(x, y); |
436 |
> |
assertEquals(y, x); |
437 |
|
} |
438 |
|
|
449 |
– |
|
450 |
– |
|
439 |
|
/** |
440 |
|
* subMap returns map with keys in requested range |
441 |
|
*/ |
577 |
|
public void testDescendingClear() { |
578 |
|
NavigableMap map = dmap5(); |
579 |
|
map.clear(); |
580 |
< |
assertEquals(map.size(), 0); |
580 |
> |
assertEquals(0, map.size()); |
581 |
|
} |
582 |
|
|
595 |
– |
|
583 |
|
/** |
584 |
|
* Maps with same contents are equal |
585 |
|
*/ |
648 |
|
assertEquals(m5, map.lastKey()); |
649 |
|
} |
650 |
|
|
664 |
– |
|
651 |
|
/** |
652 |
|
* keySet returns a Set containing all the keys |
653 |
|
*/ |
734 |
|
assertTrue(s.contains("E")); |
735 |
|
} |
736 |
|
|
751 |
– |
|
737 |
|
/** |
738 |
|
* entrySet contains all pairs |
739 |
|
*/ |
768 |
|
assertTrue(empty.containsKey(m5)); |
769 |
|
} |
770 |
|
|
786 |
– |
|
771 |
|
/** |
772 |
|
* remove removes the correct key-value pair from the map |
773 |
|
*/ |
953 |
|
* A deserialized map equals original |
954 |
|
*/ |
955 |
|
public void testDescendingSerialization() throws Exception { |
956 |
< |
NavigableMap q = dmap5(); |
956 |
> |
NavigableMap x = dmap5(); |
957 |
> |
NavigableMap y = serialClone(x); |
958 |
|
|
959 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
960 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
961 |
< |
out.writeObject(q); |
962 |
< |
out.close(); |
963 |
< |
|
979 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
980 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
981 |
< |
NavigableMap r = (NavigableMap)in.readObject(); |
982 |
< |
assertEquals(q.size(), r.size()); |
983 |
< |
assertTrue(q.equals(r)); |
984 |
< |
assertTrue(r.equals(q)); |
959 |
> |
assertTrue(x != y); |
960 |
> |
assertEquals(x.size(), y.size()); |
961 |
> |
assertEquals(x.toString(), y.toString()); |
962 |
> |
assertEquals(x, y); |
963 |
> |
assertEquals(y, x); |
964 |
|
} |
965 |
|
|
987 |
– |
|
966 |
|
/** |
967 |
|
* subMap returns map with keys in requested range |
968 |
|
*/ |