IntList { public int[] toArray() { int[] ret = new int[len]; for(int i = 0; i < len; i++) { ret[i] = buf[i]; } return ret; } 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 testToArray() { IntList intList = new IntList(); assertEqualArray(intList.toArray()); assertSame(intList, intList.add(1)); assertSame(intList, intList.add(2)); assertEqualArray(intList.toArray(), 1, 2); }