示例#1
0
 public void testRoundInfiniteToBigIntegerAlwaysFails() {
   for (RoundingMode mode : ALL_ROUNDING_MODES) {
     try {
       DoubleMath.roundToBigInteger(Double.POSITIVE_INFINITY, mode);
       fail("Expected ArithmeticException");
     } catch (ArithmeticException expected) {
     }
     try {
       DoubleMath.roundToBigInteger(Double.NEGATIVE_INFINITY, mode);
       fail("Expected ArithmeticException");
     } catch (ArithmeticException expected) {
     }
   }
 }
示例#2
0
 public void testRoundFractionalDoubleToBigInteger() {
   for (double d : FRACTIONAL_DOUBLE_CANDIDATES) {
     for (RoundingMode mode : ALL_SAFE_ROUNDING_MODES) {
       BigDecimal expected = new BigDecimal(d).setScale(0, mode);
       assertEquals(expected.toBigInteger(), DoubleMath.roundToBigInteger(d, mode));
     }
   }
 }
示例#3
0
 public void testRoundNaNToBigIntegerAlwaysFails() {
   for (RoundingMode mode : ALL_ROUNDING_MODES) {
     try {
       DoubleMath.roundToBigInteger(Double.NaN, mode);
       fail("Expected ArithmeticException");
     } catch (ArithmeticException expected) {
     }
   }
 }
示例#4
0
 public void testRoundExactFractionalDoubleToBigIntegerFails() {
   for (double d : FRACTIONAL_DOUBLE_CANDIDATES) {
     try {
       DoubleMath.roundToBigInteger(d, UNNECESSARY);
       fail("Expected ArithmeticException");
     } catch (ArithmeticException expected) {
     }
   }
 }
示例#5
0
 public void testRoundExactIntegralDoubleToBigInteger() {
   for (double d : INTEGRAL_DOUBLE_CANDIDATES) {
     BigDecimal expected = new BigDecimal(d).setScale(0, UNNECESSARY);
     assertEquals(expected.toBigInteger(), DoubleMath.roundToBigInteger(d, UNNECESSARY));
   }
 }