java.util.AbstractSequentialList

Here are the examples of the java api class java.util.AbstractSequentialList taken from open source projects.

1. AbstractSequentialListTest#test_get()

View license
/**
     * @tests java.util.AbstractSequentialList#get(int)
     */
public void test_get() {
    AbstractSequentialList list = new MyAbstractSequentialList();
    list.add(1);
    list.add("value");
    assertEquals(1, list.get(0));
    assertEquals("value", list.get(1));
    // get value by index which is out of bounds
    try {
        list.get(list.size());
        fail("Should throw IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
    }
    try {
        list.get(-1);
        fail("Should throw IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
    }
}

2. AbstractSequentialListTest#test_remove()

View license
/**
     * @tests java.util.AbstractSequentialList#remove(int)
     */
public void test_remove() {
    AbstractSequentialList list = new MyAbstractSequentialList();
    list.add(1);
    // normal test
    assertEquals(1, list.remove(0));
    list.add("value");
    assertEquals("value", list.remove(0));
    // remove index is out of bounds
    try {
        list.remove(list.size());
        fail("Should throw IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
    }
    try {
        list.remove(-1);
        fail("Should throw IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
    }
    // list dont't support remove operation
    try {
        AbstractSequentialList mylist = new MockAbstractSequentialList();
        mylist.remove(0);
        fail("Should throw UnsupportedOperationException.");
    } catch (UnsupportedOperationException e) {
    }
}