Exemplo n.º 1
0
 @Test
 public void testIsMepty() {
   CustomStack<String> customStack = new CustomStack<String>();
   assertTrue(customStack.empty());
   customStack.push("element1");
   assertFalse(customStack.empty());
   customStack.pop();
   assertTrue(customStack.empty());
 }
Exemplo n.º 2
0
  @Test
  public void testPushPop() {
    String el0 = "firstElement0";
    String el1 = "firstElement1";
    String el2 = "firstElement2";
    String el3 = "firstElement3";

    CustomStack<String> customStack = new CustomStack<String>();

    customStack.push(el0);
    assertSame(el0, customStack.pop());
    customStack.push(el0);
    customStack.push(el0);
    assertSame(el0, customStack.pop());
    customStack.push(el1);
    customStack.push(el2);
    customStack.push(el3);
    customStack.push(el1);
    assertSame(el1, customStack.pop());
    assertSame(el3, customStack.pop());
    assertSame(el2, customStack.pop());
    assertSame(el1, customStack.pop());
    assertSame(el0, customStack.pop());
    assertTrue(customStack.empty());
  }