/** listIterator only returns those elements after the given index */ public void testListIterator2() { List full = populatedArray(3); ListIterator i = full.listIterator(1); int j; for (j = 0; i.hasNext(); j++) assertEquals(j + 1, ((Integer) i.next()).intValue()); assertEquals(2, j); }
/** listIterator throws an IndexOutOfBoundsException on a negative index */ public void testListIterator1_IndexOutOfBoundsException() { try { List c = emptyArray(); c.listIterator(-1); shouldThrow(); } catch (IndexOutOfBoundsException e) { } }
/** listIterator throws an IndexOutOfBoundsException on a too high index */ public void testListIterator2_IndexOutOfBoundsException() { try { List c = emptyArray(); c.add("adasd"); c.add("asdasdas"); c.listIterator(100); shouldThrow(); } catch (IndexOutOfBoundsException e) { } }