@Test public void pushThreeStringsThenPeekTop() { ss.push("Jim"); ss.push("Tim"); ss.push("Ben"); assertEquals("Ben", ss.peek()); }
@Test public void UTC_01() { StringStack obj = new StringStack(-3); assertTrue(obj.push("string1")); assertTrue(obj.push("string2")); assertTrue(obj.push("string3")); assertFalse(obj.push("string4")); }
public void testsAddingElementsToStack() { ss.push("1"); assertEquals("1", ss.peek()); ss.push("2"); assertEquals("2", ss.peek()); ss.push("3"); assertEquals("3", ss.peek()); }
@Test public void UTC_03() { StringStack obj = new StringStack(2); assertTrue(obj.push("string1")); assertFalse(obj.push(null)); assertFalse(obj.push(null)); assertTrue(obj.push("string2")); assertFalse(obj.push("string3")); }
@Test public void UTC_06() { StringStack obj = new StringStack(1); assertTrue(obj.push("string1")); assertNotNull(obj.pop()); assertNull(obj.pop()); assertTrue(obj.push("string1")); assertNotNull(obj.pop()); assertNull(obj.pop()); }
@Test public void testsLookingAtTopElement() { assertEquals(null, ss.peek()); ss.push("1"); assertEquals(ss.peek(), "1"); assertTrue(ss.isEmpty() == false); ss.push("2"); assertEquals(ss.peek(), "2"); ss.push("3"); assertEquals(ss.peek(), "3"); }
@Test public void testsRemovingAnElementFromStack() { ss.push("1"); ss.push("2"); ss.push("3"); assertTrue(ss.isEmpty() == false); assertEquals("3", ss.pop()); assertEquals("2", ss.peek()); assertEquals("2", ss.pop()); assertEquals("1", ss.peek()); assertEquals("1", ss.pop()); assertEquals(null, ss.peek()); assertTrue(ss.isEmpty() == true); assertEquals(null, ss.pop()); }
@Test public void pushTwoStringsThenPopOne() { ss.push("Jim"); ss.push("Tim"); assertEquals(ss.pop(), "Tim"); assertEquals(ss.peek(), "Jim"); }
@Test public void pushTwoStringsThenPopTwo() { ss.push("Jim"); ss.push("Tim"); assertEquals(ss.pop(), "Tim"); assertEquals(ss.pop(), "Jim"); assertTrue(ss.isEmpty()); }
@Test public void pushOneStringThenPopOne() { ss.push("Jim"); assertFalse(ss.isEmpty()); assertEquals(ss.pop(), "Jim"); assertNull(ss.peek()); assertTrue(ss.isEmpty()); }
@Test public void pushOneStringThenPeek() { ss.push("1"); assertEquals("1", ss.peek()); }