@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
  public void shouldFindBiggestAndSmallestPrefixWhenRangeIsNotValidPrefix() {
    Ipv6Range range = Ipv6Range.from("::1").to("::4");
    assertEquals(Ipv6Range.parse("::2/127"), findMaximumPrefixForPrefixLength(range, 127).get());
    assertEquals(Ipv6Range.parse("::2/127"), findMinimumPrefixForPrefixLength(range, 127).get());
    assertEquals(Ipv6Range.parse("::2/127"), findMaximumPrefixForPrefixLength(range, 128).get());
    assertEquals(Ipv6Range.parse("::1/128"), findMinimumPrefixForPrefixLength(range, 128).get());

    Ipv6Range otherRange =
        Ipv6Range.from("::").to(BigInteger.valueOf(2).pow(128).subtract(BigInteger.valueOf(2)));
    assertEquals(Ipv6Range.parse("::/1"), findMaximumPrefixForPrefixLength(otherRange, 1).get());
    assertEquals(Ipv6Range.parse("::/1"), findMinimumPrefixForPrefixLength(otherRange, 1).get());
    assertEquals(Ipv6Range.parse("::/1"), findMaximumPrefixForPrefixLength(otherRange, 2).get());
    assertEquals(
        Ipv6Range.parse("8000::/2"), findMinimumPrefixForPrefixLength(otherRange, 2).get());
    assertEquals(Ipv6Range.parse("::/1"), findMaximumPrefixForPrefixLength(otherRange, 128).get());
    assertEquals(
        Ipv6Range.parse("ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe/128"),
        findMinimumPrefixForPrefixLength(otherRange, 128).get());
  }
 @Test(expected = IllegalArgumentException.class)
 public void findSmallestPrefixShouldThrowAnExceptionWhenRequestedPrefixLengthIsTooSmall() {
   findMinimumPrefixForPrefixLength(Ipv6Range.parse("::1-::10"), -1);
 }
 @Test
 public void shouldFindBiggestAndSmallestPrefixWhenRangeIsSingleValidPrefix() {
   Ipv6Range range = Ipv6Range.parse("::/0");
   assertEquals(Ipv6Range.parse("::/0"), findMinimumPrefixForPrefixLength(range, 0).get());
   assertEquals(Ipv6Range.parse("::/0"), findMaximumPrefixForPrefixLength(range, 128).get());
 }
 @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")));
 }
 @Test(expected = IllegalArgumentException.class)
 public void findBiggestPrefixShouldThrowAnExceptionWhenRequestedPrefixLengthIsTooBig() {
   findMaximumPrefixForPrefixLength(Ipv6Range.parse("::1-::10"), 129);
 }