Misc { public static boolean doubleEquals(final double a, final double b, final double epsilon) { final double diff = Math.abs(a - b); return diff < epsilon || (Double.isNaN(diff) && a == b); } private  Misc(); static boolean containsNulls(final Collection c); static boolean doubleEquals(final double a, final double b, final double epsilon); static boolean doubleArrayEquals(final double[] a, final double[] b, final double epsilon);  }
@Test public void testDoubleEquals1() { final double a = Math.sqrt(2); final double b = Math.sqrt(3)*Math.sqrt(2)/Math.sqrt(3); assert(a != b); assertTrue(Misc.doubleEquals(a, b, 0.00001)); }
@Test public void testDoubleEquals2() { final double a = 1; final double b = 2; assertFalse(Misc.doubleEquals(a, b, 0.00001)); }
@Test public void testDoubleEquals3() { final double a = 0.00001; final double b = 0.00001; assertTrue(Misc.doubleEquals(a, b, 0.00001)); }
@Test public void testDoubleEquals4() { final double a = 0.000000000001; final double b = 0.000000000002; assertTrue(Misc.doubleEquals(a, b, 0.001)); assertFalse(Misc.doubleEquals(a, b, 0.0000000000001)); }
@Test public void testDoubleEquals5() { final double a = Double.POSITIVE_INFINITY; final double b = 10.0; assertFalse(Misc.doubleEquals(a, b, 0.00001)); }
@Test public void testDoubleEquals6() { final double a = Double.POSITIVE_INFINITY; final double b = Double.POSITIVE_INFINITY; assert(a == b); assertTrue(Misc.doubleEquals(a, b, 0.00001)); }
@Test public void testDoubleEquals7() { final double a = Double.NEGATIVE_INFINITY; final double b = Double.NEGATIVE_INFINITY; assert(a == b); assertTrue(Misc.doubleEquals(a, b, 0.00001)); }
@Test public void testDoubleEquals8() { final double a = Double.NEGATIVE_INFINITY; final double b = Double.POSITIVE_INFINITY; assert(a != b); assertFalse(Misc.doubleEquals(a, b, 0.00001)); }