assertTrue(UTIL.splitIpv6Prefix(new IpClass("::/32")).getValue().equals(32));
assertArrayEquals(new byte[] { 0, 10, 0, 0, 0, 0, 0, 0, 0, 11, 0, 12, 0, 13, 0, 14, 64 },
UTIL.ipv6PrefixToBytes(new IpClass("A::B:C:D:E/64")));
+
+ // verify that an IPv4-mapped IPv6 address gets parsed as an IPv6 address
+ assertEquals("::ffff:ab0:eb", UTIL.ipv6AddressFor(
+ new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte) 0xff, (byte) 0xff, 0x0a, (byte) 0xb0, 0, (byte) 0xeb})
+ .getValue());
}
@Test
}).when(ipClass).getValue();
UTIL.inet6AddressFor(ipClass);
}
-}
\ No newline at end of file
+
+ @Test
+ public void testIpv4AddressForBits() {
+ assertEquals("1.2.3.4", UTIL.ipv4AddressFor(0x01020304).getValue());
+ assertEquals("255.255.255.255", UTIL.ipv4AddressFor(0xFFFFFFFF).getValue());
+ }
+
+ @Test
+ public void testIpv4AddressNoZoneForBits() {
+ assertEquals("1.2.3.4", UTIL.ipv4AddressNoZoneFor(0x01020304).getValue());
+ assertEquals("255.255.255.255", UTIL.ipv4AddressNoZoneFor(0xFFFFFFFF).getValue());
+ }
+
+ @Test
+ public void testIpv4AddressBits() {
+ assertEquals(0x01020304, UTIL.ipv4AddressBits(new IpClass("1.2.3.4")));
+ assertEquals(0xFFFFFFFF, UTIL.ipv4AddressBits(new IpClass("255.255.255.255")));
+ }
+
+ @Test
+ public void testIpv4AddressNoZoneBits() {
+ assertEquals(0x01020304, UTIL.ipv4AddressNoZoneBits(new IpClass("1.2.3.4")));
+ assertEquals(0xFFFFFFFF, UTIL.ipv4AddressNoZoneBits(new IpClass("255.255.255.255")));
+ }
+}