diff options
author | Edoardo La Greca | 2025-08-18 21:09:11 +0200 |
---|---|---|
committer | Edoardo La Greca | 2025-08-18 21:09:11 +0200 |
commit | 7341ead2aade10ea1b833e94275277658741883a (patch) | |
tree | 46495f24c54278d50aa0da5046822fbe502f3f14 /lib/src/test | |
parent | 1e50cf9c224d03896f176f3718ff80ef1659e9c2 (diff) |
switch to multi-module project structure
Diffstat (limited to 'lib/src/test')
-rw-r--r-- | lib/src/test/kotlin/IPAddressTest.kt | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/src/test/kotlin/IPAddressTest.kt b/lib/src/test/kotlin/IPAddressTest.kt new file mode 100644 index 0000000..b213d71 --- /dev/null +++ b/lib/src/test/kotlin/IPAddressTest.kt @@ -0,0 +1,38 @@ +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.function.Executable + +private class IPAddressConstructor(private val address: String) : Executable { + override fun execute() { + IPAddress(this.address) + } +} + +class IPAddressTest { + @Test + fun testAddressVersion4() { + val testAddressesCorrect = listOf( + "10.255.0.1", + "0011:2233:4455:6677:8899:aabb:ccdd:eeff", + "aabb::", + ) + + val testAddressesWrong = listOf( + "999.888.777.666", + "ghil:mnop:qrst:uvwx:yz99:8877:6655:4433", + "aaabbb::", + "aa::", + "gg::", + + ) + + // assert correct + assertAll(testAddressesCorrect.map { IPAddressConstructor(it) }) + + // assert wrong + for (address in testAddressesWrong) { + assertThrowsExactly<NumberFormatException>(NumberFormatException().javaClass, IPAddressConstructor(address)) + } + } + +}
\ No newline at end of file |