This commit is contained in:
Looly 2020-03-25 09:55:06 +08:00
parent 2e9e174594
commit b6fd1e2beb

View File

@ -0,0 +1,29 @@
package cn.hutool.core.util;
import org.junit.Assert;
import org.junit.Test;
public class HashUtilTest {
@Test
public void cityHash128Test(){
String s="Google发布的Hash计算算法CityHash64 与 CityHash128";
final long[] hash = HashUtil.cityHash128(StrUtil.utf8Bytes(s));
Assert.assertEquals(0x5944f1e788a18db0L, hash[0]);
Assert.assertEquals(0xc2f68d8b2bf4a5cfL, hash[1]);
}
@Test
public void cityHash64Test(){
String s="Google发布的Hash计算算法CityHash64 与 CityHash128";
final long hash = HashUtil.cityHash64(StrUtil.utf8Bytes(s));
Assert.assertEquals(0x1d408f2bbf967e2aL, hash);
}
@Test
public void cityHash32Test(){
String s="Google发布的Hash计算算法CityHash64 与 CityHash128";
final int hash = HashUtil.cityHash32(StrUtil.utf8Bytes(s));
Assert.assertEquals(0xa8944fbe, hash);
}
}