diff --git a/test/org/netpreserve/jwarc/InetAddressesTest.java b/test/org/netpreserve/jwarc/InetAddressesTest.java index 17717e7..bbc03de 100644 --- a/test/org/netpreserve/jwarc/InetAddressesTest.java +++ b/test/org/netpreserve/jwarc/InetAddressesTest.java @@ -29,6 +29,13 @@ public void testCanonicalInet6() throws Exception { canonicalInet6((Inet6Address) InetAddress.getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"))); assertEquals("2001:200f::1", canonicalInet6((Inet6Address) InetAddress.getByName("2001:200f:0:0:0:0:0:1"))); + // https://datatracker.ietf.org/doc/html/rfc5952#section-4.2.2 + // "The symbol "::" MUST NOT be used to shorten just one 16-bit 0 field." + assertEquals("2001:0:3:4:5:6:7:8", + canonicalInet6((Inet6Address) InetAddress.getByName("2001:0:3:4:5:6:7:8"))); + // shorten first of same-length consecutive 0 fields, also in initial position + assertEquals("::4:0:0:0:ffff", + canonicalInet6((Inet6Address) InetAddress.getByName("0:0:0:4:0:0:0:ffff"))); } } \ No newline at end of file