public void testSubList_startNegative() { try { getList().subList(-1, 0); fail("subList(-1, 0) should throw"); } catch (IndexOutOfBoundsException expected) { } }
public void testSubList_startGreaterThanEnd() { try { getList().subList(1, 0); fail("subList(1, 0) should throw"); } catch (IndexOutOfBoundsException expected) { } catch (IllegalArgumentException expected) { /* * The subList() docs claim that this should be an * IndexOutOfBoundsException, but many JDK implementations throw * IllegalArgumentException: * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4506427 */ } }
public void testSubList_endTooLarge() { try { getList().subList(0, getNumElements() + 1); fail("subList(0, size + 1) should throw"); } catch (IndexOutOfBoundsException expected) { } }
@CollectionSize.Require(absent = {ZERO, ONE}) public void testSubList_get() { List<E> list = getList(); int size = getNumElements(); List<E> copy = list.subList(0, size); List<E> head = list.subList(0, size - 1); List<E> tail = list.subList(1, size); assertEquals(list.get(0), copy.get(0)); assertEquals(list.get(size - 1), copy.get(size - 1)); assertEquals(list.get(1), tail.get(0)); assertEquals(list.get(size - 1), tail.get(size - 2)); assertEquals(list.get(0), head.get(0)); assertEquals(list.get(size - 2), head.get(size - 2)); for (List<E> subList : Arrays.asList(copy, head, tail)) { for (int index : Arrays.asList(-1, subList.size())) { try { subList.get(index); fail("expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException expected) { } } } }
public void testSubList_startNegative() { try { getList().subList(-1, 0); fail("subList(-1, 0) should throw"); } catch (IndexOutOfBoundsException expected) { } }
public void testSubList_startNegative() { try { getList().subList(-1, 0); fail("subList(-1, 0) should throw"); } catch (IndexOutOfBoundsException expected) { } }
public void testSubList_startGreaterThanEnd() { try { getList().subList(1, 0); fail("subList(1, 0) should throw"); } catch (IndexOutOfBoundsException expected) { } catch (IllegalArgumentException expected) { /* * The subList() docs claim that this should be an * IndexOutOfBoundsException, but many JDK implementations throw * IllegalArgumentException: * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4506427 */ } }
public void testSubList_startGreaterThanEnd() { try { getList().subList(1, 0); fail("subList(1, 0) should throw"); } catch (IndexOutOfBoundsException expected) { } catch (IllegalArgumentException expected) { /* * The subList() docs claim that this should be an * IndexOutOfBoundsException, but many JDK implementations throw * IllegalArgumentException: * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4506427 */ } }
public void testSubList_endTooLarge() { try { getList().subList(0, getNumElements() + 1); fail("subList(0, size + 1) should throw"); } catch (IndexOutOfBoundsException expected) { } }
public void testSubList_endTooLarge() { try { getList().subList(0, getNumElements() + 1); fail("subList(0, size + 1) should throw"); } catch (IndexOutOfBoundsException expected) { } }
@CollectionSize.Require(absent = {ZERO, ONE}) public void testSubList_get() { List<E> list = getList(); int size = getNumElements(); List<E> copy = list.subList(0, size); List<E> head = list.subList(0, size - 1); List<E> tail = list.subList(1, size); assertEquals(list.get(0), copy.get(0)); assertEquals(list.get(size - 1), copy.get(size - 1)); assertEquals(list.get(1), tail.get(0)); assertEquals(list.get(size - 1), tail.get(size - 2)); assertEquals(list.get(0), head.get(0)); assertEquals(list.get(size - 2), head.get(size - 2)); for (List<E> subList : Arrays.asList(copy, head, tail)) { for (int index : Arrays.asList(-1, subList.size())) { try { subList.get(index); fail("expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException expected) { } } } }
@CollectionSize.Require(absent = {ZERO, ONE}) public void testSubList_get() { List<E> list = getList(); int size = getNumElements(); List<E> copy = list.subList(0, size); List<E> head = list.subList(0, size - 1); List<E> tail = list.subList(1, size); assertEquals(list.get(0), copy.get(0)); assertEquals(list.get(size - 1), copy.get(size - 1)); assertEquals(list.get(1), tail.get(0)); assertEquals(list.get(size - 1), tail.get(size - 2)); assertEquals(list.get(0), head.get(0)); assertEquals(list.get(size - 2), head.get(size - 2)); for (List<E> subList : Arrays.asList(copy, head, tail)) { for (int index : Arrays.asList(-1, subList.size())) { try { subList.get(index); fail("expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException expected) { } } } }