public void testFactorial() { for (int i = 0; i <= DoubleMath.MAX_FACTORIAL; i++) { double actual = BigIntegerMath.factorial(i).doubleValue(); double result = DoubleMath.factorial(i); assertEquals(actual, result, Math.ulp(actual)); } }
public void testFactorialNegative() { for (int n : NEGATIVE_INTEGER_CANDIDATES) { try { DoubleMath.factorial(n); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } } }
public void testFactorialTooHigh() { assertEquals(Double.POSITIVE_INFINITY, DoubleMath.factorial(DoubleMath.MAX_FACTORIAL + 1)); assertEquals(Double.POSITIVE_INFINITY, DoubleMath.factorial(DoubleMath.MAX_FACTORIAL + 20)); }