mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cn.hutool.core.codec.hash.metro;
|
||||
|
||||
import cn.hutool.core.codec.HexUtil;
|
||||
import cn.hutool.core.codec.Number128;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@@ -106,7 +107,8 @@ public class MetroHash128Test {
|
||||
|
||||
static String h128(final String input) {
|
||||
final MetroHash128 mh = MetroHash128.of(0).apply(ByteBuffer.wrap(StrUtil.utf8Bytes(input)));
|
||||
return hex(mh.getHigh()) + hex(mh.getLow());
|
||||
final Number128 hash = mh.get();
|
||||
return hex(hash.getHighValue()) + hex(hash.getLowValue());
|
||||
}
|
||||
|
||||
private static String hex(final long value){
|
||||
|
@@ -82,13 +82,13 @@ public class NumberUtilTest {
|
||||
|
||||
@Test
|
||||
public void isIntegerTest() {
|
||||
String[] validNumArr = {"0", "-0", "+0", "12", "+12", "1234567890", "2147483647", "-2147483648",
|
||||
final String[] validNumArr = {"0", "-0", "+0", "12", "+12", "1234567890", "2147483647", "-2147483648",
|
||||
"0x012345678", "0X012345678", "0xabcdef", "-0xabcdef", "0x12abcdef", "0x7FFFFFFF", "-0x80000000",
|
||||
"01234567", "017777777777", "-020000000000"
|
||||
};
|
||||
privateIsIntegerTest(validNumArr, true);
|
||||
|
||||
String[] invalidNumArr = {null, "", " ", "+", "+1.", ".1", "99L", "99D", "99F", "12.3", "123e1", "-12.3", "1.2.3",
|
||||
final String[] invalidNumArr = {null, "", " ", "+", "+1.", ".1", "99L", "99D", "99F", "12.3", "123e1", "-12.3", "1.2.3",
|
||||
"2147483648", "0x80000000", "020000000000", "-2147483649", "-0x80000001", "-020000000001", "-020000000001",
|
||||
"a", "+a", "123abc", "09"
|
||||
};
|
||||
@@ -96,14 +96,14 @@ public class NumberUtilTest {
|
||||
}
|
||||
|
||||
private void privateIsIntegerTest(final String[] numStrArr, final boolean expected) {
|
||||
for (String numStr : numStrArr) {
|
||||
for (final String numStr : numStrArr) {
|
||||
Assert.assertEquals("未通过的数字为: " + numStr, expected, NumberUtil.isInteger(numStr));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isLongTest() {
|
||||
String[] validNumArr = {
|
||||
final String[] validNumArr = {
|
||||
"0", "0L", "-0L", "+0L", "12", "+12", "1234567890123456789", "99L",
|
||||
"2147483648", "0x80000000", "020000000000", "-2147483649", "-0x80000001", "-020000000001", "-020000000001",
|
||||
"9223372036854775807", "-9223372036854775808",
|
||||
@@ -113,7 +113,7 @@ public class NumberUtilTest {
|
||||
};
|
||||
privateIsLongTest(validNumArr, true);
|
||||
|
||||
String[] invalidNumArr = {null, "", " ", "+", "+1.", ".1", "99D", "99F", "12.3", "123e1", "-12.3", "1.2.3",
|
||||
final String[] invalidNumArr = {null, "", " ", "+", "+1.", ".1", "99D", "99F", "12.3", "123e1", "-12.3", "1.2.3",
|
||||
"a", "+a", "123abc", "09",
|
||||
"9223372036854775808", "-9223372036854775809",
|
||||
"0x8000000000000000", "-0x8000000000000001",
|
||||
@@ -123,7 +123,7 @@ public class NumberUtilTest {
|
||||
}
|
||||
|
||||
private void privateIsLongTest(final String[] numStrArr, final boolean expected) {
|
||||
for (String numStr : numStrArr) {
|
||||
for (final String numStr : numStrArr) {
|
||||
Assert.assertEquals("未通过的数字为: " + numStr, expected, NumberUtil.isLong(numStr));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user