mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
Ipv4Util 新增方法:检测指定 IP 地址是否匹配通配符 pattern
This commit is contained in:
@@ -107,6 +107,15 @@ public class Ipv4UtilTest {
|
||||
Assert.assertFalse("掩码位非法检验", maskBitValid);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchesTest() {
|
||||
boolean matches1 = Ipv4Util.matches("127.*.*.1", "127.0.0.1");
|
||||
Assert.assertTrue("IP地址通配符匹配1", matches1);
|
||||
|
||||
boolean matches2 = Ipv4Util.matches("192.168.*.1", "127.0.0.1");
|
||||
Assert.assertFalse("IP地址通配符匹配2", matches2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ipv4ToLongTest(){
|
||||
long l = Ipv4Util.ipv4ToLong("127.0.0.1");
|
||||
|
Reference in New Issue
Block a user