1 3 package test.jmock.core.constraint; 4 5 import org.jmock.core.constraint.IsCloseTo; 6 7 8 public class IsCloseToTest extends AbstractConstraintsTest 9 { 10 11 public void testEvaluatesToTrueIfArgumentIsEqualToADoubleValueWithinSomeError() { 12 IsCloseTo p = new IsCloseTo(1.0, 0.5); 13 14 assertTrue(p.eval(new Double (1.0))); 15 assertTrue(p.eval(new Double (0.5))); 16 assertTrue(p.eval(new Double (1.5))); 17 18 assertTrue(p.eval(new Float (1.0))); 19 assertTrue(p.eval(new Integer (1))); 20 21 assertTrue("number too large", !p.eval(new Double (2.0))); 22 assertTrue("number too small", !p.eval(new Double (0.0))); 23 24 try { 25 p.eval("wrong type"); 26 fail("ClassCastException expected for wrong type of argument"); 27 } 28 catch (ClassCastException ex) { 29 } 31 } 32 33 } 34 | Popular Tags |