コード例 #1
0
 @Test
 public void shouldReturnFalseForInvalidPrefix() {
   assertFalse(PrefixUtils.isLegalPrefix(Ipv6Range.parse("::0-::2")));
   assertFalse(PrefixUtils.isLegalPrefix(Ipv6Range.parse("::1-::3")));
   assertFalse(
       PrefixUtils.isLegalPrefix(Ipv6Range.parse("::1-ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")));
   assertFalse(
       PrefixUtils.isLegalPrefix(Ipv6Range.parse("::-ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe")));
   assertFalse(
       PrefixUtils.isLegalPrefix(Ipv6Range.parse("::2-ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe")));
 }
コード例 #2
0
 @Test(expected = IllegalArgumentException.class)
 public void shouldFailToGetPrefixLengthWhenInvalidPrefix() {
   PrefixUtils.getPrefixLength(Ipv6Range.parse("::0-::2"));
 }
コード例 #3
0
 @Test
 public void shouldGetPrefixLengthWhenCorrectPrefix() {
   assertEquals(128, PrefixUtils.getPrefixLength(Ipv6Range.parse("::0-::0")));
   assertEquals(128, PrefixUtils.getPrefixLength(Ipv6Range.parse("::1-::1")));
   assertEquals(126, PrefixUtils.getPrefixLength(Ipv6Range.parse("::0-::3")));
 }
コード例 #4
0
 @Test
 public void shouldReturnTrueForValidPrefix() {
   assertTrue(PrefixUtils.isLegalPrefix(Ipv6Range.parse("::/0")));
 }