-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ IdGenerator can have random overridden
- Loading branch information
1 parent
83a1e0e
commit 18933ec
Showing
2 changed files
with
39 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.andrewohara.utils | ||
|
||
import io.kotest.matchers.shouldBe | ||
import io.kotest.matchers.string.shouldHaveLength | ||
import org.junit.jupiter.api.Test | ||
import java.util.Random | ||
|
||
class IdGeneratorTest { | ||
|
||
private val testObj = IdGenerator(Random(1337)) | ||
|
||
@Test | ||
fun `next hex`() { | ||
testObj.nextHex(8) shouldBe "19E79D84" | ||
} | ||
|
||
@Test | ||
fun `next base36`() { | ||
testObj.nextBase36(8) shouldBe "QETRJ88E" | ||
} | ||
|
||
@Test | ||
fun `next numeric`() { | ||
testObj.nextNumeric(8) shouldBe 10546784.toBigInteger() | ||
} | ||
|
||
@Test | ||
fun `companion object`() { | ||
IdGenerator.nextHex(4).shouldHaveLength(4) | ||
IdGenerator.nextNumeric(4).toString().shouldHaveLength(4) | ||
IdGenerator.nextBase36(4).shouldHaveLength(4) | ||
} | ||
} |