### Question:
IPv6 implements Comparable<IPv6> { public static String expand(String ipStr, int nwords) throws IPStringConversionException { StringBuilder sb = new StringBuilder(); String hex; int[] vals; int[] expanded_vals; int i; vals = splitvals(ipStr); if (vals == null) { throw new IPStringConversionException("Error converting hex to binary in IPv6 ip"); } expanded_vals = expand(vals, nwords); for (i = 0; i < nwords - 1; i++) { hex = String.format("%s:", BitConverters.int16bit2hex(expanded_vals[i])); sb.append(hex); } hex = String.format("%s", BitConverters.int16bit2hex(expanded_vals[nwords - 1])); sb.append(hex); return sb.toString(); } IPv6(BigInteger in);  IPv6();  IPv6(String ip);  IPv6(byte[] in); static String expand(String ipStr, int nwords); String expand(); BigInteger toBigInteger(); static IPv6 bigInteger2IPv6(BigInteger in); static byte[] IpString2bytes(String ipStr); static String bytes2IpString(byte[] in); void setIp(byte[] in); String getString(); byte[] getBytes(); void setIp(String ip); void insertInteger(int in, int startBit); void insertBigInteger(BigInteger in, int startBit, int size); void setAccountPartition(int accountId); void setVipOctets(int lo); int getVipOctets(); void setClusterPartition(IPv6Cidr clusterCidr); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); @Override int compareTo(IPv6 that);  }### Answer:
@Test(expected = IPStringConversionException.class) public void testNotEnoughintVals() throws IPStringConversionException { IPv6.expand(":", 8); }
@Test(expected = IPStringConversionException.class) public void testRejectMultipleZeroCompress() throws IPStringConversionException { IPv6.expand("1234::5678::FFFF", 8); }
@Test(expected = IPStringConversionException.class) public void testRejectInvalidHex() throws IPStringConversionException { IPv6.expand("1234:x:23::", 8); }
@Test(expected = IPStringConversionException.class) public void testRejectHexNot16bit() throws IPStringConversionException { IPv6.expand("fffff::", 8); }
@Test public void testExpand() throws IPStringConversionException { IPv6 ip = new IPv6(ipv4Mixed_compressed); String expanded_str = ip.expand(); assertNotNull("Expected non null expanded ip string", expanded_str); assertTrue("Expected uncompressed ip to match ip.expand()", expanded_str.equals(ipv4Mixed_uncompressed)); }