diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2021-01-25 21:29:12 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2021-01-25 21:29:12 +0100 |
commit | 912bc8b903dfa6d438c2469ecdad35c181c71830 (patch) | |
tree | 1e6ee9fdcb2b9d488914b80623d68189867533bb /module/ri-base/src/test | |
parent | 92b957036218c03a20ba35c19a70bdf5e2333fd3 (diff) | |
download | rules-sandbox-912bc8b903dfa6d438c2469ecdad35c181c71830.tar.gz rules-sandbox-912bc8b903dfa6d438c2469ecdad35c181c71830.tar.bz2 rules-sandbox-912bc8b903dfa6d438c2469ecdad35c181c71830.tar.xz rules-sandbox-912bc8b903dfa6d438c2469ecdad35c181c71830.zip |
Improving usability, massive refactoring.
* Moving all Drools code into their own modules. This fixes ri-engine
to acme dependency.
* Now they all inherit from their own parent, should be used by
third party code too.
* Separating acme planning code into its own module.
* Splitting rules code from ri-engine into ri-base. ri-engine is now
a pure launcher for modules.
* Dumping kogito for the most part, but it seems like the planner still
requires that.
Diffstat (limited to 'module/ri-base/src/test')
-rw-r--r-- | module/ri-base/src/test/java/io/trygvis/rules/network/Ipv4CidrTest.txt | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/module/ri-base/src/test/java/io/trygvis/rules/network/Ipv4CidrTest.txt b/module/ri-base/src/test/java/io/trygvis/rules/network/Ipv4CidrTest.txt new file mode 100644 index 0000000..826f586 --- /dev/null +++ b/module/ri-base/src/test/java/io/trygvis/rules/network/Ipv4CidrTest.txt @@ -0,0 +1,37 @@ +package io.trygvis.rules.network; + +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 io.trygvis.rules.network.Ipv4Cidr.parseCidr; +import static org.junit.jupiter.api.Assertions.*; + +class Ipv4CidrTest { + + @Test + public void basic() { + Assertions.assertThrows(IllegalArgumentException.class, () -> parseCidr("192.168.1.1/24").addresses()); + assertEquals(256, parseCidr("192.168.1.0/24").addresses().size()); + assertEquals(128, parseCidr("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, parseCidr(s).toString()); + } + + @Test + public void partition() { + var children = parseCidr("192.168.1.0/24").partition(26); + assertEquals(1 << 2, children.size()); + for (var cidr : children) { + assertEquals(26, cidr.bits); + } + } +} |