@Test(expectedExceptions = ArithmeticException.class) public void shouldReturnsWhenDoubleIsNAN() { assertTrue(NumberVerifier.isInfinityAndNotNaN(Double.NaN)); }
public static boolean isInfinityAndNotNaN(Number number) { if (Double.class == number.getClass() || Float.class == number.getClass()) { double dValue = number.doubleValue(); if (Double.isNaN(dValue)) { throw new ArithmeticException("Not a valid input: NaN."); } else if (Double.isInfinite(dValue)) { return true; } } return false; }
NumberVerifier { public static boolean isInfinityAndNotNaN(Number number) { if (Double.class == number.getClass() || Float.class == number.getClass()) { double dValue = number.doubleValue(); if (Double.isNaN(dValue)) { throw new ArithmeticException("Not a valid input: NaN."); } else if (Double.isInfinite(dValue)) { return true; } } return false; } }
NumberVerifier { public static boolean isInfinityAndNotNaN(Number number) { if (Double.class == number.getClass() || Float.class == number.getClass()) { double dValue = number.doubleValue(); if (Double.isNaN(dValue)) { throw new ArithmeticException("Not a valid input: NaN."); } else if (Double.isInfinite(dValue)) { return true; } } return false; } private  NumberVerifier(); }
NumberVerifier { public static boolean isInfinityAndNotNaN(Number number) { if (Double.class == number.getClass() || Float.class == number.getClass()) { double dValue = number.doubleValue(); if (Double.isNaN(dValue)) { throw new ArithmeticException("Not a valid input: NaN."); } else if (Double.isInfinite(dValue)) { return true; } } return false; } private  NumberVerifier(); static void checkNoInfinityOrNaN(Number number); static boolean isInfinityAndNotNaN(Number number); }
NumberVerifier { public static boolean isInfinityAndNotNaN(Number number) { if (Double.class == number.getClass() || Float.class == number.getClass()) { double dValue = number.doubleValue(); if (Double.isNaN(dValue)) { throw new ArithmeticException("Not a valid input: NaN."); } else if (Double.isInfinite(dValue)) { return true; } } return false; } private  NumberVerifier(); static void checkNoInfinityOrNaN(Number number); static boolean isInfinityAndNotNaN(Number number);  }