fix a bug in FilterListIterator and add a test for it
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130701 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6b320e8afe
commit
e2af015a2f
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/Attic/FilterListIterator.java,v 1.2 2002/02/26 17:28:55 rwaldhoff Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/Attic/FilterListIterator.java,v 1.3 2002/05/13 16:10:37 rwaldhoff Exp $
|
||||||
* $Revision: 1.2 $
|
* $Revision: 1.3 $
|
||||||
* $Date: 2002/02/26 17:28:55 $
|
* $Date: 2002/05/13 16:10:37 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -71,7 +71,7 @@ import java.util.NoSuchElementException;
|
||||||
* <code>Predicate</code> evaluates to <code>true</code> are
|
* <code>Predicate</code> evaluates to <code>true</code> are
|
||||||
* returned by the iterator.
|
* returned by the iterator.
|
||||||
*
|
*
|
||||||
* @version $Revision: 1.2 $ $Date: 2002/02/26 17:28:55 $
|
* @version $Revision: 1.3 $ $Date: 2002/05/13 16:10:37 $
|
||||||
* @author Rodney Waldhoff
|
* @author Rodney Waldhoff
|
||||||
*/
|
*/
|
||||||
public class FilterListIterator extends ProxyListIterator {
|
public class FilterListIterator extends ProxyListIterator {
|
||||||
|
@ -199,6 +199,8 @@ public class FilterListIterator extends ProxyListIterator {
|
||||||
clearPreviousObject();
|
clearPreviousObject();
|
||||||
if(!setNextObject()) {
|
if(!setNextObject()) {
|
||||||
return false;
|
return false;
|
||||||
|
} else {
|
||||||
|
clearNextObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,6 +232,8 @@ public class FilterListIterator extends ProxyListIterator {
|
||||||
clearNextObject();
|
clearNextObject();
|
||||||
if(!setPreviousObject()) {
|
if(!setPreviousObject()) {
|
||||||
return false;
|
return false;
|
||||||
|
} else {
|
||||||
|
clearPreviousObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestFilterListIterator.java,v 1.2 2002/02/26 17:28:55 rwaldhoff Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestFilterListIterator.java,v 1.3 2002/05/13 16:10:37 rwaldhoff Exp $
|
||||||
* $Revision: 1.2 $
|
* $Revision: 1.3 $
|
||||||
* $Date: 2002/02/26 17:28:55 $
|
* $Date: 2002/05/13 16:10:37 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -70,7 +70,7 @@ import java.util.ListIterator;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @version $Revision: 1.2 $ $Date: 2002/02/26 17:28:55 $
|
* @version $Revision: 1.3 $ $Date: 2002/05/13 16:10:37 $
|
||||||
* @author Rodney Waldhoff
|
* @author Rodney Waldhoff
|
||||||
*/
|
*/
|
||||||
public class TestFilterListIterator extends TestCase {
|
public class TestFilterListIterator extends TestCase {
|
||||||
|
@ -316,6 +316,18 @@ public class TestFilterListIterator extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testFailingHasNextBug() {
|
||||||
|
FilterListIterator filtered = new FilterListIterator(list.listIterator(),fourPred);
|
||||||
|
ListIterator expected = fours.listIterator();
|
||||||
|
while(expected.hasNext()) {
|
||||||
|
expected.next();
|
||||||
|
filtered.next();
|
||||||
|
}
|
||||||
|
assertTrue(filtered.hasPrevious());
|
||||||
|
assertTrue(!filtered.hasNext());
|
||||||
|
assertEquals(expected.previous(),filtered.previous());
|
||||||
|
}
|
||||||
|
|
||||||
// Utilities
|
// Utilities
|
||||||
|
|
||||||
private void walkForward(ListIterator expected, ListIterator testing) {
|
private void walkForward(ListIterator expected, ListIterator testing) {
|
||||||
|
|
Loading…
Reference in New Issue