/** * <p>Validates that the specified argument is not {@code NaN}; otherwise * throwing an exception.</p> * * <pre>Validate.notNaN(myDouble);</pre> * * <p>The message of the exception is "The validated value is not a * number".</p> * * @param value the value to validate * @throws IllegalArgumentException if the value is not a number * @see #notNaN(double, java.lang.String, java.lang.Object...) * * @since 3.5 */ public static void notNaN(final double value) { notNaN(value, DEFAULT_NOT_NAN_EX_MESSAGE); }
@Test public void testNotNaN2() { Validate.notNaN(0.0, "MSG"); Validate.notNaN(Double.POSITIVE_INFINITY, "MSG"); Validate.notNaN(Double.NEGATIVE_INFINITY, "MSG"); try { Validate.notNaN(Double.NaN, "MSG"); fail("Expecting IllegalArgumentException"); } catch (final IllegalArgumentException ex) { assertEquals("MSG", ex.getMessage()); } }
@Test public void testNotNaN1() { Validate.notNaN(0.0); Validate.notNaN(Double.POSITIVE_INFINITY); Validate.notNaN(Double.NEGATIVE_INFINITY); try { Validate.notNaN(Double.NaN); fail("Expecting IllegalArgumentException"); } catch (final IllegalArgumentException ex) { assertEquals("The validated value is not a number", ex.getMessage()); } }
/** * <p>Validates that the specified argument is not {@code NaN}; otherwise * throwing an exception.</p> * * <pre>Validate.notNaN(myDouble);</pre> * * <p>The message of the exception is "The validated value is not a * number".</p> * * @param value the value to validate * @throws IllegalArgumentException if the value is not a number * @see #notNaN(double, java.lang.String, java.lang.Object...) * * @since 3.5 */ public static void notNaN(final double value) { notNaN(value, DEFAULT_NOT_NAN_EX_MESSAGE); }
/** * <p>Validates that the specified argument is not {@code NaN}; otherwise * throwing an exception.</p> * * <pre>Validate.notNaN(myDouble);</pre> * * <p>The message of the exception is "The validated value is not a * number".</p> * * @param value the value to validate * @throws IllegalArgumentException if the value is not a number * @see #notNaN(double, java.lang.String, java.lang.Object...) * * @since 3.5 */ public static void notNaN(final double value) { notNaN(value, DEFAULT_NOT_NAN_EX_MESSAGE); }
/** * <p>Validates that the specified argument is not {@code NaN}; otherwise * throwing an exception.</p> * * <pre>Validate.notNaN(myDouble);</pre> * * <p>The message of the exception is "The validated value is not a * number".</p> * * @param value the value to validate * @throws IllegalArgumentException if the value is not a number * @see #notNaN(double, java.lang.String, java.lang.Object...) * * @since 3.5 */ public static void notNaN(final double value) { notNaN(value, DEFAULT_NOT_NAN_EX_MESSAGE); }