I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit f238d051 authored by zab's avatar zab
Browse files

test removal

parent d8613d22
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ import org.junit.Test; ...@@ -11,6 +11,7 @@ import org.junit.Test;
public class CachedIteratorArrayListTest { public class CachedIteratorArrayListTest {
private List<Character> l; private List<Character> l;
private Iterator<Character> iter;
@Before @Before
public void setUp() { public void setUp() {
...@@ -18,6 +19,7 @@ public class CachedIteratorArrayListTest { ...@@ -18,6 +19,7 @@ public class CachedIteratorArrayListTest {
l.add('a'); l.add('a');
l.add('b'); l.add('b');
l.add('c'); l.add('c');
iter = l.iterator();
} }
/** test iterations work */ /** test iterations work */
...@@ -35,7 +37,7 @@ public class CachedIteratorArrayListTest { ...@@ -35,7 +37,7 @@ public class CachedIteratorArrayListTest {
// and one partial // and one partial
total = ""; total = "";
Iterator<Character> iter = l.iterator(); iter = l.iterator();
total += iter.next(); total += iter.next();
total += iter.next(); total += iter.next();
iter = l.iterator(); iter = l.iterator();
...@@ -49,5 +51,21 @@ public class CachedIteratorArrayListTest { ...@@ -49,5 +51,21 @@ public class CachedIteratorArrayListTest {
Iterator<Character> one = l.iterator(); Iterator<Character> one = l.iterator();
assertSame(one, two); assertSame(one, two);
} }
@Test
public void testRemove() {
iter.next();
iter.remove();
// test proper removal
assertEquals(2,l.size());
assertEquals('b',l.get(0).charValue());
assertEquals('c',l.get(1).charValue());
// test iterator still workx after removal
assertTrue(iter.hasNext());
assertEquals('b',iter.next().charValue());
assertEquals('c',iter.next().charValue());
assertFalse(iter.hasNext());
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment