public void testCombineOrdered_randomHashCodes() { Random random = new Random(7); List<HashCode> hashCodes = Lists.newArrayList(); for (int i = 0; i < 10; i++) { hashCodes.add(HashCode.fromLong(random.nextLong())); } HashCode hashCode1 = Hashing.combineOrdered(hashCodes); Collections.shuffle(hashCodes, random); HashCode hashCode2 = Hashing.combineOrdered(hashCodes); assertFalse(hashCode1.equals(hashCode2)); }
public void testCombineOrdered() { HashCode hash31 = HashCode.fromInt(31); HashCode hash32 = HashCode.fromInt(32); assertEquals(hash32, Hashing.combineOrdered(ImmutableList.of(hash32))); assertEquals( HashCode.fromBytes(new byte[] {(byte) 0x80, 0, 0, 0}), Hashing.combineOrdered(ImmutableList.of(hash32, hash32))); assertEquals( HashCode.fromBytes(new byte[] {(byte) 0xa0, 0, 0, 0}), Hashing.combineOrdered(ImmutableList.of(hash32, hash32, hash32))); assertFalse( Hashing.combineOrdered(ImmutableList.of(hash31, hash32)) .equals(Hashing.combineOrdered(ImmutableList.of(hash32, hash31)))); }
public void testCombineOrdered_randomHashCodes() { Random random = new Random(7); List<HashCode> hashCodes = Lists.newArrayList(); for (int i = 0; i < 10; i++) { hashCodes.add(HashCode.fromLong(random.nextLong())); } HashCode hashCode1 = Hashing.combineOrdered(hashCodes); Collections.shuffle(hashCodes, random); HashCode hashCode2 = Hashing.combineOrdered(hashCodes); assertFalse(hashCode1.equals(hashCode2)); }
public void testCombineOrdered() { HashCode hash31 = HashCode.fromInt(31); HashCode hash32 = HashCode.fromInt(32); assertEquals(hash32, Hashing.combineOrdered(ImmutableList.of(hash32))); assertEquals(HashCode.fromBytes(new byte[] { (byte) 0x80, 0, 0, 0 }), Hashing.combineOrdered(ImmutableList.of(hash32, hash32))); assertEquals(HashCode.fromBytes(new byte[] { (byte) 0xa0, 0, 0, 0 }), Hashing.combineOrdered(ImmutableList.of(hash32, hash32, hash32))); assertFalse( Hashing.combineOrdered(ImmutableList.of(hash31, hash32)).equals( Hashing.combineOrdered(ImmutableList.of(hash32, hash31)))); }