MathUtils { public static void checkFinite(final double x) throws NotFiniteNumberException { if (Double.isInfinite(x) || Double.isNaN(x)) { throw new NotFiniteNumberException(x); } } private  MathUtils(); static int hash(double value); static boolean equals(double x, double y); static int hash(double[] value); static double normalizeAngle(double a, double center); static double reduce(double a,
                                double period,
                                double offset); static byte copySign(byte magnitude, byte sign); static short copySign(short magnitude, short sign); static int copySign(int magnitude, int sign); static long copySign(long magnitude, long sign); static void checkFinite(final double x); static void checkFinite(final double[] val); static void checkNotNull(Object o,
                                    Localizable pattern,
                                    Object ... args); static void checkNotNull(Object o); static final double TWO_PI; static final double PI_SQUARED; }
@Test public void testCheckFinite() { try { MathUtils.checkFinite(Double.POSITIVE_INFINITY); Assert.fail("an exception should have been thrown"); } catch (NotFiniteNumberException e) { } try { MathUtils.checkFinite(Double.NEGATIVE_INFINITY); Assert.fail("an exception should have been thrown"); } catch (NotFiniteNumberException e) { } try { MathUtils.checkFinite(Double.NaN); Assert.fail("an exception should have been thrown"); } catch (NotFiniteNumberException e) { } try { MathUtils.checkFinite(new double[] {0, -1, Double.POSITIVE_INFINITY, -2, 3}); Assert.fail("an exception should have been thrown"); } catch (NotFiniteNumberException e) { } try { MathUtils.checkFinite(new double[] {1, Double.NEGATIVE_INFINITY, -2, 3}); Assert.fail("an exception should have been thrown"); } catch (NotFiniteNumberException e) { } try { MathUtils.checkFinite(new double[] {4, 3, -1, Double.NaN, -2, 1}); Assert.fail("an exception should have been thrown"); } catch (NotFiniteNumberException e) { } }