### Question:
NumberVerifier { public static void checkNoInfinityOrNaN(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)) { throw new ArithmeticException("Not a valid input: INFINITY: " + dValue); } } } private  NumberVerifier(); static void checkNoInfinityOrNaN(Number number); static boolean isInfinityAndNotNaN(Number number);  }### Answer:
@Test public void shouldIgnoreNumberWhenNumberIsNotInfinityOrNaN() { NumberVerifier.checkNoInfinityOrNaN(BigDecimal.ONE); NumberVerifier.checkNoInfinityOrNaN(1L); NumberVerifier.checkNoInfinityOrNaN(Float.MIN_NORMAL); NumberVerifier.checkNoInfinityOrNaN(Double.MIN_NORMAL); }
@Test(expectedExceptions = ArithmeticException.class) public void shouldIReturnErrorWhenFloatIsNAN() { NumberVerifier.checkNoInfinityOrNaN(Float.NaN); }
@Test(expectedExceptions = ArithmeticException.class) public void shouldIReturnErrorWhenFloatIsNegativeInfinite() { NumberVerifier.checkNoInfinityOrNaN(Float.NEGATIVE_INFINITY); }
@Test(expectedExceptions = ArithmeticException.class) public void shouldIReturnErrorWhenFloatIsPositiveInfinite() { NumberVerifier.checkNoInfinityOrNaN(Float.POSITIVE_INFINITY); }
@Test(expectedExceptions = ArithmeticException.class) public void shouldIReturnErrorWhenDoubleIsNAN() { NumberVerifier.checkNoInfinityOrNaN(Double.NaN); }
@Test(expectedExceptions = ArithmeticException.class) public void shouldIReturnErrorWhenDoubleIsNegativeInfinite() { NumberVerifier.checkNoInfinityOrNaN(Double.NEGATIVE_INFINITY); }
@Test(expectedExceptions = ArithmeticException.class) public void shouldIReturnErrorWhenDoubleIsPositiveInfinite() { NumberVerifier.checkNoInfinityOrNaN(Double.POSITIVE_INFINITY); }