public void testHashCodesM3_32_double() { int seed = 123; Random rand = new Random(seed); HashFunction hf = Hashing.murmur3_32(seed); for (int i = 0; i < 1000; i++) { double val = rand.nextDouble(); byte[] data = ByteBuffer.allocate(8).putDouble(val).array(); int hc1 = hf.hashBytes(data).asInt(); int hc2 = Murmur3.hash32(data, data.length, seed); Assert.Equal(hc1, hc2); } }
public void testHashCodesM3_32_string() { string key = "test"; int seed = 123; HashFunction hf = Hashing.murmur3_32(seed); int hc1 = hf.hashBytes(key.getBytes()).asInt(); int hc2 = Murmur3.hash32(key.getBytes(), key.getBytes().length, seed); Assert.Equal(hc1, hc2); key = "testkey"; hc1 = hf.hashBytes(key.getBytes()).asInt(); hc2 = Murmur3.hash32(key.getBytes(), key.getBytes().length, seed); Assert.Equal(hc1, hc2); }