1 /* Copyright (c) 2000-2003, jMock.org. See bundled LICENSE.txt */ 2 package org.jmock.expectation; 3 4 import junit.framework.AssertionFailedError; 5 import org.jmock.AbstractTestCase; 6 7 public class TestExpectationDoubleValue extends AbstractTestCase { 8 9 private ExpectationDoubleValue myExpectation = 10 new ExpectationDoubleValue("ExpectationDoubleValue for testing"); 11 12 public void testExpectNothing() { 13 myExpectation.setExpectNothing(); 14 15 assertTrue("Should have an expectation", 16 myExpectation.hasExpectations()); 17 } 18 19 public void testExpectNothingFail() { 20 myExpectation.setExpectNothing(); 21 22 try { 23 myExpectation.setActual(100.0); 24 fail("Should fail fast"); 25 } catch (AssertionFailedError ex) { 26 // expected 27 } 28 29 } 30 31 public void testFailOnVerify() { 32 myExpectation.setExpected(0.0, 0.0); 33 myExpectation.setFailOnVerify(); 34 35 myExpectation.setActual(1.0); 36 assertVerifyFails(myExpectation); 37 } 38 39 public void testFlushActual() { 40 myExpectation.setActual(10); 41 42 myExpectation.setExpectNothing(); 43 44 myExpectation.verify(); 45 } 46 47 public void testHasNoExpectations() { 48 myExpectation.setActual(0.0); 49 50 assertTrue("Has no expectations", 51 !myExpectation.hasExpectations()); 52 } 53 54 public void testFailOutsideError() { 55 myExpectation.setExpected(100.0, 1.0); 56 57 try { 58 myExpectation.setActual(102.0); 59 fail("Should fail fast on double"); 60 } catch (AssertionFailedError ex) { 61 //expected 62 } 63 64 } 65 66 public void testPassOnError() { 67 myExpectation.setExpected(100.0, 1.0); 68 myExpectation.setActual(101.0); 69 myExpectation.verify(); 70 } 71 72 public void testPassWithinError() { 73 myExpectation.setExpected(100.0, 1.0); 74 myExpectation.setActual(100); 75 myExpectation.verify(); 76 } 77 }

This page was automatically generated by Maven