예제 #1
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());
 }
예제 #2
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());
   }
 }
예제 #3
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());
   }
 }
예제 #4
0
 public void testIneffectiveBogusPostPush() {
   Stack<Integer> lastElementStack = new BogusLastElementStack<Integer>();
   lastElementStack.push(1);
   lastElementStack.push(2);
   lastElementStack.pop();
 }