26 |
|
private LinkedList populatedQueue(int n) { |
27 |
|
LinkedList q = new LinkedList(); |
28 |
|
assertTrue(q.isEmpty()); |
29 |
< |
for(int i = 0; i < n; ++i) |
29 |
> |
for (int i = 0; i < n; ++i) |
30 |
|
assertTrue(q.offer(new Integer(i))); |
31 |
|
assertFalse(q.isEmpty()); |
32 |
|
assertEquals(n, q.size()); |
169 |
|
m.add(new Object()); |
170 |
|
l.addAll(4,m); |
171 |
|
shouldThrow(); |
172 |
< |
} catch(IndexOutOfBoundsException success) {} |
172 |
> |
} catch (IndexOutOfBoundsException success) {} |
173 |
|
} |
174 |
|
|
175 |
|
/** |
183 |
|
m.add(new Object()); |
184 |
|
l.addAll(-1,m); |
185 |
|
shouldThrow(); |
186 |
< |
} catch(IndexOutOfBoundsException success){} |
186 |
> |
} catch (IndexOutOfBoundsException success){} |
187 |
|
} |
188 |
|
|
189 |
|
/** |
339 |
|
LinkedList q = populatedQueue(SIZE); |
340 |
|
Object[] o = q.toArray(); |
341 |
|
Arrays.sort(o); |
342 |
< |
for(int i = 0; i < o.length; i++) |
342 |
> |
for (int i = 0; i < o.length; i++) |
343 |
|
assertEquals(o[i], q.poll()); |
344 |
|
} |
345 |
|
|
351 |
|
Integer[] ints = new Integer[SIZE]; |
352 |
|
ints = (Integer[])q.toArray(ints); |
353 |
|
Arrays.sort(ints); |
354 |
< |
for(int i = 0; i < ints.length; i++) |
354 |
> |
for (int i = 0; i < ints.length; i++) |
355 |
|
assertEquals(ints[i], q.poll()); |
356 |
|
} |
357 |
|
|
364 |
|
l.add(new Object()); |
365 |
|
Object o[] = l.toArray(null); |
366 |
|
shouldThrow(); |
367 |
< |
} catch(NullPointerException success){} |
367 |
> |
} catch (NullPointerException success){} |
368 |
|
} |
369 |
|
|
370 |
|
/** |
376 |
|
l.add(new Integer(5)); |
377 |
|
Object o[] = l.toArray(new String[10] ); |
378 |
|
shouldThrow(); |
379 |
< |
} catch(ArrayStoreException success){} |
379 |
> |
} catch (ArrayStoreException success){} |
380 |
|
} |
381 |
|
|
382 |
|
/** |
386 |
|
LinkedList q = populatedQueue(SIZE); |
387 |
|
int i = 0; |
388 |
|
Iterator it = q.iterator(); |
389 |
< |
while(it.hasNext()) { |
389 |
> |
while (it.hasNext()) { |
390 |
|
assertTrue(q.contains(it.next())); |
391 |
|
++i; |
392 |
|
} |
434 |
|
LinkedList q = populatedQueue(SIZE); |
435 |
|
int i = 0; |
436 |
|
Iterator it = q.descendingIterator(); |
437 |
< |
while(it.hasNext()) { |
437 |
> |
while (it.hasNext()) { |
438 |
|
assertTrue(q.contains(it.next())); |
439 |
|
++i; |
440 |
|
} |
442 |
|
assertFalse(it.hasNext()); |
443 |
|
try { |
444 |
|
it.next(); |
445 |
< |
} catch(NoSuchElementException success) { |
445 |
> |
} catch (NoSuchElementException success) { |
446 |
|
} |
447 |
|
} |
448 |
|
|