Ejemplo n.º 1
0
 @JExercise(
     tests = "String pop()",
     description =
         "The pop() method returns the element on the top of the stack or null if the stack is empty.")
 public void testPop() {
   assertEquals("pop() should return null when the stack is empty. ", null, stack.pop());
   stack.push("0");
   stack.push("1");
   stack.push("2");
   assertEquals("2", stack.pop());
   assertEquals("1", stack.pop());
   stack.push("3");
   assertEquals("3", stack.pop());
   assertEquals("0", stack.pop());
   assertEquals("pop() should return null when the stack is empty. ", null, stack.pop());
 }
Ejemplo n.º 2
0
 @JExercise(
     tests = "void push(String)",
     description = "The push(String) method puts the String argument on the stack.")
 public void testPush() {
   stack.push("1");
   assertEquals("1", stack.peek(0));
   stack.push("2");
   assertEquals("2", stack.peek(0));
   stack.push("3");
   assertEquals("3", stack.pop());
 }