Ejemplo n.º 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) {
     }
   }
 }
Ejemplo n.º 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));
     }
   }
 }
Ejemplo n.º 3
0
 public void testRoundNaNToBigIntegerAlwaysFails() {
   for (RoundingMode mode : ALL_ROUNDING_MODES) {
     try {
       DoubleMath.roundToBigInteger(Double.NaN, mode);
       fail("Expected ArithmeticException");
     } catch (ArithmeticException expected) {
     }
   }
 }
Ejemplo n.º 4
0
 public void testRoundExactFractionalDoubleToBigIntegerFails() {
   for (double d : FRACTIONAL_DOUBLE_CANDIDATES) {
     try {
       DoubleMath.roundToBigInteger(d, UNNECESSARY);
       fail("Expected ArithmeticException");
     } catch (ArithmeticException expected) {
     }
   }
 }
Ejemplo n.º 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));
   }
 }