IntArrayStack { public IntArrayStack() { array = new int[INITIAL_CAPACITY]; top = -1; } IntArrayStack(); boolean isEmpty(); int size(); void getElements(int[] destArray, int destStartIndex); int[] toArray(); void clear(); int peek(); int pop(); void push(int x);  }
@Test public void testIntArrayStack() { IntArrayStack stack = new IntArrayStack(); stack.push(1); stack.push(2); stack.push(6); assertFalse(stack.isEmpty()); assertEquals(stack.size(), 3); assertEquals(stack.peek(), 6); assertEquals(stack.pop(), 6); assertEquals(stack.size(), 2); stack.push(8); assertEquals(stack.pop(), 8); assertEquals(stack.size(), 2); int[] buf = new int[5]; stack.getElements(buf, 1); assertTrue(Arrays.equals(buf, new int[]{ 0, 1, 2, 0, 0 })); stack.clear(); assertEquals(stack.size(), 0); assertTrue(stack.isEmpty()); }