@Test public void testSize() throws Exception { int size = stack.size(); stack.push("Agh?"); assertNotEquals(size, stack.size()); assertEquals(size + 1, stack.size()); }
@BeforeMethod public void setUp() throws Exception { stack = init(); stack.push("..."); stack.push("Luka"); stack.push("<3"); stack.push("Bazza"); }
@Test public void testPeek() throws Exception { int size = stack.size(); assertTrue(size > 0); final String top = stack.peek(); assertEquals(top, "Bazza"); // peek shouldn't remove top item from the stack assertEquals(size, stack.size()); }
@Test public void testPush() throws Exception { final String item = "New top"; int size = stack.size(); stack.push(item); assertNotEquals(size, stack.size()); assertEquals(size + 1, stack.size()); final String top = stack.peek(); assertEquals(top, item); }
@Test public void testPop() throws Exception { int size = stack.size(); assertTrue(size > 0); String top = stack.pop(); assertEquals(top, "Bazza"); assertNotEquals(size, stack.size()); top = stack.pop(); assertEquals(top, "<3"); assertEquals(size - 2, stack.size()); }
@Test public void testIsEmpty() throws Exception { assertFalse(stack.isEmpty()); assertNotEquals(stack.size(), 0); }