示例#1
0
  @Test
  public void testSize() throws Exception {
    int size = stack.size();

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

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