Search in sources :

Example 91 with GwtIncompatible

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

the class LongMathTest method testIsPrimeOnRandomComposites.

// isPrime is GWT-incompatible
@GwtIncompatible
public void testIsPrimeOnRandomComposites() {
    Random rand = new Random(1);
    for (int bits = 5; bits < 32; bits++) {
        for (int i = 0; i < 100; i++) {
            long p = BigInteger.probablePrime(bits, rand).longValue();
            long q = BigInteger.probablePrime(bits, rand).longValue();
            assertFalse(LongMath.isPrime(p * q));
        }
    }
}
Also used : Random(java.util.Random) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 92 with GwtIncompatible

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

the class LongMathTest method testCheckedSubtract.

// TODO
@GwtIncompatible
// slow
@AndroidIncompatible
public void testCheckedSubtract() {
    for (long a : ALL_LONG_CANDIDATES) {
        for (long b : ALL_LONG_CANDIDATES) {
            BigInteger expectedResult = valueOf(a).subtract(valueOf(b));
            boolean expectedSuccess = fitsInLong(expectedResult);
            try {
                assertEquals(a - b, LongMath.checkedSubtract(a, b));
                assertTrue(expectedSuccess);
            } catch (ArithmeticException e) {
                if (expectedSuccess) {
                    failFormat("expected checkedSubtract(%s, %s) = %s; got ArithmeticException", a, b, expectedResult);
                }
            }
        }
    }
}
Also used : BigInteger(java.math.BigInteger) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 93 with GwtIncompatible

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

the class LongMathTest method testDivByZeroAlwaysFails.

// TODO
@GwtIncompatible
public void testDivByZeroAlwaysFails() {
    for (long p : ALL_LONG_CANDIDATES) {
        for (RoundingMode mode : ALL_ROUNDING_MODES) {
            try {
                LongMath.divide(p, 0L, mode);
                fail("Expected ArithmeticException");
            } catch (ArithmeticException expected) {
            }
        }
    }
}
Also used : RoundingMode(java.math.RoundingMode) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 94 with GwtIncompatible

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

the class UnsignedLongsTest method testDivideRemainderEuclideanProperty.

// Too slow in GWT (~3min fully optimized)
@GwtIncompatible
public void testDivideRemainderEuclideanProperty() {
    // Use a seed so that the test is deterministic:
    Random r = new Random(0L);
    for (int i = 0; i < 1000000; i++) {
        long dividend = r.nextLong();
        long divisor = r.nextLong();
        // Test that the Euclidean property is preserved:
        assertEquals(0, dividend - (divisor * UnsignedLongs.divide(dividend, divisor) + UnsignedLongs.remainder(dividend, divisor)));
    }
}
Also used : Random(java.util.Random) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

Example 95 with GwtIncompatible

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

the class IntsTest method testStringConverter_nullPointerTester.

// NullPointerTester
@GwtIncompatible
public void testStringConverter_nullPointerTester() throws Exception {
    NullPointerTester tester = new NullPointerTester();
    tester.testAllPublicInstanceMethods(Ints.stringConverter());
}
Also used : NullPointerTester(com.google.common.testing.NullPointerTester) 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