I am trying to create an assert equals (double, double, epsilon) method. I created it and for some reason when I run my tester, the method is failing.
public static void assertEquals(double expect, double actual, double epsilon){
totalAssertMethods ++;
double difference = (Math.abs(expect - actual));
if (difference <= epsilon){
} else {
totalAssertMethodsFailures ++;
Throwable throwable = new Throwable("Error: Expected X +/-E, found Y");
throwable.printStackTrace();
}
}
I think the problem is, is that the difference between expect and actual in the test is only different from epsilon by approx 0.000001. Does anyone know how to go about fixing this?