318 |
|
} |
319 |
|
|
320 |
|
/** |
321 |
< |
* toArray contains all elements |
321 |
> |
* toArray contains all elements in FIFO order |
322 |
|
*/ |
323 |
|
public void testToArray() { |
324 |
|
LinkedList q = populatedQueue(SIZE); |
325 |
|
Object[] o = q.toArray(); |
326 |
– |
Arrays.sort(o); |
326 |
|
for (int i = 0; i < o.length; i++) |
327 |
< |
assertEquals(o[i], q.poll()); |
327 |
> |
assertSame(o[i], q.poll()); |
328 |
|
} |
329 |
|
|
330 |
|
/** |
331 |
< |
* toArray(a) contains all elements |
331 |
> |
* toArray(a) contains all elements in FIFO order |
332 |
|
*/ |
333 |
|
public void testToArray2() { |
334 |
|
LinkedList q = populatedQueue(SIZE); |
335 |
|
Integer[] ints = new Integer[SIZE]; |
336 |
< |
ints = (Integer[])q.toArray(ints); |
338 |
< |
Arrays.sort(ints); |
336 |
> |
assertSame(ints, q.toArray(ints)); |
337 |
|
for (int i = 0; i < ints.length; i++) |
338 |
< |
assertEquals(ints[i], q.poll()); |
338 |
> |
assertSame(ints[i], q.poll()); |
339 |
|
} |
340 |
|
|
341 |
|
/** |
342 |
< |
* toArray(null) throws NPE |
342 |
> |
* toArray(null) throws NullPointerException |
343 |
|
*/ |
344 |
< |
public void testToArray_BadArg() { |
344 |
> |
public void testToArray_NullArg() { |
345 |
|
LinkedList l = new LinkedList(); |
346 |
|
l.add(new Object()); |
347 |
|
try { |
348 |
< |
Object o[] = l.toArray(null); |
348 |
> |
l.toArray(null); |
349 |
|
shouldThrow(); |
350 |
|
} catch (NullPointerException success) {} |
351 |
|
} |
352 |
|
|
353 |
|
/** |
354 |
< |
* toArray with incompatible array type throws CCE |
354 |
> |
* toArray(incompatible array type) throws ArrayStoreException |
355 |
|
*/ |
356 |
|
public void testToArray1_BadArg() { |
357 |
|
LinkedList l = new LinkedList(); |
358 |
|
l.add(new Integer(5)); |
359 |
|
try { |
360 |
< |
Object o[] = l.toArray(new String[10]); |
360 |
> |
l.toArray(new String[10]); |
361 |
|
shouldThrow(); |
362 |
|
} catch (ArrayStoreException success) {} |
363 |
|
} |