> assertEquals(0.0f, 0.0f, 0.0f);
Results in the following failure in hosted and web modes:
> junit.framework.AssertionFailedError: expected=0.0 actual=0.0 delta=0.0
While this assertion passes:
> assertEquals(0.0f, 0.1f, 0.0f);
So, this JUnit method seems to be broken. Also, when stepping into this
method in the debugger (hosted mode) the line numbers are all wrong. It
works fine for regular ol' TestCase (not GWTTestCase). I'm using JUnit
version 3.8.1 jar and source.
I have no current need to allow for precision so I'm using the
following workaround to verify values in my tests:
> assertTrue(0.0f == 0.0f);
-= Mat
assertEquals(0.0f, 0.0f, 0.0001f)
The means "equal within a 0.0001 margin of error."
static public void assertEquals(String str, float obj1, float obj2,
float delta) {
if (obj1 - obj2 < delta || obj2 - obj1 < delta) {
return;
} else {
fail(str + " expected=" + obj1 + " actual=" + obj2 + " delta=" +
delta);
}
}
It should be something like this:
if (obj1 > obj2 && obj1 - obj2 < delta || obj2 - obj1 <= delta)
return;
else
fail();
The assertEquals(String, double, double, double) method is also
affected.
-= Mat