public void testCombineUnordered_differentBitLengths() { try { Hashing.combineUnordered(ImmutableList.of(HashCodes.fromInt(32), HashCodes.fromLong(32L))); fail(); } catch (IllegalArgumentException expected) { } }
public void testCombineUnordered_randomHashCodes() { Random random = new Random(); List<HashCode> hashCodes = Lists.newArrayList(); for (int i = 0; i < 10; i++) { hashCodes.add(HashCodes.fromLong(random.nextLong())); } HashCode hashCode1 = Hashing.combineUnordered(hashCodes); Collections.shuffle(hashCodes); HashCode hashCode2 = Hashing.combineUnordered(hashCodes); assertEquals(hashCode1, hashCode2); }
public void testConsistentHash_ofHashCode() { checkSameResult(HashCodes.fromLong(1), 1); checkSameResult(HashCodes.fromLong(0x9999999999999999L), 0x9999999999999999L); checkSameResult(HashCodes.fromInt(0x99999999), 0x0000000099999999L); }
public void testPadToLong() { assertEquals(0x1111111111111111L, Hashing.padToLong(HashCodes.fromLong(0x1111111111111111L))); assertEquals(0x9999999999999999L, Hashing.padToLong(HashCodes.fromLong(0x9999999999999999L))); assertEquals(0x0000000011111111L, Hashing.padToLong(HashCodes.fromInt(0x11111111))); assertEquals(0x0000000099999999L, Hashing.padToLong(HashCodes.fromInt(0x99999999))); }