-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ipv4 addr generation to Internet
- Loading branch information
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
core/src/test/kotlin/io/github/serpro69/kfaker/provider/InternetTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.github.serpro69.kfaker.provider | ||
|
||
import io.github.serpro69.kfaker.Faker | ||
import io.github.serpro69.kfaker.FakerService | ||
import io.github.serpro69.kfaker.helper.isPrivateNet | ||
import io.github.serpro69.kfaker.helper.isReservedNet | ||
import io.kotest.core.spec.style.DescribeSpec | ||
import io.kotest.matchers.shouldBe | ||
|
||
class InternetTest: DescribeSpec({ | ||
describe("Internet provider") { | ||
val internet = Internet(FakerService(faker = Faker())) | ||
|
||
context("IPv4 address generation") { | ||
repeat(100) { | ||
it("should generate private IPv4 address run#$it") { | ||
isPrivateNet(internet.privateIPv4Address()) shouldBe true | ||
isReservedNet(internet.privateIPv4Address()) shouldBe true | ||
} | ||
it("should generate a public IPv4 address run#$it") { | ||
isPrivateNet(internet.publicIPv4Address()) shouldBe false | ||
isReservedNet(internet.publicIPv4Address()) shouldBe false | ||
} | ||
it("should generate a random IPv4 address run#$it") { | ||
internet.iPv4Address().split(".").all { s -> s.toInt() in 0..255 } shouldBe true | ||
} | ||
} | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters