MyStack implements SimpleStack<T> { @Override public void push(T obj) { stack[depth++] = obj; } MyStack();  MyStack(int howBig); @Override boolean empty(); @Override void push(T obj); @Override T pop(); @Override T peek(); boolean hasNext(); boolean hasRoom(); int getStackDepth(); static final int DEFAULT_INITIAL; }
@Test public void testPush() { int i = 0; do { ss.push("Hello #" + i++); } while (((MyStack<String>) ss).hasRoom()); assertEquals(i, MyStack.DEFAULT_INITIAL); }
@Test(expected=ArrayIndexOutOfBoundsException.class) public void testPushOverflow() { MyStack<Integer> s = new MyStack<Integer>(1); s.push(0); s.push(0); }