Code example for ListIterator

Methods: hasPreviousnextnextIndexpreviousIndex

0
    @Test
    public void listIterator() 
    { 
        MutableList<T> collection = this.getCollection();
        ListIterator<T> it = collection.listIterator();
        Assert.assertFalse(it.hasPrevious());
        Assert.assertEquals(-1, it.previousIndex());
        Assert.assertEquals(0, it.nextIndex());
        it.next();
        Assert.assertEquals(1, it.nextIndex());
 
        Verify.assertThrows(UnsupportedOperationException.class, (Runnable) it::remove);
 
        Verify.assertThrows(UnsupportedOperationException.class, () -> it.add(null)); 
 
        it.set(null); 
        Assert.assertNotEquals(this.getCollection(), collection); 
    } 
 
    @Test