!943 修复MaskBIt中根据掩码位获取long值的bug

Merge pull request !943 from emptypoint/fix-MaskBit
This commit is contained in:
Looly
2023-02-20 07:37:45 +00:00
committed by Gitee
2 changed files with 10 additions and 2 deletions

View File

@@ -121,7 +121,7 @@ public class Ipv4UtilTest {
}
@Test
public void ipv4ToLongTest(){
public void ipv4ToLongTest() {
long l = Ipv4Util.ipv4ToLong("127.0.0.1");
Assert.assertEquals(2130706433L, l);
l = Ipv4Util.ipv4ToLong("114.114.114.114");
@@ -132,6 +132,13 @@ public class Ipv4UtilTest {
Assert.assertEquals(4294967295L, l);
}
@Test
public void getMaskIpLongTest() {
for (int i = 1; i <= 32; i++) {
Assert.assertEquals(Ipv4Util.ipv4ToLong(MaskBit.get(i)), MaskBit.getMaskIpLong(i));
}
}
@SuppressWarnings("SameParameterValue")
private void testGenerateIpList(final String fromIp, final String toIp) {
Assert.assertEquals(