commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwaldh...@apache.org
Subject cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections/iterators TestListIterator.java
Date Tue, 15 Apr 2003 00:27:37 GMT
rwaldhoff    2003/04/14 17:27:37

  Modified:    collections/src/test/org/apache/commons/collections/iterators
                        TestListIterator.java
  Log:
  implement some TestListIterator tests, hence clearing a TODO
  
  Revision  Changes    Path
  1.2       +31 -7     jakarta-commons/collections/src/test/org/apache/commons/collections/iterators/TestListIterator.java
  
  Index: TestListIterator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/iterators/TestListIterator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestListIterator.java	13 Apr 2003 23:26:09 -0000	1.1
  +++ TestListIterator.java	15 Apr 2003 00:27:37 -0000	1.2
  @@ -60,13 +60,13 @@
    */
   package org.apache.commons.collections.iterators;
   
  +import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.ListIterator;
  +
   /**
  - * @TODO implement me
  - * (Having this type around, even without specific tests, consolidates
  - * a bunch of "to dos" of the form "this should extend TestListIterator once
  - * it exists (see subclasses).
  + * @version $Revision$ $Date$ 
  + * @author Rodney Waldhoff
    */
   public abstract class TestListIterator extends TestIterator {
   
  @@ -86,4 +86,28 @@
           return makeFullListIterator();
       }
   
  +    // tests
  +
  +    public void testEmptyListIteratorIsIndeedEmpty() {
  +        ListIterator iter = makeEmptyListIterator();
  +        assertTrue(!iter.hasNext());
  +        assertTrue(!iter.hasPrevious());
  +    }
  +    
  +    public void testWalkForwardAndBack() {
  +        ArrayList list = new ArrayList();
  +        ListIterator iter = makeFullListIterator();
  +        while(iter.hasNext()) {
  +            list.add(iter.next());
  +        }
  +        for(int i = list.size()-1;i>=0;i--) {
  +            Object obj = list.get(i);
  +            if(null == obj) {
  +                assertNull(iter.previous());
  +            } else {
  +                assertEquals(obj,iter.previous());
  +            }
  +        }
  +        assertTrue(!iter.hasPrevious());
  +    }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message