diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2021-01-06 09:12:56 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2021-01-06 09:12:56 +0100 |
commit | bd2208922ea6a0486074c72a57b01d7df368f885 (patch) | |
tree | 1fca7e8f5c013f0ea9e99a942c47213842f96d50 /src/test/java/io/trygvis/rules/acme | |
parent | 9e353ef7af8164d33544a890e60d2049de7d61cb (diff) | |
download | rules-sandbox-bd2208922ea6a0486074c72a57b01d7df368f885.tar.gz rules-sandbox-bd2208922ea6a0486074c72a57b01d7df368f885.tar.bz2 rules-sandbox-bd2208922ea6a0486074c72a57b01d7df368f885.tar.xz rules-sandbox-bd2208922ea6a0486074c72a57b01d7df368f885.zip |
Generating IP addresses.
Diffstat (limited to 'src/test/java/io/trygvis/rules/acme')
-rw-r--r-- | src/test/java/io/trygvis/rules/acme/IpCalcTest.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/java/io/trygvis/rules/acme/IpCalcTest.java b/src/test/java/io/trygvis/rules/acme/IpCalcTest.java new file mode 100644 index 0000000..8b1e2c6 --- /dev/null +++ b/src/test/java/io/trygvis/rules/acme/IpCalcTest.java @@ -0,0 +1,27 @@ +package io.trygvis.rules.acme; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import static org.junit.jupiter.api.Assertions.*; + +class IpCalcTest { + + @Test + public void basic() { + Assertions.assertThrows(IllegalArgumentException.class, () -> IpCalc.cidr("192.168.1.1/24").addresses()); + assertEquals(256, IpCalc.cidr("192.168.1.0/24").addresses().size()); + assertEquals(128, IpCalc.cidr("192.168.1.128/25").addresses().size()); + } + + @ParameterizedTest + @ValueSource(strings = { + "192.168.1.0/24", + "192.168.1.128/25", + }) + public void testParsing(String s) { + assertEquals(s, IpCalc.cidr(s).toString()); + } +} |