This commit is contained in:
Looly
2024-03-18 16:09:48 +08:00
parent 0567a98e08
commit a34cb71bc0
8 changed files with 27 additions and 28 deletions

View File

@@ -15,6 +15,7 @@ package org.dromara.hutool.core.codec.hash.metro;
import org.dromara.hutool.core.codec.binary.HexUtil;
import org.dromara.hutool.core.codec.Number128;
import org.dromara.hutool.core.util.ByteUtil;
import org.dromara.hutool.core.util.CharsetUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -130,4 +131,12 @@ public class MetroHash128Test {
private static String hex(final byte[] bytes){
return HexUtil.encodeStr(bytes).toUpperCase();
}
@Test
public void metroHash128GetLongArrayTest() {
final byte[] str = "我是一段测试123".getBytes(CharsetUtil.UTF_8);
final long[] hash128 = MetroHash128.of(0).hash128(str).getLongArray();
Assertions.assertEquals(228255164667538345L, hash128[0]);
Assertions.assertEquals(-6394585948993412256L, hash128[1]);
}
}

View File

@@ -49,14 +49,6 @@ public class MetroHashTest {
Assertions.assertEquals(147395857347476456L, hash64);
}
@Test
public void metroHash128Test() {
final byte[] str = "我是一段测试123".getBytes(CharsetUtil.UTF_8);
final long[] hash128 = MetroHash128.of(0).hash128(str).getLongArray();
Assertions.assertEquals(228255164667538345L, hash128[0]);
Assertions.assertEquals(-6394585948993412256L, hash128[1]);
}
/**
* 数据量越大 MetroHash 优势越明显,
*/