### Question:
InsnList { public ListIterator<AbstractInsnNode> iterator() { return iterator(0); }  int size(); AbstractInsnNode getFirst(); AbstractInsnNode getLast(); AbstractInsnNode get(final int index); boolean contains(final AbstractInsnNode insnNode); int indexOf(final AbstractInsnNode insnNode); void accept(final MethodVisitor methodVisitor); ListIterator<AbstractInsnNode> iterator(); @SuppressWarnings("unchecked") ListIterator<AbstractInsnNode> iterator(final int index); AbstractInsnNode[] toArray(); void set(final AbstractInsnNode oldInsnNode, final AbstractInsnNode newInsnNode); void add(final AbstractInsnNode insnNode); void add(final InsnList insnList); void insert(final AbstractInsnNode insnNode); void insert(final InsnList insnList); void insert(final AbstractInsnNode previousInsn, final AbstractInsnNode insnNode); void insert(final AbstractInsnNode previousInsn, final InsnList insnList); void insertBefore(final AbstractInsnNode nextInsn, final AbstractInsnNode insnNode); void insertBefore(final AbstractInsnNode nextInsn, final InsnList insnList); void remove(final AbstractInsnNode insnNode); void clear(); void resetLabels();  }### Answer:
@Test public void testIteratorNext_noSuchElement() { ListIterator<AbstractInsnNode> iterator = newInsnList().iterator(); Executable next = () -> iterator.next(); assertThrows(NoSuchElementException.class, next); }
@Test public void testIteratorNext_nonEmptyList() { InsnList insnList = newInsnList(insn1, insn2); ListIterator<AbstractInsnNode> iterator = insnList.iterator(1); AbstractInsnNode insn = iterator.next(); assertEquals(insn2, insn); assertFalse(iterator.hasNext()); assertEquals(2, iterator.nextIndex()); assertTrue(iterator.hasPrevious()); assertEquals(1, iterator.previousIndex()); }
@Test public void testIteratorPrevious_noSuchElement() { ListIterator<AbstractInsnNode> iterator = newInsnList().iterator(); Executable previous = () -> iterator.previous(); assertThrows(NoSuchElementException.class, previous); }
@Test public void testIteratorPrevious_nonEmptyList() { InsnList insnList = newInsnList(insn1, insn2); ListIterator<AbstractInsnNode> iterator = insnList.iterator(1); AbstractInsnNode insn = iterator.previous(); assertEquals(insn1, insn); assertTrue(iterator.hasNext()); assertEquals(0, iterator.nextIndex()); assertFalse(iterator.hasPrevious()); assertEquals(-1, iterator.previousIndex()); }