示例#1
0
  @Test
  public void testPush() {
    // Stack stack = new Stack(5);
    Integer i = 0;
    stack.push(i);
    assertFalse("Stack size = 1", stack.isEmpty());

    Stack<Double> stackDouble = new Stack<Double>();
    Double f = 0.1;
    stackDouble.push(f);
    assertFalse("Stack size = 1", stackDouble.isEmpty());
  }
示例#2
0
  @Test
  public void testEmpty() {
    Stack<String> testStack = new Stack<String>();
    assertTrue(testStack.isEmpty());

    String test = "Test";
    testStack.push(test);
    assertFalse(testStack.isEmpty());

    testStack.pop();
    assertTrue(testStack.isEmpty());
  }
示例#3
0
 @Test
 public void testPushPop() {
   // Stack stack = new Stack(5);
   stack.push(0);
   stack.pop();
   assertTrue("Stack is empty", stack.isEmpty());
 }
示例#4
0
 @Test
 public void PushNull() {
   // Stack stack = new Stack(2);
   Integer i = null;
   stack.push(i);
   assertFalse("Stack size = 1", stack.isEmpty());
 }
示例#5
0
 /** Test of isEmpty method, of class Stack. Stack is empty. */
 @Test
 public void testIsEmpty() {
   System.out.println("isEmpty");
   Stack instance = new Stack(1);
   boolean expResult = true;
   boolean result = instance.isEmpty();
   assertEquals(expResult, result);
 }
示例#6
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());
  }
示例#7
0
 @SuppressWarnings("unused")
 @Test
 public void testTopWithIsEmpty() {
   // Stack stack = new Stack(2);
   stack.push(0);
   int top = stack.top();
   assertFalse("Stack size = 1", stack.isEmpty());
 }
示例#8
0
 @Test
 public void testIsEmpty() {
   // Stack stack = new Stack(5);
   boolean empty = stack.isEmpty();
   assertTrue("Stack is empty", empty);
 }