Exemple #1
0
  @Test
  public void testBasicFeatures() {
    Stack stack = new Stack();

    assertTrue(stack.isEmpty());

    stack.push("first");
    assertFalse(stack.isEmpty());

    String peek = stack.peek();
    assertThat(peek, is("first"));
    assertFalse(stack.isEmpty());

    String pop = stack.pop();
    assertThat(pop, is("first"));
    assertTrue(stack.isEmpty());
  }
Exemple #2
0
 @Test
 public void shouldReturnNullOnEmptyPeak() throws Exception {
   Stack stack = new Stack();
   String peek = stack.peek();
   assertThat(peek, is(nullValue()));
 }