Ejemplo n.º 1
0
 public void testBogusPostPush1() {
   Stack<Integer> countingStack = new BogusCountingStack<Integer>();
   try {
     countingStack.push(1);
     fail();
   } catch (PostconditionError expected) {
     assertEquals("[peek() == old (obj)]", expected.getMessages().toString());
   }
 }
Ejemplo n.º 2
0
 public void testBogusPostPush() {
   Stack<Integer> bogusPostconditionsStack = new BogusPostconditionsStack<Integer>();
   try {
     bogusPostconditionsStack.push(1);
     fail();
   } catch (PostconditionError expected) {
     assertEquals("[size() == old (size()) + 1]", expected.getMessages().toString());
   }
 }
Ejemplo n.º 3
0
 public void testEmptyPop() {
   try {
     stack.pop();
     fail();
   } catch (PreconditionError expected) {
     assertEquals("[size() >= 1]", expected.getMessages().toString());
   }
 }
Ejemplo n.º 4
0
 public void testNormal() {
   stack.push(1);
   stack.push(2);
   assertEquals(2, stack.size());
   stack.pop();
   stack.push(3);
   stack.pop();
   stack.pop();
   stack.push(4);
   assertEquals(1, stack.size());
 }
Ejemplo n.º 5
0
 public void testIneffectiveBogusPostPush() {
   Stack<Integer> lastElementStack = new BogusLastElementStack<Integer>();
   lastElementStack.push(1);
   lastElementStack.push(2);
   lastElementStack.pop();
 }