You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by mo...@apache.org on 2002/03/19 01:05:16 UTC
cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections TestArrayIterator2.java
morgand 02/03/18 16:05:16
Modified: collections/src/test/org/apache/commons/collections
TestArrayIterator2.java
Log:
using the setArray(Object) method no longer produces an out of bounds
exception
Revision Changes Path
1.3 +29 -4 jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayIterator2.java
Index: TestArrayIterator2.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayIterator2.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestArrayIterator2.java 25 Feb 2002 22:48:52 -0000 1.2
+++ TestArrayIterator2.java 19 Mar 2002 00:05:16 -0000 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayIterator2.java,v 1.2 2002/02/25 22:48:52 morgand Exp $
- * $Revision: 1.2 $
- * $Date: 2002/02/25 22:48:52 $
+ * $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestArrayIterator2.java,v 1.3 2002/03/19 00:05:16 morgand Exp $
+ * $Revision: 1.3 $
+ * $Date: 2002/03/19 00:05:16 $
*
* ====================================================================
*
@@ -70,7 +70,7 @@
*
* @author Morgan Delagrange
* @author James Strachan
- * @version $Id: TestArrayIterator2.java,v 1.2 2002/02/25 22:48:52 morgand Exp $
+ * @version $Id: TestArrayIterator2.java,v 1.3 2002/03/19 00:05:16 morgand Exp $
*/
public class TestArrayIterator2 extends TestIterator {
@@ -118,6 +118,31 @@
assertTrue("NoSuchElementException must be thrown",
e.getClass().equals((new NoSuchElementException()).getClass()));
}
+ }
+
+ // proves that an ArrayIterator set with the constructor has the same number of elements
+ // as an ArrayIterator set with setArray(Object)
+ public void testSetArray() {
+ Iterator iter1 = new ArrayIterator(testArray);
+ int count1 = 0;
+ while (iter1.hasNext()) {
+ ++count1;
+ iter1.next();
+ }
+
+ assertEquals("the count should be right using the constructor",
+ count1,testArray.length);
+
+ ArrayIterator iter2 = new ArrayIterator();
+ iter2.setArray(testArray);
+ int count2 = 0;
+ while (iter2.hasNext()) {
+ ++count2;
+ iter2.next();
+ }
+
+ assertEquals("the count should be right using setArray(Object)",
+ count2,testArray.length);
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>