12 |
|
|
13 |
|
public class LinkedListTest extends JSR166TestCase { |
14 |
|
public static void main(String[] args) { |
15 |
< |
junit.textui.TestRunner.run (suite()); |
15 |
> |
junit.textui.TestRunner.run(suite()); |
16 |
|
} |
17 |
|
|
18 |
|
public static Test suite() { |
174 |
|
} |
175 |
|
|
176 |
|
/** |
177 |
< |
* poll succeeds unless empty |
177 |
> |
* poll succeeds unless empty |
178 |
|
*/ |
179 |
|
public void testPoll() { |
180 |
|
LinkedList q = populatedQueue(SIZE); |
185 |
|
} |
186 |
|
|
187 |
|
/** |
188 |
< |
* peek returns next element, or null if empty |
188 |
> |
* peek returns next element, or null if empty |
189 |
|
*/ |
190 |
|
public void testPeek() { |
191 |
|
LinkedList q = populatedQueue(SIZE); |
214 |
|
} |
215 |
|
|
216 |
|
/** |
217 |
< |
* remove removes next element, or throws NSEE if empty |
217 |
> |
* remove removes next element, or throws NSEE if empty |
218 |
|
*/ |
219 |
|
public void testRemove() { |
220 |
|
LinkedList q = populatedQueue(SIZE); |
318 |
|
} |
319 |
|
|
320 |
|
/** |
321 |
< |
* toArray contains all elements |
321 |
> |
* toArray contains all elements |
322 |
|
*/ |
323 |
|
public void testToArray() { |
324 |
|
LinkedList q = populatedQueue(SIZE); |
329 |
|
} |
330 |
|
|
331 |
|
/** |
332 |
< |
* toArray(a) contains all elements |
332 |
> |
* toArray(a) contains all elements |
333 |
|
*/ |
334 |
|
public void testToArray2() { |
335 |
|
LinkedList q = populatedQueue(SIZE); |
353 |
|
} |
354 |
|
|
355 |
|
/** |
356 |
< |
* toArray with incompatable aray type throws CCE |
356 |
> |
* toArray(incompatible array type) throws ArrayStoreException |
357 |
|
*/ |
358 |
|
public void testToArray1_BadArg() { |
359 |
|
LinkedList l = new LinkedList(); |
360 |
|
l.add(new Integer(5)); |
361 |
|
try { |
362 |
< |
Object o[] = l.toArray(new String[10]); |
362 |
> |
l.toArray(new String[10]); |
363 |
|
shouldThrow(); |
364 |
|
} catch (ArrayStoreException success) {} |
365 |
|
} |
366 |
|
|
367 |
|
/** |
368 |
< |
* iterator iterates through all elements |
368 |
> |
* iterator iterates through all elements |
369 |
|
*/ |
370 |
|
public void testIterator() { |
371 |
|
LinkedList q = populatedQueue(SIZE); |
379 |
|
} |
380 |
|
|
381 |
|
/** |
382 |
< |
* iterator ordering is FIFO |
382 |
> |
* iterator ordering is FIFO |
383 |
|
*/ |
384 |
|
public void testIteratorOrdering() { |
385 |
|
final LinkedList q = new LinkedList(); |
397 |
|
/** |
398 |
|
* iterator.remove removes current element |
399 |
|
*/ |
400 |
< |
public void testIteratorRemove () { |
400 |
> |
public void testIteratorRemove() { |
401 |
|
final LinkedList q = new LinkedList(); |
402 |
|
q.add(new Integer(1)); |
403 |
|
q.add(new Integer(2)); |
412 |
|
} |
413 |
|
|
414 |
|
/** |
415 |
< |
* Descending iterator iterates through all elements |
415 |
> |
* Descending iterator iterates through all elements |
416 |
|
*/ |
417 |
|
public void testDescendingIterator() { |
418 |
|
LinkedList q = populatedQueue(SIZE); |
431 |
|
} |
432 |
|
|
433 |
|
/** |
434 |
< |
* Descending iterator ordering is reverse FIFO |
434 |
> |
* Descending iterator ordering is reverse FIFO |
435 |
|
*/ |
436 |
|
public void testDescendingIteratorOrdering() { |
437 |
|
final LinkedList q = new LinkedList(); |
449 |
|
/** |
450 |
|
* descendingIterator.remove removes current element |
451 |
|
*/ |
452 |
< |
public void testDescendingIteratorRemove () { |
452 |
> |
public void testDescendingIteratorRemove() { |
453 |
|
final LinkedList q = new LinkedList(); |
454 |
< |
q.add(new Integer(3)); |
455 |
< |
q.add(new Integer(2)); |
456 |
< |
q.add(new Integer(1)); |
454 |
> |
q.add(three); |
455 |
> |
q.add(two); |
456 |
> |
q.add(one); |
457 |
|
Iterator it = q.descendingIterator(); |
458 |
|
it.next(); |
459 |
|
it.remove(); |
460 |
|
it = q.descendingIterator(); |
461 |
< |
assertEquals(it.next(), 2); |
462 |
< |
assertEquals(it.next(), 3); |
461 |
> |
assertSame(it.next(), two); |
462 |
> |
assertSame(it.next(), three); |
463 |
|
assertFalse(it.hasNext()); |
464 |
|
} |
465 |
|
|
481 |
|
public void testAddFirst() { |
482 |
|
LinkedList q = populatedQueue(3); |
483 |
|
q.addFirst(four); |
484 |
< |
assertEquals(four,q.peek()); |
484 |
> |
assertSame(four, q.peek()); |
485 |
|
} |
486 |
|
|
487 |
|
/** |
489 |
|
*/ |
490 |
|
public void testPush() { |
491 |
|
LinkedList q = populatedQueue(3); |
492 |
– |
q.pollLast(); |
492 |
|
q.push(four); |
493 |
< |
assertEquals(four,q.peekFirst()); |
493 |
> |
assertSame(four, q.peekFirst()); |
494 |
|
} |
495 |
|
|
496 |
|
/** |
497 |
< |
* pop removes next element, or throws NSEE if empty |
497 |
> |
* pop removes next element, or throws NSEE if empty |
498 |
|
*/ |
499 |
|
public void testPop() { |
500 |
|
LinkedList q = populatedQueue(SIZE); |
526 |
|
} |
527 |
|
|
528 |
|
/** |
529 |
< |
* pollLast succeeds unless empty |
529 |
> |
* pollLast succeeds unless empty |
530 |
|
*/ |
531 |
|
public void testPollLast() { |
532 |
|
LinkedList q = populatedQueue(SIZE); |
537 |
|
} |
538 |
|
|
539 |
|
/** |
540 |
< |
* peekFirst returns next element, or null if empty |
540 |
> |
* peekFirst returns next element, or null if empty |
541 |
|
*/ |
542 |
|
public void testPeekFirst() { |
543 |
|
LinkedList q = populatedQueue(SIZE); |
552 |
|
|
553 |
|
|
554 |
|
/** |
555 |
< |
* peekLast returns next element, or null if empty |
555 |
> |
* peekLast returns next element, or null if empty |
556 |
|
*/ |
557 |
|
public void testPeekLast() { |
558 |
|
LinkedList q = populatedQueue(SIZE); |
578 |
|
} |
579 |
|
|
580 |
|
/** |
581 |
< |
* getLast returns next element, or throws NSEE if empty |
581 |
> |
* getLast returns next element, or throws NSEE if empty |
582 |
|
*/ |
583 |
|
public void testLastElement() { |
584 |
|
LinkedList q = populatedQueue(SIZE); |