Ejemplo n.º 1
0
  @Test
  public void testSize() throws Exception {
    int size = stack.size();

    stack.push("Agh?");
    assertNotEquals(size, stack.size());
    assertEquals(size + 1, stack.size());
  }
Ejemplo n.º 2
0
  @BeforeMethod
  public void setUp() throws Exception {
    stack = init();

    stack.push("...");
    stack.push("Luka");
    stack.push("<3");
    stack.push("Bazza");
  }
Ejemplo n.º 3
0
  @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());
  }
Ejemplo n.º 4
0
  @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);
  }
Ejemplo n.º 5
0
  @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());
  }
Ejemplo n.º 6
0
 @Test
 public void testIsEmpty() throws Exception {
   assertFalse(stack.isEmpty());
   assertNotEquals(stack.size(), 0);
 }