assertEquals(expected, actual, delta) currently throws an exception if a delta of zero is passed in.
This is a change in behavior from JUnit 4 and an unnecessary restriction. I propose that the desired behavior should be to treat delta of zero as a test for equality.
In my projects a delta of zero occurs when the test tolerance is dynamically computed. The current work around is to add EPS to the dynamic tolerance. This bloats the code and the desired test is for equality, not _nearly_ equal.
Two simple modifications (once for float and double) are required. Change the line delta <= 0.0 to delta < 0.0.
static void assertValidDelta(float delta) {
if (Float.isNaN(delta) || delta < 0.0) {
failIllegalDelta(String.valueOf(delta));
}
}
That's it.
I'd be fine with changing it.
@junit-team/junit-lambda WDYT?
+1
I've tried to fix this issue
_in progress_ in #1613
Most helpful comment
I'd be fine with changing it.
@junit-team/junit-lambda WDYT?