mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
!661 添加一个带默认值的 Ipv4Util.ipv4ToLong 方法
Merge pull request !661 from churen/v5-dev
This commit is contained in:
@@ -86,4 +86,17 @@ public class Ipv4UtilTest {
|
||||
l = Ipv4Util.ipv4ToLong("255.255.255.255");
|
||||
Assert.assertEquals(4294967295L, l);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ipv4ToLongWithDefaultTest() {
|
||||
String strIP = "不正确的 IP 地址";
|
||||
long defaultValue = 0L;
|
||||
long ipOfLong = Ipv4Util.ipv4ToLong(strIP, defaultValue);
|
||||
Assert.assertEquals(ipOfLong, defaultValue);
|
||||
|
||||
String strIP2 = "255.255.255.255";
|
||||
long defaultValue2 = 0L;
|
||||
long ipOfLong2 = Ipv4Util.ipv4ToLong(strIP2, defaultValue2);
|
||||
Assert.assertEquals(ipOfLong2, 4294967295L);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user