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 |
|
* Other contributors include Andrew Wright, Jeffrey Hayes, |
6 |
|
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
66 |
|
|
67 |
|
|
68 |
|
/** |
69 |
< |
* addAll adds each element from the given collection |
69 |
> |
* addAll adds each element from the given collection |
70 |
|
*/ |
71 |
|
public void testAddAll() { |
72 |
|
CopyOnWriteArrayList full = populatedArray(3); |
79 |
|
} |
80 |
|
|
81 |
|
/** |
82 |
< |
* addAllAbsent adds each element from the given collection that did not |
83 |
< |
* already exist in the List |
82 |
> |
* addAllAbsent adds each element from the given collection that did not |
83 |
> |
* already exist in the List |
84 |
|
*/ |
85 |
|
public void testAddAllAbsent() { |
86 |
|
CopyOnWriteArrayList full = populatedArray(3); |
93 |
|
} |
94 |
|
|
95 |
|
/** |
96 |
< |
* addIfAbsent will not add the element if it already exists in the list |
96 |
> |
* addIfAbsent will not add the element if it already exists in the list |
97 |
|
*/ |
98 |
|
public void testAddIfAbsent() { |
99 |
|
CopyOnWriteArrayList full = populatedArray(SIZE); |
102 |
|
} |
103 |
|
|
104 |
|
/** |
105 |
< |
* addIfAbsent adds the element when it does not exist in the list |
105 |
> |
* addIfAbsent adds the element when it does not exist in the list |
106 |
|
*/ |
107 |
|
public void testAddIfAbsent2() { |
108 |
|
CopyOnWriteArrayList full = populatedArray(SIZE); |
111 |
|
} |
112 |
|
|
113 |
|
/** |
114 |
< |
* clear removes all elements from the list |
114 |
> |
* clear removes all elements from the list |
115 |
|
*/ |
116 |
|
public void testClear() { |
117 |
|
CopyOnWriteArrayList full = populatedArray(SIZE); |
121 |
|
|
122 |
|
|
123 |
|
/** |
124 |
< |
* Cloned list is equal |
124 |
> |
* Cloned list is equal |
125 |
|
*/ |
126 |
|
public void testClone() { |
127 |
|
CopyOnWriteArrayList l1 = populatedArray(SIZE); |
132 |
|
} |
133 |
|
|
134 |
|
/** |
135 |
< |
* contains is true for added elements |
135 |
> |
* contains is true for added elements |
136 |
|
*/ |
137 |
|
public void testContains() { |
138 |
|
CopyOnWriteArrayList full = populatedArray(3); |
176 |
|
|
177 |
|
|
178 |
|
/** |
179 |
< |
* containsAll returns true for collection with subset of elements |
179 |
> |
* containsAll returns true for collection with subset of elements |
180 |
|
*/ |
181 |
|
public void testContainsAll() { |
182 |
|
CopyOnWriteArrayList full = populatedArray(3); |
189 |
|
} |
190 |
|
|
191 |
|
/** |
192 |
< |
* get returns the value at the given index |
192 |
> |
* get returns the value at the given index |
193 |
|
*/ |
194 |
|
public void testGet() { |
195 |
|
CopyOnWriteArrayList full = populatedArray(3); |
197 |
|
} |
198 |
|
|
199 |
|
/** |
200 |
< |
* indexOf gives the index for the given object |
200 |
> |
* indexOf gives the index for the given object |
201 |
|
*/ |
202 |
|
public void testIndexOf() { |
203 |
|
CopyOnWriteArrayList full = populatedArray(3); |
206 |
|
} |
207 |
|
|
208 |
|
/** |
209 |
< |
* indexOf gives the index based on the given index |
210 |
< |
* at which to start searching |
209 |
> |
* indexOf gives the index based on the given index |
210 |
> |
* at which to start searching |
211 |
|
*/ |
212 |
|
public void testIndexOf2() { |
213 |
|
CopyOnWriteArrayList full = populatedArray(3); |
216 |
|
} |
217 |
|
|
218 |
|
/** |
219 |
< |
* isEmpty returns true when empty, else false |
219 |
> |
* isEmpty returns true when empty, else false |
220 |
|
*/ |
221 |
|
public void testIsEmpty() { |
222 |
|
CopyOnWriteArrayList empty = new CopyOnWriteArrayList(); |
226 |
|
} |
227 |
|
|
228 |
|
/** |
229 |
< |
* iterator() returns an iterator containing the elements of the list |
229 |
> |
* iterator() returns an iterator containing the elements of the list |
230 |
|
*/ |
231 |
|
public void testIterator() { |
232 |
|
CopyOnWriteArrayList full = populatedArray(SIZE); |
262 |
|
} |
263 |
|
|
264 |
|
/** |
265 |
< |
* lastIndexOf returns the index for the given object |
265 |
> |
* lastIndexOf returns the index for the given object |
266 |
|
*/ |
267 |
|
public void testLastIndexOf1() { |
268 |
|
CopyOnWriteArrayList full = populatedArray(3); |
273 |
|
} |
274 |
|
|
275 |
|
/** |
276 |
< |
* lastIndexOf returns the index from the given starting point |
276 |
> |
* lastIndexOf returns the index from the given starting point |
277 |
|
*/ |
278 |
|
public void testlastIndexOf2() { |
279 |
|
CopyOnWriteArrayList full = populatedArray(3); |
284 |
|
} |
285 |
|
|
286 |
|
/** |
287 |
< |
* listIterator traverses all elements |
287 |
> |
* listIterator traverses all elements |
288 |
|
*/ |
289 |
|
public void testListIterator1() { |
290 |
|
CopyOnWriteArrayList full = populatedArray(SIZE); |
296 |
|
} |
297 |
|
|
298 |
|
/** |
299 |
< |
* listIterator only returns those elements after the given index |
299 |
> |
* listIterator only returns those elements after the given index |
300 |
|
*/ |
301 |
|
public void testListIterator2() { |
302 |
|
CopyOnWriteArrayList full = populatedArray(3); |
308 |
|
} |
309 |
|
|
310 |
|
/** |
311 |
< |
* remove removes and returns the object at the given index |
311 |
> |
* remove removes and returns the object at the given index |
312 |
|
*/ |
313 |
|
public void testRemove() { |
314 |
|
CopyOnWriteArrayList full = populatedArray(3); |
317 |
|
} |
318 |
|
|
319 |
|
/** |
320 |
< |
* removeAll removes all elements from the given collection |
320 |
> |
* removeAll removes all elements from the given collection |
321 |
|
*/ |
322 |
|
public void testRemoveAll() { |
323 |
|
CopyOnWriteArrayList full = populatedArray(3); |
329 |
|
} |
330 |
|
|
331 |
|
/** |
332 |
< |
* set changes the element at the given index |
332 |
> |
* set changes the element at the given index |
333 |
|
*/ |
334 |
|
public void testSet() { |
335 |
|
CopyOnWriteArrayList full = populatedArray(3); |
338 |
|
} |
339 |
|
|
340 |
|
/** |
341 |
< |
* size returns the number of elements |
341 |
> |
* size returns the number of elements |
342 |
|
*/ |
343 |
|
public void testSize() { |
344 |
|
CopyOnWriteArrayList empty = new CopyOnWriteArrayList(); |
348 |
|
} |
349 |
|
|
350 |
|
/** |
351 |
< |
* toArray returns an Object array containing all elements from the list |
351 |
> |
* toArray returns an Object array containing all elements from the list |
352 |
|
*/ |
353 |
|
public void testToArray() { |
354 |
|
CopyOnWriteArrayList full = populatedArray(3); |
360 |
|
} |
361 |
|
|
362 |
|
/** |
363 |
< |
* toArray returns an Integer array containing all elements from |
364 |
< |
* the list |
363 |
> |
* toArray returns an Integer array containing all elements from |
364 |
> |
* the list |
365 |
|
*/ |
366 |
|
public void testToArray2() { |
367 |
|
CopyOnWriteArrayList full = populatedArray(3); |
400 |
|
// Exception tests |
401 |
|
|
402 |
|
/** |
403 |
< |
* toArray throws an ArrayStoreException when the given array |
404 |
< |
* can not store the objects inside the list |
403 |
> |
* toArray throws an ArrayStoreException when the given array |
404 |
> |
* can not store the objects inside the list |
405 |
|
*/ |
406 |
|
public void testToArray_ArrayStoreException() { |
407 |
|
try { |
414 |
|
} |
415 |
|
|
416 |
|
/** |
417 |
< |
* get throws an IndexOutOfBoundsException on a negative index |
417 |
> |
* get throws an IndexOutOfBoundsException on a negative index |
418 |
|
*/ |
419 |
|
public void testGet1_IndexOutOfBoundsException() { |
420 |
|
try { |
425 |
|
} |
426 |
|
|
427 |
|
/** |
428 |
< |
* get throws an IndexOutOfBoundsException on a too high index |
428 |
> |
* get throws an IndexOutOfBoundsException on a too high index |
429 |
|
*/ |
430 |
|
public void testGet2_IndexOutOfBoundsException() { |
431 |
|
try { |
438 |
|
} |
439 |
|
|
440 |
|
/** |
441 |
< |
* set throws an IndexOutOfBoundsException on a negative index |
441 |
> |
* set throws an IndexOutOfBoundsException on a negative index |
442 |
|
*/ |
443 |
|
public void testSet1_IndexOutOfBoundsException() { |
444 |
|
try { |
449 |
|
} |
450 |
|
|
451 |
|
/** |
452 |
< |
* set throws an IndexOutOfBoundsException on a too high index |
452 |
> |
* set throws an IndexOutOfBoundsException on a too high index |
453 |
|
*/ |
454 |
|
public void testSet2() { |
455 |
|
try { |
462 |
|
} |
463 |
|
|
464 |
|
/** |
465 |
< |
* add throws an IndexOutOfBoundsException on a negative index |
465 |
> |
* add throws an IndexOutOfBoundsException on a negative index |
466 |
|
*/ |
467 |
|
public void testAdd1_IndexOutOfBoundsException() { |
468 |
|
try { |
473 |
|
} |
474 |
|
|
475 |
|
/** |
476 |
< |
* add throws an IndexOutOfBoundsException on a too high index |
476 |
> |
* add throws an IndexOutOfBoundsException on a too high index |
477 |
|
*/ |
478 |
|
public void testAdd2_IndexOutOfBoundsException() { |
479 |
|
try { |
486 |
|
} |
487 |
|
|
488 |
|
/** |
489 |
< |
* remove throws an IndexOutOfBoundsException on a negative index |
489 |
> |
* remove throws an IndexOutOfBoundsException on a negative index |
490 |
|
*/ |
491 |
|
public void testRemove1_IndexOutOfBounds() { |
492 |
|
try { |
497 |
|
} |
498 |
|
|
499 |
|
/** |
500 |
< |
* remove throws an IndexOutOfBoundsException on a too high index |
500 |
> |
* remove throws an IndexOutOfBoundsException on a too high index |
501 |
|
*/ |
502 |
|
public void testRemove2_IndexOutOfBounds() { |
503 |
|
try { |
510 |
|
} |
511 |
|
|
512 |
|
/** |
513 |
< |
* addAll throws an IndexOutOfBoundsException on a negative index |
513 |
> |
* addAll throws an IndexOutOfBoundsException on a negative index |
514 |
|
*/ |
515 |
|
public void testAddAll1_IndexOutOfBoundsException() { |
516 |
|
try { |
521 |
|
} |
522 |
|
|
523 |
|
/** |
524 |
< |
* addAll throws an IndexOutOfBoundsException on a too high index |
524 |
> |
* addAll throws an IndexOutOfBoundsException on a too high index |
525 |
|
*/ |
526 |
|
public void testAddAll2_IndexOutOfBoundsException() { |
527 |
|
try { |
534 |
|
} |
535 |
|
|
536 |
|
/** |
537 |
< |
* listIterator throws an IndexOutOfBoundsException on a negative index |
537 |
> |
* listIterator throws an IndexOutOfBoundsException on a negative index |
538 |
|
*/ |
539 |
|
public void testListIterator1_IndexOutOfBoundsException() { |
540 |
|
try { |
545 |
|
} |
546 |
|
|
547 |
|
/** |
548 |
< |
* listIterator throws an IndexOutOfBoundsException on a too high index |
548 |
> |
* listIterator throws an IndexOutOfBoundsException on a too high index |
549 |
|
*/ |
550 |
|
public void testListIterator2_IndexOutOfBoundsException() { |
551 |
|
try { |
558 |
|
} |
559 |
|
|
560 |
|
/** |
561 |
< |
* subList throws an IndexOutOfBoundsException on a negative index |
561 |
> |
* subList throws an IndexOutOfBoundsException on a negative index |
562 |
|
*/ |
563 |
|
public void testSubList1_IndexOutOfBoundsException() { |
564 |
|
try { |
569 |
|
} |
570 |
|
|
571 |
|
/** |
572 |
< |
* subList throws an IndexOutOfBoundsException on a too high index |
572 |
> |
* subList throws an IndexOutOfBoundsException on a too high index |
573 |
|
*/ |
574 |
|
public void testSubList2_IndexOutOfBoundsException() { |
575 |
|
try { |
581 |
|
} |
582 |
|
|
583 |
|
/** |
584 |
< |
* subList throws IndexOutOfBoundsException when the second index |
585 |
< |
* is lower then the first |
584 |
> |
* subList throws IndexOutOfBoundsException when the second index |
585 |
> |
* is lower then the first |
586 |
|
*/ |
587 |
|
public void testSubList3_IndexOutOfBoundsException() { |
588 |
|
try { |