mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
修正cidr判定问题
This commit is contained in:
@@ -101,4 +101,15 @@ public class NetUtilTest {
|
||||
Console.log(txt);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isInRangeTest(){
|
||||
Assert.assertTrue(NetUtil.isInRange("114.114.114.114","0.0.0.0/0"));
|
||||
Assert.assertTrue(NetUtil.isInRange("192.168.3.4","192.0.0.0/8"));
|
||||
Assert.assertTrue(NetUtil.isInRange("192.168.3.4","192.168.0.0/16"));
|
||||
Assert.assertTrue(NetUtil.isInRange("192.168.3.4","192.168.3.0/24"));
|
||||
Assert.assertTrue(NetUtil.isInRange("192.168.3.4","192.168.3.4/32"));
|
||||
Assert.assertFalse(NetUtil.isInRange("8.8.8.8","192.0.0.0/8"));
|
||||
Assert.assertFalse(NetUtil.isInRange("114.114.114.114","192.168.3.4/32"));
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user