/** A simple test to show that top() is working correctly when items are being pushed/popped */ @Ignore @Test public void testPushPopTop() { final StackIF<String> stack = makeStringStack(); stack.push(values[2]); assertEquals("The top item of the stack should be 'Three'", stack.top(), "Three"); stack.push(values[2]); stack.push(values[0]); stack.pop(); assertEquals("The top item of the stack should be 'Three'", stack.top(), "Three"); stack.pop(); stack.push(values[1]); stack.push(values[1]); stack.pop(); assertEquals("The top item of the stack should be 'Two'", stack.top(), "Two"); }
/** Simple test to show that size() is working correctly as items are being pushed/popped. */ @Ignore @Test public void testPushPopSize() { final StackIF<String> stack = makeStringStack(); stack.push(values[0]); stack.push(values[1]); stack.push(values[1]); assertEquals("Stack should have a size of 3", stack.size(), 3); stack.pop(); stack.push(values[2]); stack.push(values[1]); stack.push(values[0]); assertEquals("Stack should have a size of 5", stack.size(), 5); stack.pop(); stack.pop(); stack.pop(); stack.pop(); stack.pop(); assertEquals("Stack should be empty", stack.size(), 0); }
/** Tests that isEmpty() is working correctly when items are being pushed/popped. */ @Ignore @Test public void testEmptyMethod() { final StackIF<Integer> stack = makeIntegerStack(); assertTrue("Stack should be empty", stack.isEmpty()); stack.push(1); stack.push(2); assertFalse("Stack should not be empty", stack.isEmpty()); stack.pop(); stack.pop(); assertTrue("Stack should be empty", stack.isEmpty()); }
/** Tests that popping an empty stack throws a StackUnderflowException. */ @Ignore @Test(expected = StackUnderflowException.class) public void poppingEmptyThrowsException() { final StackIF<Integer> stack = makeIntegerStack(); stack.pop(); }