@AndroidIncompatible // OutOfMemoryError public void testLargeBloomFilterDoesntOverflow() { long numBits = Integer.MAX_VALUE; numBits++; LockFreeBitArray bitArray = new LockFreeBitArray(numBits); assertTrue( "BitArray.bitSize() must return a positive number, but was " + bitArray.bitSize(), bitArray.bitSize() > 0); // Ideally we would also test the bitSize() overflow of this BF, but it runs out of heap space // BloomFilter.create(Funnels.unencodedCharsFunnel(), 244412641, 1e-11); }
@AndroidIncompatible // OutOfMemoryError public void testLargeNumberOfInsertions() { // We use horrible FPPs here to keep Java from OOM'ing BloomFilter<String> unused = BloomFilter.create(Funnels.unencodedCharsFunnel(), Integer.MAX_VALUE / 2, 0.29); unused = BloomFilter.create(Funnels.unencodedCharsFunnel(), 45L * Integer.MAX_VALUE, 0.99); }
@AndroidIncompatible // slow TODO(cpovirk): Maybe just reduce iterations under Android. public void testGoodFastHash() { for (int i = 1; i < 200; i += 17) { HashFunction hasher = Hashing.goodFastHash(i); assertTrue(hasher.bits() >= i); HashTestUtils.assertInvariants(hasher); } }
@AndroidIncompatible // slow public void testBitSize() { double fpp = 0.03; for (int i = 1; i < 10000; i++) { long numBits = BloomFilter.optimalNumOfBits(i, fpp); int arraySize = Ints.checkedCast(LongMath.divide(numBits, 64, RoundingMode.CEILING)); assertEquals( arraySize * Long.SIZE, BloomFilter.create(Funnels.unencodedCharsFunnel(), i, fpp).bitSize()); } }
@AndroidIncompatible // slow. TODO(cpovirk): Maybe just reduce iterations under Android. public void testExhaustive() throws Exception { Random random = new Random(0); // will iteratively make more debuggable, each time it breaks
@AndroidIncompatible // sun.security public void testNoProviders() { ProviderList providers = Providers.getProviderList(); Providers.setProviderList(ProviderList.newList()); try { Hashing.hmacMd5(MD5_KEY); fail("expected ISE"); } catch (IllegalStateException expected) { } finally { Providers.setProviderList(providers); } }
@AndroidIncompatible // slow TODO(cpovirk): Maybe just reduce iterations under Android. public void testGoodFastHash() { for (int i = 1; i < 200; i += 17) { HashFunction hasher = Hashing.goodFastHash(i); assertTrue(hasher.bits() >= i); HashTestUtils.assertInvariants(hasher); } }
@AndroidIncompatible // OutOfMemoryError public void testLargeBloomFilterDoesntOverflow() { long numBits = Integer.MAX_VALUE; numBits++; LockFreeBitArray bitArray = new LockFreeBitArray(numBits); assertTrue( "BitArray.bitSize() must return a positive number, but was " + bitArray.bitSize(), bitArray.bitSize() > 0); // Ideally we would also test the bitSize() overflow of this BF, but it runs out of heap space // BloomFilter.create(Funnels.unencodedCharsFunnel(), 244412641, 1e-11); }
@AndroidIncompatible // OutOfMemoryError public void testLargeNumberOfInsertions() { // We use horrible FPPs here to keep Java from OOM'ing BloomFilter<String> unused = BloomFilter.create(Funnels.unencodedCharsFunnel(), Integer.MAX_VALUE / 2, 0.29); unused = BloomFilter.create(Funnels.unencodedCharsFunnel(), 45L * Integer.MAX_VALUE, 0.99); }
@AndroidIncompatible // slow public void testBitSize() { double fpp = 0.03; for (int i = 1; i < 10000; i++) { long numBits = BloomFilter.optimalNumOfBits(i, fpp); int arraySize = Ints.checkedCast(LongMath.divide(numBits, 64, RoundingMode.CEILING)); assertEquals( arraySize * Long.SIZE, BloomFilter.create(Funnels.unencodedCharsFunnel(), i, fpp).bitSize()); } }
@AndroidIncompatible // slow. TODO(cpovirk): Maybe just reduce iterations under Android. public void testExhaustive() throws Exception { Random random = new Random(0); // will iteratively make more debuggable, each time it breaks
@AndroidIncompatible // sun.security public void testNoProviders() { ProviderList providers = Providers.getProviderList(); Providers.setProviderList(ProviderList.newList()); try { Hashing.hmacMd5(MD5_KEY); fail("expected ISE"); } catch (IllegalStateException expected) { } finally { Providers.setProviderList(providers); } }