* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
+
package org.opendaylight.mdsal.model.ietf.util;
import static com.google.common.net.InetAddresses.forString;
import static org.junit.Assert.assertArrayEquals;
-import static org.opendaylight.mdsal.model.ietf.util.Ipv6Utils.bytesForString;
+import static org.opendaylight.mdsal.model.ietf.util.Ipv6Utils.fillIpv6Bytes;
+
import org.junit.Test;
public class Ipv6UtilsTest {
+
@Test
public void testDiscards() {
assertEqualResult("2001:0000:3238:DFE1:63:0000:0000:FEFB");
assertEqualResult("::");
}
- /**
- * @author Anton Ivanov aivanov@brocade.com
- */
@Test
public void testFullQuads() {
assertEqualResult("0000:0000:0000:0000:0000:0000:0000:0001");
}
- @Test
- public void testZoneIndex() {
- assertArrayEquals(forString("::1").getAddress(), bytesForString("::1%2"));
- }
-
@Test
public void testRfc4291() {
assertEqualResult("ABCD:EF01:2345:6789:ABCD:EF01:2345:6789");
assertArrayEquals(test1, bytesForString("0:0:0:0:0:0:13.1.68.3"));
assertArrayEquals(test1, bytesForString("::13.1.68.3"));
- final byte[] test2 = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte)255, (byte)255,
- (byte)129, (byte)144, 52, 38 };
+ final byte[] test2 = new byte[] {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte)255, (byte)255, (byte)129, (byte)144, 52, 38
+ };
assertArrayEquals(test2, bytesForString("0:0:0:0:0:FFFF:129.144.52.38"));
assertArrayEquals(test2, bytesForString("::FFFF:129.144.52.38"));
}
assertEqualResult("64:ff9b::192.0.2.33");
}
+ private static byte[] bytesForString(final String str) {
+ final byte[] bytes = new byte[16];
+ fillIpv6Bytes(bytes, str, str.length());
+ return bytes;
+ }
+
// Utility for quick comparison with Guava
private static void assertEqualResult(final String str) {
assertArrayEquals(forString(str).getAddress(), bytesForString(str));