summaryrefslogtreecommitdiff
path: root/main/src/test/java/de/blinkt
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2016-07-24 12:45:17 +0200
committerArne Schwabe <arne@rfc2549.org>2016-07-24 12:45:17 +0200
commit438c6a1dc2fa3b32ebf49faf44e645efc7e2da2d (patch)
treef97c5d4b73b44c3c608c4c8a43c9eb986f971cf7 /main/src/test/java/de/blinkt
parente29345de1904bbfcf884e58326f122518bc6669b (diff)
Fix ipv6 address with two zero ranges.
Diffstat (limited to 'main/src/test/java/de/blinkt')
-rw-r--r--main/src/test/java/de/blinkt/openvpn/core/TestIpParser.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/main/src/test/java/de/blinkt/openvpn/core/TestIpParser.java b/main/src/test/java/de/blinkt/openvpn/core/TestIpParser.java
new file mode 100644
index 00000000..37f9fdcd
--- /dev/null
+++ b/main/src/test/java/de/blinkt/openvpn/core/TestIpParser.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2012-2016 Arne Schwabe
+ * Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt
+ */
+
+package de.blinkt.openvpn.core;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * Created by arne on 23.07.16.
+ */
+
+public class TestIpParser {
+
+ @Test
+ public void parseIPv6Zeros() throws UnknownHostException {
+
+ testAddress("2020:0:1234::", 45, "2020:0:1234::/45");
+ testAddress("::", 0, "::/0");
+ testAddress("2a02:2e0:3fe:1001:302::", 128, "2a02:2e0:3fe:1001:302::/128");
+ testAddress("2a02:2e0:3fe:1001:302::70", 128, "2a02:2e0:3fe:1001:302:0:0:70/128");
+ }
+
+ void testAddress(String input, int mask, String output) throws UnknownHostException {
+ Inet6Address ip = (Inet6Address) InetAddress.getByName(input);
+
+ NetworkSpace.ipAddress netIp = new NetworkSpace.ipAddress(ip, mask, true);
+
+ Assert.assertEquals(output, netIp.toString());
+ }
+}