scolebourne 2004/05/12 15:20:54
Modified: collections/src/test/org/apache/commons/collections/list
AbstractTestList.java
Log:
Add tests of specific ListIterator behaviour
Revision Changes Path
1.7 +35 -2
jakarta-commons/collections/src/test/org/apache/commons/collections/list/AbstractTestList.java
Index: AbstractTestList.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/list/AbstractTestList.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractTestList.java 18 Feb 2004 01:20:34 -0000 1.6
+++ AbstractTestList.java 12 May 2004 22:20:54 -0000 1.7
@@ -771,12 +771,45 @@
*/
public void testListListIteratorByIndex() {
resetFull();
- for (int i = 0; i < confirmed.size(); i++) {
+ try {
+ getList().listIterator(-1);
+ } catch (IndexOutOfBoundsException ex) {}
+ resetFull();
+ try {
+ getList().listIterator(getList().size() + 1);
+ } catch (IndexOutOfBoundsException ex) {}
+ resetFull();
+ for (int i = 0; i <= confirmed.size(); i++) {
forwardTest(getList().listIterator(i), i);
backwardTest(getList().listIterator(i), i);
}
+ resetFull();
+ for (int i = 0; i <= confirmed.size(); i++) {
+ backwardTest(getList().listIterator(i), i);
+ }
}
+ /**
+ * Tests remove on list iterator is correct.
+ */
+ public void testListListIteratorPreviousRemove() {
+ if (isRemoveSupported() == false) return;
+ resetFull();
+ ListIterator it = getList().listIterator();
+ Object zero = it.next();
+ Object one = it.next();
+ Object two = it.next();
+ Object two2 = it.previous();
+ Object one2 = it.previous();
+ assertSame(one, one2);
+ assertSame(two, two2);
+ assertSame(zero, getList().get(0));
+ assertSame(one, getList().get(1));
+ assertSame(two, getList().get(2));
+ it.remove();
+ assertSame(zero, getList().get(0));
+ assertSame(two, getList().get(1));
+ }
/**
* Traverses to the end of the given iterator.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]