25 |
|
return new TestSuite(CopyOnWriteArrayListTest.class); |
26 |
|
} |
27 |
|
|
28 |
< |
static CopyOnWriteArrayList populatedArray(int n) { |
29 |
< |
CopyOnWriteArrayList a = new CopyOnWriteArrayList(); |
28 |
> |
static CopyOnWriteArrayList<Integer> populatedArray(int n) { |
29 |
> |
CopyOnWriteArrayList<Integer> a |
30 |
> |
= new CopyOnWriteArrayList<Integer>(); |
31 |
|
assertTrue(a.isEmpty()); |
32 |
|
for (int i = 0; i < n; ++i) |
33 |
< |
a.add(new Integer(i)); |
33 |
> |
a.add(i); |
34 |
|
assertFalse(a.isEmpty()); |
35 |
|
assertEquals(n, a.size()); |
36 |
|
return a; |
365 |
|
* the list |
366 |
|
*/ |
367 |
|
public void testToArray2() { |
368 |
< |
CopyOnWriteArrayList full = populatedArray(3); |
369 |
< |
Integer[] i = new Integer[3]; |
370 |
< |
i = (Integer[])full.toArray(i); |
371 |
< |
assertEquals(3, i.length); |
372 |
< |
assertEquals(0, i[0].intValue()); |
373 |
< |
assertEquals(1, i[1].intValue()); |
374 |
< |
assertEquals(2, i[2].intValue()); |
368 |
> |
final int size = 3; |
369 |
> |
CopyOnWriteArrayList<Integer> full = populatedArray(size); |
370 |
> |
Integer[] ints = new Integer[size]; |
371 |
> |
assertSame(ints, full.toArray(ints)); |
372 |
> |
Iterator<Integer> it = full.iterator(); |
373 |
> |
for (int i = 0; i < size; i++) |
374 |
> |
assertSame(ints[i], it.next()); |
375 |
> |
assertFalse(it.hasNext()); |
376 |
|
} |
377 |
|
|
378 |
|
/** |