@Test public void acceptable(){ double precision = 0.001; double zeroThreshold = (precision * precision); assertTrue(VerificationUtil.acceptable(1.0, 1.0, precision, zeroThreshold)); assertTrue(VerificationUtil.acceptable(1.0, 0.999, precision, zeroThreshold)); assertFalse(VerificationUtil.acceptable(1.0, 0.99895, precision, zeroThreshold)); assertTrue(VerificationUtil.acceptable(1.0, 1.001, precision, zeroThreshold)); assertFalse(VerificationUtil.acceptable(1.0, 1.00105, precision, zeroThreshold)); assertTrue(VerificationUtil.acceptable(-1.0, -1.0, precision, zeroThreshold)); assertTrue(VerificationUtil.acceptable(-1.0, -1.001, precision, zeroThreshold)); assertFalse(VerificationUtil.acceptable(-1.0, -1.00105, precision, zeroThreshold)); assertTrue(VerificationUtil.acceptable(-1.0, -0.999, precision, zeroThreshold)); assertFalse(VerificationUtil.acceptable(-1.0, -0.99895, precision, zeroThreshold)); }
static public boolean acceptable(Object expected, Object actual, double precision, double zeroThreshold){ if(expected instanceof Number && actual instanceof Number){ return acceptable((Number)expected, (Number)actual, precision, zeroThreshold); } return Objects.equals(expected, actual); }
VerificationUtil { static public boolean acceptable(Object expected, Object actual, double precision, double zeroThreshold){ if(expected instanceof Number && actual instanceof Number){ return acceptable((Number)expected, (Number)actual, precision, zeroThreshold); } return Objects.equals(expected, actual); } }
VerificationUtil { static public boolean acceptable(Object expected, Object actual, double precision, double zeroThreshold){ if(expected instanceof Number && actual instanceof Number){ return acceptable((Number)expected, (Number)actual, precision, zeroThreshold); } return Objects.equals(expected, actual); } private  VerificationUtil(); }
VerificationUtil { static public boolean acceptable(Object expected, Object actual, double precision, double zeroThreshold){ if(expected instanceof Number && actual instanceof Number){ return acceptable((Number)expected, (Number)actual, precision, zeroThreshold); } return Objects.equals(expected, actual); } private  VerificationUtil(); static boolean acceptable(Object expected, Object actual, double precision, double zeroThreshold); static boolean acceptable(Number expected, Number actual, double precision, double zeroThreshold); static boolean isZero(Number value, double zeroThreshold); }
VerificationUtil { static public boolean acceptable(Object expected, Object actual, double precision, double zeroThreshold){ if(expected instanceof Number && actual instanceof Number){ return acceptable((Number)expected, (Number)actual, precision, zeroThreshold); } return Objects.equals(expected, actual); } private  VerificationUtil(); static boolean acceptable(Object expected, Object actual, double precision, double zeroThreshold); static boolean acceptable(Number expected, Number actual, double precision, double zeroThreshold); static boolean isZero(Number value, double zeroThreshold);  }