IntList { public int get(int i) { checkIndex(i); return buf[i]; } IntList(int capacity);  IntList(); int[] toArray(); int size(); int get(int i); int set(int i, int val); void ensureCapacity(int capacity); IntList add(int i);  }
@Test public void testGet() { IntList intList = new IntList(); assertEquals(0, intList.size()); intList.add(1); assertEquals(1, intList.get(0)); assertEquals(1, intList.size()); assertEqualArray(intList.toArray(), 1); }
@Test public void testGet_throwsForNegativeIndex() { IntList intList = new IntList(); try { intList.get(-1); fail(); } catch (ArrayIndexOutOfBoundsException e) {} }
@Test public void testGet_throwsForIndexOutOfBounds() { IntList intList = new IntList(); try { intList.get(0); fail(); } catch (ArrayIndexOutOfBoundsException e) {} }