mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
NetUtil.bigIntegerToIPv6增加长度修正
This commit is contained in:
@@ -3,15 +3,18 @@ package cn.hutool.core.net;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.lang.PatternPool;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.net.HttpCookie;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* NetUtil单元测试
|
||||
*
|
||||
@@ -126,4 +129,11 @@ public class NetUtilTest {
|
||||
final String ip = NetUtil.getMultistageReverseProxyIp(ips);
|
||||
assertEquals("12.34.56.78", ip);
|
||||
}
|
||||
|
||||
@Test
|
||||
void bigIntegerToIPv6Test() {
|
||||
BigInteger bigInteger = new BigInteger("21987654321098765432109876543210", 10);
|
||||
String ipv6Address = NetUtil.bigIntegerToIPv6(bigInteger);
|
||||
Assertions.assertEquals("0:115:85f1:5eb3:c74d:a870:11c6:7eea", ipv6Address);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user