javadba javadba - 1 year ago 101
Java Question

How to test for equality of float/double in JUnit?


method is justifiably deprecated. Is there an alternate and/or different approach baked into junit - or do I roll my own tiny extension

static boolean assertEquals(double d1, double d2) {
return Math.abs(d1 - d2) < 1e-8;

Answer Source

Yes, use assertEquals(double expected, double actual, double delta) instead.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download