Search in sources :

Example 86 with GwtIncompatible

use of com.google.common.annotations.GwtIncompatible in project guava by google.

the class DoubleMathTest method testRoundNaNToLongAlwaysFails.

// DoubleMath.roundToLong(double, RoundingMode)
@GwtIncompatible
public void testRoundNaNToLongAlwaysFails() {
    for (RoundingMode mode : ALL_ROUNDING_MODES) {
        try {
            DoubleMath.roundToLong(Double.NaN, mode);
            fail("Expected ArithmeticException");
        } catch (ArithmeticException expected) {
        }
    }
}
Also used : RoundingMode(java.math.RoundingMode) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 87 with GwtIncompatible

use of com.google.common.annotations.GwtIncompatible in project guava by google.

the class DoubleMathTest method testRoundIntegralDoubleToBigInteger.

// DoubleMath.roundToBigInteger(double, RoundingMode)
@GwtIncompatible
public void testRoundIntegralDoubleToBigInteger() {
    for (double d : INTEGRAL_DOUBLE_CANDIDATES) {
        for (RoundingMode mode : ALL_SAFE_ROUNDING_MODES) {
            BigDecimal expected = new BigDecimal(d).setScale(0, mode);
            assertEquals(expected.toBigInteger(), DoubleMath.roundToBigInteger(d, mode));
        }
    }
}
Also used : RoundingMode(java.math.RoundingMode) BigDecimal(java.math.BigDecimal) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 88 with GwtIncompatible

use of com.google.common.annotations.GwtIncompatible in project guava by google.

the class IntMathTest method testLog10NegativeAlwaysThrows.

// log10
@GwtIncompatible
public void testLog10NegativeAlwaysThrows() {
    for (int x : NEGATIVE_INTEGER_CANDIDATES) {
        for (RoundingMode mode : ALL_ROUNDING_MODES) {
            try {
                IntMath.log10(x, mode);
                fail("Expected IllegalArgumentException");
            } catch (IllegalArgumentException expected) {
            }
        }
    }
}
Also used : RoundingMode(java.math.RoundingMode) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 89 with GwtIncompatible

use of com.google.common.annotations.GwtIncompatible in project guava by google.

the class LongMathTest method testConstantsHalfPowersOf10.

// TODO
@GwtIncompatible
public void testConstantsHalfPowersOf10() {
    for (int i = 0; i < LongMath.halfPowersOf10.length; i++) {
        assertEquals(BigIntegerMath.sqrt(BigInteger.TEN.pow(2 * i + 1), FLOOR), BigInteger.valueOf(LongMath.halfPowersOf10[i]));
    }
    BigInteger nextBigger = BigIntegerMath.sqrt(BigInteger.TEN.pow(2 * LongMath.halfPowersOf10.length + 1), FLOOR);
    assertTrue(nextBigger.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0);
}
Also used : BigInteger(java.math.BigInteger) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 90 with GwtIncompatible

use of com.google.common.annotations.GwtIncompatible in project guava by google.

the class LongMathTest method testSqrtNegativeAlwaysThrows.

// TODO
@GwtIncompatible
public void testSqrtNegativeAlwaysThrows() {
    for (long x : NEGATIVE_LONG_CANDIDATES) {
        for (RoundingMode mode : ALL_ROUNDING_MODES) {
            try {
                LongMath.sqrt(x, mode);
                fail("Expected IllegalArgumentException");
            } catch (IllegalArgumentException expected) {
            }
        }
    }
}
Also used : RoundingMode(java.math.RoundingMode) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Aggregations

GwtIncompatible (com.google.common.annotations.GwtIncompatible)361 NullPointerTester (com.google.common.testing.NullPointerTester)105 TestSuite (junit.framework.TestSuite)54 BigInteger (java.math.BigInteger)40 RoundingMode (java.math.RoundingMode)39 CountDownLatch (java.util.concurrent.CountDownLatch)25 ExecutorService (java.util.concurrent.ExecutorService)18 CancellationException (java.util.concurrent.CancellationException)17 Random (java.util.Random)16 ListTestSuiteBuilder (com.google.common.collect.testing.ListTestSuiteBuilder)15 ExecutionException (java.util.concurrent.ExecutionException)15 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)15 IOException (java.io.IOException)14 BigDecimal (java.math.BigDecimal)14 TestStringSetGenerator (com.google.common.collect.testing.TestStringSetGenerator)11 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)11 TimeoutException (java.util.concurrent.TimeoutException)11 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)11 EqualsTester (com.google.common.testing.EqualsTester)10 List (java.util.List)10