IntList { public void ensureCapacity(int capacity) { if (capacity > buf.length) { int factor = buf.length / 2 + 1; grow(calcSize(capacity - buf.length, factor)); } } 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 testEnsureCapacity() { IntList intList = new IntList(0); intList.add(1); intList.ensureCapacity(100); assertEquals(1, intList.size()); assertEqualArray(intList.toArray(), 1); }