1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
|
import junit.framework.*; |
34 |
|
} |
35 |
|
|
36 |
|
/** |
37 |
< |
* clear removes all pairs |
37 |
> |
* clear removes all pairs |
38 |
|
*/ |
39 |
|
public void testClear() { |
40 |
|
ConcurrentSkipListMap 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 |
|
ConcurrentSkipListMap 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 |
|
ConcurrentSkipListMap 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 |
|
ConcurrentSkipListMap 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 |
|
ConcurrentSkipListMap 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 |
|
ConcurrentSkipListMap empty = new ConcurrentSkipListMap(); |
104 |
|
} |
105 |
|
|
106 |
|
/** |
107 |
< |
* firstKey returns first key |
107 |
> |
* firstKey returns first key |
108 |
|
*/ |
109 |
|
public void testFirstKey() { |
110 |
|
ConcurrentSkipListMap map = map5(); |
112 |
|
} |
113 |
|
|
114 |
|
/** |
115 |
< |
* lastKey returns last key |
115 |
> |
* lastKey returns last key |
116 |
|
*/ |
117 |
|
public void testLastKey() { |
118 |
|
ConcurrentSkipListMap 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 |
|
ConcurrentSkipListMap 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 |
|
ConcurrentSkipListMap 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 |
|
ConcurrentSkipListMap map = map5(); |
161 |
|
} |
162 |
|
|
163 |
|
/** |
164 |
< |
* keySet is ordered |
164 |
> |
* keySet is ordered |
165 |
|
*/ |
166 |
|
public void testKeySetOrder() { |
167 |
|
ConcurrentSkipListMap map = map5(); |
199 |
|
} |
200 |
|
|
201 |
|
/** |
202 |
< |
* descendingKeySet is ordered |
202 |
> |
* descendingKeySet is ordered |
203 |
|
*/ |
204 |
|
public void testDescendingKeySetOrder() { |
205 |
|
ConcurrentSkipListMap 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 |
|
ConcurrentSkipListMap map = map5(); |
237 |
|
} |
238 |
|
|
239 |
|
/** |
240 |
< |
* Values.toArray contains all values |
240 |
> |
* Values.toArray contains all values |
241 |
|
*/ |
242 |
|
public void testValuesToArray() { |
243 |
|
ConcurrentSkipListMap map = map5(); |
305 |
|
} |
306 |
|
|
307 |
|
/** |
308 |
< |
* entrySet.toArray contains all entries |
308 |
> |
* entrySet.toArray contains all entries |
309 |
|
*/ |
310 |
|
public void testEntrySetToArray() { |
311 |
|
ConcurrentSkipListMap map = map5(); |
319 |
|
} |
320 |
|
|
321 |
|
/** |
322 |
< |
* descendingEntrySet.toArray contains all entries |
322 |
> |
* descendingEntrySet.toArray contains all entries |
323 |
|
*/ |
324 |
|
public void testDescendingEntrySetToArray() { |
325 |
|
ConcurrentSkipListMap map = map5(); |
333 |
|
} |
334 |
|
|
335 |
|
/** |
336 |
< |
* putAll adds all key-value pairs from the given map |
336 |
> |
* putAll adds all key-value pairs from the given map |
337 |
|
*/ |
338 |
|
public void testPutAll() { |
339 |
|
ConcurrentSkipListMap empty = new ConcurrentSkipListMap(); |
348 |
|
} |
349 |
|
|
350 |
|
/** |
351 |
< |
* putIfAbsent works when the given key is not present |
351 |
> |
* putIfAbsent works when the given key is not present |
352 |
|
*/ |
353 |
|
public void testPutIfAbsent() { |
354 |
|
ConcurrentSkipListMap map = map5(); |
357 |
|
} |
358 |
|
|
359 |
|
/** |
360 |
< |
* putIfAbsent does not add the pair if the key is already present |
360 |
> |
* putIfAbsent does not add the pair if the key is already present |
361 |
|
*/ |
362 |
|
public void testPutIfAbsent2() { |
363 |
|
ConcurrentSkipListMap map = map5(); |
365 |
|
} |
366 |
|
|
367 |
|
/** |
368 |
< |
* replace fails when the given key is not present |
368 |
> |
* replace fails when the given key is not present |
369 |
|
*/ |
370 |
|
public void testReplace() { |
371 |
|
ConcurrentSkipListMap map = map5(); |
374 |
|
} |
375 |
|
|
376 |
|
/** |
377 |
< |
* replace succeeds if the key is already present |
377 |
> |
* replace succeeds if the key is already present |
378 |
|
*/ |
379 |
|
public void testReplace2() { |
380 |
|
ConcurrentSkipListMap map = map5(); |
405 |
|
|
406 |
|
|
407 |
|
/** |
408 |
< |
* remove removes the correct key-value pair from the map |
408 |
> |
* remove removes the correct key-value pair from the map |
409 |
|
*/ |
410 |
|
public void testRemove() { |
411 |
|
ConcurrentSkipListMap map = map5(); |
662 |
|
} |
663 |
|
|
664 |
|
/** |
665 |
< |
* size returns the correct values |
665 |
> |
* size returns the correct values |
666 |
|
*/ |
667 |
|
public void testSize() { |
668 |
|
ConcurrentSkipListMap map = map5(); |
980 |
|
* Submaps of submaps subdivide correctly |
981 |
|
*/ |
982 |
|
public void testRecursiveSubMaps() throws Exception { |
983 |
< |
int mapSize = 1000; |
983 |
> |
int mapSize = expensiveTests ? 1000 : 100; |
984 |
|
Class cl = ConcurrentSkipListMap.class; |
985 |
|
NavigableMap<Integer, Integer> map = newMap(cl); |
986 |
|
bs = new BitSet(mapSize); |
1192 |
|
// BitSet should support this! Test would run much faster |
1193 |
|
while (key >= min) { |
1194 |
|
if (bs.get(key)) |
1195 |
< |
return(key); |
1195 |
> |
return key; |
1196 |
|
key--; |
1197 |
|
} |
1198 |
|
return -1; |