IntList { @Private static int calcSize(int expectedSize, int factor) { int rem = expectedSize % factor; return expectedSize / factor * factor + (rem > 0 ? factor : 0); } 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 testCalcSize() { assertEquals(4, IntList.calcSize(4, 1)); assertEquals(3, IntList.calcSize(1, 3)); assertEquals(3, IntList.calcSize(2, 3)); assertEquals(3, IntList.calcSize(3, 3)); assertEquals(6, IntList.calcSize(4, 3)); }