I am trying to pass Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY and Double.NaN as CSV parameters in JUnit5:
@DisplayName("Testing ActivationFunction.heaviside")
@ParameterizedTest(name = "Testing ActivationFunction.heaviside ({0},{1})")
@CsvSource({
"Double.NEGATIVE_INFINITY, 0",
"-100, 0",
"-1, 0",
"0, 0.5",
"1, 1",
"100, 1",
"Double.POSITIVE_INFINITY, 0",
"Double.NaN, Double.NaN"
})
void testActivationFunction_heaviside(double input, double output) {
assertEquals(output, ActivationFunction.heaviside(input));
}
Unfortunately, it triggers errors like "Error converting parameter at index 0: Failed to convert String "Double.POSITIVE_INFINITY" to type java.lang.Double" in the JUnit5 test runner.
Is there a good way to automatically pass such values for testing, or I have just to write a separate test method as follows:
assertEquals(0, Double.NEGATIVE_INFINITY);
assertEquals(1, Double.POSITIVE_INFINITY);
assertEquals(Double.NaN, Double.NaN);