@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"))); }
@Test(expected = IllegalArgumentException.class) public void shouldFailToGetPrefixLengthWhenInvalidPrefix() { PrefixUtils.getPrefixLength(Ipv6Range.parse("::0-::2")); }
@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"))); }
@Test public void shouldReturnTrueForValidPrefix() { assertTrue(PrefixUtils.isLegalPrefix(Ipv6Range.parse("::/0"))); }