Search in sources :

Example 81 with GwtIncompatible

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

the class DoubleMathTest method testNullPointers.

// NullPointerTester
@GwtIncompatible
public void testNullPointers() {
    NullPointerTester tester = new NullPointerTester();
    tester.setDefault(double.class, 3.0);
    tester.testAllPublicStaticMethods(DoubleMath.class);
}
Also used : NullPointerTester(com.google.common.testing.NullPointerTester) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 82 with GwtIncompatible

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

the class DoubleMathTest method testRoundNaNToIntAlwaysFails.

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

Example 83 with GwtIncompatible

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

the class DoubleMathTest method testRoundFractionalDoubleToInt.

// DoubleMath.roundToInt(double, RoundingMode)
@GwtIncompatible
public void testRoundFractionalDoubleToInt() {
    for (double d : FRACTIONAL_DOUBLE_CANDIDATES) {
        for (RoundingMode mode : ALL_SAFE_ROUNDING_MODES) {
            BigDecimal expected = new BigDecimal(d).setScale(0, mode);
            boolean isInBounds = expected.compareTo(MAX_INT_AS_BIG_DECIMAL) <= 0 & expected.compareTo(MIN_INT_AS_BIG_DECIMAL) >= 0;
            try {
                assertEquals("Rounding " + d + " with mode " + mode, expected.intValue(), DoubleMath.roundToInt(d, mode));
                assertTrue(isInBounds);
            } catch (ArithmeticException e) {
                assertFalse(isInBounds);
            }
        }
    }
}
Also used : RoundingMode(java.math.RoundingMode) BigDecimal(java.math.BigDecimal) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 84 with GwtIncompatible

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

the class DoubleMathTest method testRoundNaNToBigIntegerAlwaysFails.

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

Example 85 with GwtIncompatible

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

the class DoubleMathTest method testRoundInfiniteToBigIntegerAlwaysFails.

// DoubleMath.roundToBigInteger(double, RoundingMode)
@GwtIncompatible
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) {
        }
    }
}
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