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); |
34 |
|
} |
35 |
|
|
36 |
|
/** |
37 |
< |
* clear removes all pairs |
37 |
> |
* clear removes all pairs |
38 |
|
*/ |
39 |
|
public void testClear() { |
40 |
|
TreeMap map = map5(); |
52 |
|
} |
53 |
|
|
54 |
|
/** |
55 |
< |
* Maps with same contents are equal |
55 |
> |
* Maps with same contents are equal |
56 |
|
*/ |
57 |
|
public void testEquals() { |
58 |
|
TreeMap map1 = map5(); |
65 |
|
} |
66 |
|
|
67 |
|
/** |
68 |
< |
* containsKey returns true for contained key |
68 |
> |
* containsKey returns true for contained key |
69 |
|
*/ |
70 |
|
public void testContainsKey() { |
71 |
|
TreeMap map = map5(); |
74 |
|
} |
75 |
|
|
76 |
|
/** |
77 |
< |
* containsValue returns true for held values |
77 |
> |
* containsValue returns true for held values |
78 |
|
*/ |
79 |
|
public void testContainsValue() { |
80 |
|
TreeMap map = map5(); |
83 |
|
} |
84 |
|
|
85 |
|
/** |
86 |
< |
* get returns the correct element at the given key, |
87 |
< |
* or null if not present |
86 |
> |
* get returns the correct element at the given key, |
87 |
> |
* or null if not present |
88 |
|
*/ |
89 |
|
public void testGet() { |
90 |
|
TreeMap map = map5(); |
94 |
|
} |
95 |
|
|
96 |
|
/** |
97 |
< |
* isEmpty is true of empty map and false for non-empty |
97 |
> |
* isEmpty is true of empty map and false for non-empty |
98 |
|
*/ |
99 |
|
public void testIsEmpty() { |
100 |
|
TreeMap empty = new TreeMap(); |
104 |
|
} |
105 |
|
|
106 |
|
/** |
107 |
< |
* firstKey returns first key |
107 |
> |
* firstKey returns first key |
108 |
|
*/ |
109 |
|
public void testFirstKey() { |
110 |
|
TreeMap map = map5(); |
112 |
|
} |
113 |
|
|
114 |
|
/** |
115 |
< |
* lastKey returns last key |
115 |
> |
* lastKey returns last key |
116 |
|
*/ |
117 |
|
public void testLastKey() { |
118 |
|
TreeMap map = map5(); |
121 |
|
|
122 |
|
|
123 |
|
/** |
124 |
< |
* keySet.toArray returns contains all keys |
124 |
> |
* keySet.toArray returns contains all keys |
125 |
|
*/ |
126 |
|
public void testKeySetToArray() { |
127 |
|
TreeMap map = map5(); |
134 |
|
} |
135 |
|
|
136 |
|
/** |
137 |
< |
* descendingkeySet.toArray returns contains all keys |
137 |
> |
* descendingkeySet.toArray returns contains all keys |
138 |
|
*/ |
139 |
|
public void testDescendingKeySetToArray() { |
140 |
|
TreeMap map = map5(); |
147 |
|
} |
148 |
|
|
149 |
|
/** |
150 |
< |
* keySet returns a Set containing all the keys |
150 |
> |
* keySet returns a Set containing all the keys |
151 |
|
*/ |
152 |
|
public void testKeySet() { |
153 |
|
TreeMap map = map5(); |
161 |
|
} |
162 |
|
|
163 |
|
/** |
164 |
< |
* keySet is ordered |
164 |
> |
* keySet is ordered |
165 |
|
*/ |
166 |
|
public void testKeySetOrder() { |
167 |
|
TreeMap map = map5(); |
199 |
|
} |
200 |
|
|
201 |
|
/** |
202 |
< |
* descendingKeySet is ordered |
202 |
> |
* descendingKeySet is ordered |
203 |
|
*/ |
204 |
|
public void testDescendingKeySetOrder() { |
205 |
|
TreeMap map = map5(); |
218 |
|
} |
219 |
|
|
220 |
|
/** |
221 |
< |
* descending iterator of descendingKeySet is ordered |
221 |
> |
* descending iterator of descendingKeySet is ordered |
222 |
|
*/ |
223 |
|
public void testDescendingKeySetDescendingIteratorOrder() { |
224 |
|
TreeMap map = map5(); |
289 |
|
} |
290 |
|
|
291 |
|
/** |
292 |
< |
* entrySet.toArray contains all entries |
292 |
> |
* entrySet.toArray contains all entries |
293 |
|
*/ |
294 |
|
public void testEntrySetToArray() { |
295 |
|
TreeMap map = map5(); |
303 |
|
} |
304 |
|
|
305 |
|
/** |
306 |
< |
* descendingEntrySet.toArray contains all entries |
306 |
> |
* descendingEntrySet.toArray contains all entries |
307 |
|
*/ |
308 |
|
public void testDescendingEntrySetToArray() { |
309 |
|
TreeMap map = map5(); |
317 |
|
} |
318 |
|
|
319 |
|
/** |
320 |
< |
* putAll adds all key-value pairs from the given map |
320 |
> |
* putAll adds all key-value pairs from the given map |
321 |
|
*/ |
322 |
|
public void testPutAll() { |
323 |
|
TreeMap empty = new TreeMap(); |
332 |
|
} |
333 |
|
|
334 |
|
/** |
335 |
< |
* remove removes the correct key-value pair from the map |
335 |
> |
* remove removes the correct key-value pair from the map |
336 |
|
*/ |
337 |
|
public void testRemove() { |
338 |
|
TreeMap map = map5(); |
357 |
|
|
358 |
|
Map.Entry e4 = map.lowerEntry(zero); |
359 |
|
assertNull(e4); |
360 |
– |
|
360 |
|
} |
361 |
|
|
362 |
|
/** |
375 |
|
|
376 |
|
Map.Entry e4 = map.higherEntry(six); |
377 |
|
assertNull(e4); |
379 |
– |
|
378 |
|
} |
379 |
|
|
380 |
|
/** |
393 |
|
|
394 |
|
Map.Entry e4 = map.floorEntry(zero); |
395 |
|
assertNull(e4); |
398 |
– |
|
396 |
|
} |
397 |
|
|
398 |
|
/** |
411 |
|
|
412 |
|
Map.Entry e4 = map.ceilingEntry(six); |
413 |
|
assertNull(e4); |
417 |
– |
|
414 |
|
} |
415 |
|
|
416 |
|
|
430 |
|
|
431 |
|
Object e4 = q.lowerKey(zero); |
432 |
|
assertNull(e4); |
437 |
– |
|
433 |
|
} |
434 |
|
|
435 |
|
/** |
448 |
|
|
449 |
|
Object e4 = q.higherKey(six); |
450 |
|
assertNull(e4); |
456 |
– |
|
451 |
|
} |
452 |
|
|
453 |
|
/** |
466 |
|
|
467 |
|
Object e4 = q.floorKey(zero); |
468 |
|
assertNull(e4); |
475 |
– |
|
469 |
|
} |
470 |
|
|
471 |
|
/** |
484 |
|
|
485 |
|
Object e4 = q.ceilingKey(six); |
486 |
|
assertNull(e4); |
494 |
– |
|
487 |
|
} |
488 |
|
|
489 |
|
/** |
541 |
|
} |
542 |
|
|
543 |
|
/** |
544 |
< |
* size returns the correct values |
544 |
> |
* size returns the correct values |
545 |
|
*/ |
546 |
|
public void testSize() { |
547 |
|
TreeMap map = map5(); |
652 |
|
assertEquals(1, sm.size()); |
653 |
|
assertEquals(three, sm.firstKey()); |
654 |
|
assertEquals(three, sm.lastKey()); |
655 |
< |
assertTrue(sm.remove(three) != null); |
655 |
> |
assertEquals("C", sm.remove(three)); |
656 |
|
assertTrue(sm.isEmpty()); |
657 |
|
assertEquals(3, map.size()); |
658 |
|
} |
685 |
|
assertEquals(4, map.size()); |
686 |
|
assertEquals(0, sm.size()); |
687 |
|
assertTrue(sm.isEmpty()); |
688 |
< |
assertTrue(sm.remove(three) == null); |
688 |
> |
assertSame(sm.remove(three), null); |
689 |
|
assertEquals(4, map.size()); |
690 |
|
} |
691 |
|
|
767 |
|
NavigableMap ssm = sm.tailMap(four, true); |
768 |
|
assertEquals(four, ssm.firstKey()); |
769 |
|
assertEquals(five, ssm.lastKey()); |
770 |
< |
assertTrue(ssm.remove(four) != null); |
770 |
> |
assertEquals("D", ssm.remove(four)); |
771 |
|
assertEquals(1, ssm.size()); |
772 |
|
assertEquals(3, sm.size()); |
773 |
|
assertEquals(4, map.size()); |
992 |
|
// BitSet should support this! Test would run much faster |
993 |
|
while (key >= min) { |
994 |
|
if (bs.get(key)) |
995 |
< |
return(key); |
995 |
> |
return key; |
996 |
|
key--; |
997 |
|
} |
998 |
|
return -1; |