ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/LinkedListTest.java
(Generate patch)

Comparing jsr166/src/test/tck/LinkedListTest.java (file contents):
Revision 1.8 by dl, Tue Dec 28 16:15:59 2004 UTC vs.
Revision 1.9 by dl, Wed Sep 14 23:50:31 2005 UTC

# Line 427 | Line 427 | public class LinkedListTest extends JSR1
427          assertFalse(it.hasNext());
428      }
429  
430 +    /**
431 +     *  Descending iterator iterates through all elements
432 +     */
433 +    public void testDescendingIterator() {
434 +        LinkedList q = populatedQueue(SIZE);
435 +        int i = 0;
436 +        Iterator it = q.descendingIterator();
437 +        while(it.hasNext()) {
438 +            assertTrue(q.contains(it.next()));
439 +            ++i;
440 +        }
441 +        assertEquals(i, SIZE);
442 +        assertFalse(it.hasNext());
443 +        try {
444 +            it.next();
445 +        } catch(NoSuchElementException success) {
446 +        }
447 +    }
448 +
449 +    /**
450 +     *  Descending iterator ordering is reverse FIFO
451 +     */
452 +    public void testDescendingIteratorOrdering() {
453 +        final LinkedList q = new LinkedList();
454 +        q.add(new Integer(3));
455 +        q.add(new Integer(2));
456 +        q.add(new Integer(1));
457 +        int k = 0;
458 +        for (Iterator it = q.descendingIterator(); it.hasNext();) {
459 +            int i = ((Integer)(it.next())).intValue();
460 +            assertEquals(++k, i);
461 +        }
462 +
463 +        assertEquals(3, k);
464 +    }
465 +
466 +    /**
467 +     * descendingIterator.remove removes current element
468 +     */
469 +    public void testDescendingIteratorRemove () {
470 +        final LinkedList q = new LinkedList();
471 +        q.add(new Integer(3));
472 +        q.add(new Integer(2));
473 +        q.add(new Integer(1));
474 +        Iterator it = q.descendingIterator();
475 +        it.next();
476 +        it.remove();
477 +        it = q.descendingIterator();
478 +        assertEquals(it.next(), new Integer(2));
479 +        assertEquals(it.next(), new Integer(3));
480 +        assertFalse(it.hasNext());
481 +    }
482 +
483  
484      /**
485       * toString contains toStrings of elements

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines