Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/test
In directory usw-pr-cvs1:/tmp/cvs-serv17637/src/core/com/mockobjects/test
Modified Files:
AllTests.java
Added Files:
TestExpectationDoubleValue.java
Log Message:
Added ExpectationDoubleValue class that expects a double value within some error
--- NEW FILE: TestExpectationDoubleValue.java ---
package com.mockobjects.test;
import junit.framework.*;
import com.mockobjects.*;
import com.mockobjects.util.*;
public class TestExpectationDoubleValue extends TestCaseMo {
private static final Class THIS = TestExpectationDoubleValue.class;
private ExpectationDoubleValue myExpectation =
new ExpectationDoubleValue("ExpectationDoubleValue for testing");
public TestExpectationDoubleValue(String name) {
super(name);
}
public static void main(String[] args) {
start(new String[] { THIS.getName()});
}
public static Test suite() {
return new TestSuite(THIS);
}
public void testExpectNothing() {
myExpectation.setExpectNothing();
assertTrue("Should have an expectation",
myExpectation.hasExpectations());
}
public void testExpectNothingFail() {
myExpectation.setExpectNothing();
try {
myExpectation.setActual(100.0);
fail("Should fail fast");
} catch (AssertionFailedError ex) {
// expected
}
}
public void testFailOnVerify() {
myExpectation.setExpected( 0.0, 0.0 );
myExpectation.setFailOnVerify();
myExpectation.setActual(1.0);
assertVerifyFails(myExpectation);
}
public void testFlushActual() {
myExpectation.setActual(10);
myExpectation.setExpectNothing();
myExpectation.verify();
}
public void testHasNoExpectations() {
myExpectation.setActual(0.0);
assertTrue( "Has no expectations",
!myExpectation.hasExpectations());
}
public void testFailOutsideError() {
myExpectation.setExpected( 100.0, 1.0 );
try {
myExpectation.setActual(102.0);
fail("Should fail fast on double");
} catch (AssertionFailedError ex) {
//expected
}
}
public void testPassOnError() {
myExpectation.setExpected( 100.0, 1.0 );
myExpectation.setActual(101.0);
myExpectation.verify();
}
public void testPassWithinError() {
myExpectation.setExpected( 100.0, 1.0 );
myExpectation.setActual(100);
myExpectation.verify();
}
}
Index: AllTests.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/test/AllTests.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AllTests.java 19 Jun 2002 15:07:11 -0000 1.4
+++ AllTests.java 23 Aug 2002 16:23:44 -0000 1.5
@@ -44,6 +44,10 @@
suite.addTest(TestExpectationValue.suite());
}
+ public static void addTestExpectationDoubleValue(TestSuite suite) {
+ suite.addTest(TestExpectationDoubleValue.suite());
+ }
+
public static void addTestMapEntry(TestSuite suite) {
suite.addTest(TestMapEntry.suite());
}
|