use of java.math.RoundingMode in project guava by hceylan.
the class BigIntegerMathTest method testDivByZeroAlwaysFails.
public void testDivByZeroAlwaysFails() {
for (BigInteger p : ALL_BIGINTEGER_CANDIDATES) {
for (RoundingMode mode : ALL_ROUNDING_MODES) {
try {
BigIntegerMath.divide(p, ZERO, mode);
fail("Expected ArithmeticException");
} catch (ArithmeticException expected) {
}
}
}
}
use of java.math.RoundingMode in project guava by hceylan.
the class BigIntegerMathTest method testDivNonZero.
public void testDivNonZero() {
for (BigInteger p : NONZERO_BIGINTEGER_CANDIDATES) {
for (BigInteger q : NONZERO_BIGINTEGER_CANDIDATES) {
for (RoundingMode mode : ALL_SAFE_ROUNDING_MODES) {
BigInteger expected = new BigDecimal(p).divide(new BigDecimal(q), 0, mode).toBigIntegerExact();
assertEquals(expected, BigIntegerMath.divide(p, q, mode));
}
}
}
}
use of java.math.RoundingMode in project guava by hceylan.
the class BigIntegerMathTest method testLog10Floor.
public void testLog10Floor() {
for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
for (RoundingMode mode : asList(FLOOR, DOWN)) {
int result = BigIntegerMath.log10(x, mode);
assertTrue(TEN.pow(result).compareTo(x) <= 0);
assertTrue(TEN.pow(result + 1).compareTo(x) > 0);
}
}
}
use of java.math.RoundingMode in project guava by hceylan.
the class IntMathTest method testLog2ZeroAlwaysThrows.
@GwtIncompatible("log2")
public void testLog2ZeroAlwaysThrows() {
for (RoundingMode mode : ALL_ROUNDING_MODES) {
try {
IntMath.log2(0, mode);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
}
}
}
use of java.math.RoundingMode in project guava by hceylan.
the class IntMathTest method testDivByZeroAlwaysFails.
@GwtIncompatible("pow()")
public void testDivByZeroAlwaysFails() {
for (int p : ALL_INTEGER_CANDIDATES) {
for (RoundingMode mode : ALL_ROUNDING_MODES) {
try {
IntMath.divide(p, 0, mode);
fail("Expected ArithmeticException");
} catch (ArithmeticException expected) {
}
}
}
}
Aggregations