This commit is contained in:
Looly
2024-03-18 16:22:46 +08:00
parent a34cb71bc0
commit de6eb1deea
4 changed files with 12 additions and 22 deletions

View File

@@ -135,7 +135,7 @@ public class MetroHash128Test {
@Test
public void metroHash128GetLongArrayTest() {
final byte[] str = "我是一段测试123".getBytes(CharsetUtil.UTF_8);
final long[] hash128 = MetroHash128.of(0).hash128(str).getLongArray();
final long[] hash128 = MetroHash128.of(0).hash128(str).getLongArray(ByteOrder.BIG_ENDIAN);
Assertions.assertEquals(228255164667538345L, hash128[0]);
Assertions.assertEquals(-6394585948993412256L, hash128[1]);
}

View File

@@ -13,16 +13,17 @@
package org.dromara.hutool.core.util;
import org.dromara.hutool.core.codec.hash.HashUtil;
import org.dromara.hutool.core.util.ByteUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.nio.ByteOrder;
public class HashUtilTest {
@Test
public void cityHash128Test(){
final String s="Google发布的Hash计算算法CityHash64 与 CityHash128";
final long[] hash = HashUtil.cityHash128(ByteUtil.toUtf8Bytes(s));
final long[] hash = HashUtil.cityHash128(ByteUtil.toUtf8Bytes(s)).getLongArray(ByteOrder.BIG_ENDIAN);
Assertions.assertEquals(0x5944f1e788a18db0L, hash[0]);
Assertions.assertEquals(0xc2f68d8b2bf4a5cfL, hash[1]);
}