Improve list iterator tests
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131444 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fae8897bc4
commit
7cdc68b01b
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/iterators/AbstractTestListIterator.java,v 1.4 2003/11/18 22:37:13 scolebourne Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/iterators/AbstractTestListIterator.java,v 1.5 2003/12/24 01:12:55 scolebourne Exp $
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
* The Apache Software License, Version 1.1
|
* The Apache Software License, Version 1.1
|
||||||
|
@ -71,7 +71,7 @@ import java.util.NoSuchElementException;
|
||||||
* overriding the supportsXxx() methods if necessary.
|
* overriding the supportsXxx() methods if necessary.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision: 1.4 $ $Date: 2003/11/18 22:37:13 $
|
* @version $Revision: 1.5 $ $Date: 2003/12/24 01:12:55 $
|
||||||
*
|
*
|
||||||
* @author Rodney Waldhoff
|
* @author Rodney Waldhoff
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
|
@ -223,21 +223,33 @@ public abstract class AbstractTestListIterator extends AbstractTestIterator {
|
||||||
public void testAdd() {
|
public void testAdd() {
|
||||||
ListIterator it = makeFullListIterator();
|
ListIterator it = makeFullListIterator();
|
||||||
|
|
||||||
|
Object addValue = addSetValue();
|
||||||
if (supportsAdd() == false) {
|
if (supportsAdd() == false) {
|
||||||
// check for UnsupportedOperationException if not supported
|
// check for UnsupportedOperationException if not supported
|
||||||
try {
|
try {
|
||||||
it.add(addSetValue());
|
it.add(addValue);
|
||||||
} catch (UnsupportedOperationException ex) {}
|
} catch (UnsupportedOperationException ex) {}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add at start should be OK
|
// add at start should be OK, added should be previous
|
||||||
it.add(addSetValue());
|
it = makeFullListIterator();
|
||||||
|
it.add(addValue);
|
||||||
|
assertSame(addValue, it.previous());
|
||||||
|
|
||||||
|
// add at start should be OK, added should not be next
|
||||||
|
it = makeFullListIterator();
|
||||||
|
it.add(addValue);
|
||||||
|
assertTrue(addValue != it.next());
|
||||||
|
|
||||||
// add in middle and at end should be OK
|
// add in middle and at end should be OK
|
||||||
|
it = makeFullListIterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
it.add(addSetValue());
|
it.add(addValue);
|
||||||
|
// check add OK
|
||||||
|
assertSame(addValue, it.previous());
|
||||||
|
it.next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue