Example #1
0
 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));
   }
 }
Example #2
0
 public void testFactorialNegative() {
   for (int n : NEGATIVE_INTEGER_CANDIDATES) {
     try {
       DoubleMath.factorial(n);
       fail("Expected IllegalArgumentException");
     } catch (IllegalArgumentException expected) {
     }
   }
 }
Example #3
0
 public void testFactorialTooHigh() {
   assertEquals(Double.POSITIVE_INFINITY, DoubleMath.factorial(DoubleMath.MAX_FACTORIAL + 1));
   assertEquals(Double.POSITIVE_INFINITY, DoubleMath.factorial(DoubleMath.MAX_FACTORIAL + 20));
 }