bump versions
- kotlinx js wrappers - kotest also fix kotest dependencies
This commit is contained in:
parent
93444bfe39
commit
ffe9bcb9a8
4 changed files with 228 additions and 5 deletions
|
|
@ -0,0 +1,98 @@
|
|||
package dev.adamko.kafkatorio.schema.common
|
||||
|
||||
import io.kotest.assertions.asClue
|
||||
import io.kotest.core.spec.style.FunSpec
|
||||
import io.kotest.matchers.ints.shouldBeExactly
|
||||
|
||||
class MapChunkPositionBoundsTest : FunSpec({
|
||||
|
||||
context("create bounds") {
|
||||
|
||||
context("MapChunkPosition(0, 0)") {
|
||||
|
||||
context("chunk size 32") {
|
||||
|
||||
val chunkPos = MapChunkPosition(0, 0)
|
||||
val bounds = MapChunkPositionBounds(chunkPos, ChunkSize.CHUNK_032)
|
||||
|
||||
test("leftTop should be 0,0") {
|
||||
bounds.leftTop.asClue {
|
||||
it.x shouldBeExactly 0
|
||||
it.y shouldBeExactly 0
|
||||
}
|
||||
}
|
||||
|
||||
test("rightBottom should be 31,31") {
|
||||
bounds.rightBottom.asClue {
|
||||
it.x shouldBeExactly 31
|
||||
it.y shouldBeExactly 31
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context("chunk size 256") {
|
||||
|
||||
val chunkPos = MapChunkPosition(0, 0)
|
||||
val bounds = MapChunkPositionBounds(chunkPos, ChunkSize.CHUNK_256)
|
||||
|
||||
test("leftTop should be 0,0") {
|
||||
bounds.leftTop.asClue {
|
||||
it.x shouldBeExactly 0
|
||||
it.y shouldBeExactly 0
|
||||
}
|
||||
}
|
||||
|
||||
test("rightBottom should be 255,255") {
|
||||
bounds.rightBottom.asClue {
|
||||
it.x shouldBeExactly 255
|
||||
it.y shouldBeExactly 255
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context("MapChunkPosition(-10, -10)") {
|
||||
|
||||
context("chunk size 32") {
|
||||
|
||||
val chunkPos = MapChunkPosition(-10, -10)
|
||||
val bounds = MapChunkPositionBounds(chunkPos, ChunkSize.CHUNK_032)
|
||||
|
||||
test("leftTop should be -320,-320") {
|
||||
bounds.leftTop.asClue {
|
||||
it.x shouldBeExactly -320
|
||||
it.y shouldBeExactly -320
|
||||
}
|
||||
}
|
||||
|
||||
test("rightBottom should be -289,-289") {
|
||||
bounds.rightBottom.asClue {
|
||||
it.x shouldBeExactly -289
|
||||
it.y shouldBeExactly -289
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context("chunk size 256") {
|
||||
|
||||
val chunkPos = MapChunkPosition(-10, -10)
|
||||
val bounds = MapChunkPositionBounds(chunkPos, ChunkSize.CHUNK_256)
|
||||
|
||||
test("leftTop should be -2560") {
|
||||
bounds.leftTop.asClue {
|
||||
it.x shouldBeExactly -2560
|
||||
it.y shouldBeExactly -2560
|
||||
}
|
||||
}
|
||||
|
||||
test("rightBottom should be (-2560 + 255)") {
|
||||
bounds.rightBottom.asClue {
|
||||
it.x shouldBeExactly (-2560 + 255)
|
||||
it.y shouldBeExactly (-2560 + 255)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
package dev.adamko.kafkatorio.schema.common
|
||||
|
||||
import io.kotest.core.spec.style.FunSpec
|
||||
import io.kotest.datatest.withData
|
||||
import io.kotest.matchers.shouldBe
|
||||
import io.kotest.property.Arb
|
||||
import io.kotest.property.arbitrary.arbitrary
|
||||
import io.kotest.property.arbitrary.int
|
||||
import io.kotest.property.checkAll
|
||||
|
||||
class MapChunkPositionTest : FunSpec({
|
||||
|
||||
context("check MapChunkPosition.contains()") {
|
||||
|
||||
context("MapChunkPosition(0, 0)") {
|
||||
|
||||
val chunkPos = MapChunkPosition(0, 0)
|
||||
|
||||
test("should contain tiles from (0,0) to (31,31)") {
|
||||
checkAll(mapTilePositionArb(0..31)) { tilePos ->
|
||||
(tilePos in chunkPos) shouldBe true
|
||||
}
|
||||
}
|
||||
|
||||
test("should not contain tiles below (0,0)") {
|
||||
checkAll(
|
||||
mapTilePositionArb(-1000..-1)
|
||||
) { tilePos ->
|
||||
(tilePos in chunkPos) shouldBe false
|
||||
}
|
||||
}
|
||||
|
||||
test("should not contain tiles above (31,31)") {
|
||||
checkAll(
|
||||
mapTilePositionArb(32..100)
|
||||
) { tilePos ->
|
||||
(tilePos in chunkPos) shouldBe false
|
||||
}
|
||||
}
|
||||
}
|
||||
context("MapChunkPosition(-10, -10)") {
|
||||
|
||||
val chunkPos = MapChunkPosition(-10, -10)
|
||||
|
||||
test("should contain tiles from (-320,-320) to (-289,-289)") {
|
||||
checkAll(mapTilePositionArb(-320..-289)) { tilePos ->
|
||||
(tilePos in chunkPos) shouldBe true
|
||||
}
|
||||
}
|
||||
|
||||
test("should not contain tiles below (-320,-320)") {
|
||||
checkAll(
|
||||
mapTilePositionArb(-400..-321)
|
||||
) { tilePos ->
|
||||
(tilePos in chunkPos) shouldBe false
|
||||
}
|
||||
}
|
||||
|
||||
test("should not contain tiles above (-289,-289)") {
|
||||
checkAll(
|
||||
mapTilePositionArb(-288..100)
|
||||
) { tilePos ->
|
||||
(tilePos in chunkPos) shouldBe false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}) {
|
||||
companion object {
|
||||
fun mapTilePositionArb(
|
||||
range: IntRange = -1000..1000
|
||||
) = arbitrary {
|
||||
MapTilePosition(
|
||||
Arb.int(range).bind(),
|
||||
Arb.int(range).bind(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package dev.adamko.kafkatorio.schema.common
|
||||
|
||||
import dev.adamko.kafkatorio.schema.common.MapChunkPositionTest.Companion.mapTilePositionArb
|
||||
import io.kotest.core.spec.style.FunSpec
|
||||
import io.kotest.property.forAll
|
||||
|
||||
class MapTilePositionTest : FunSpec({
|
||||
|
||||
context("comparison") {
|
||||
|
||||
test("less than <") {
|
||||
forAll(
|
||||
mapTilePositionArb(),
|
||||
mapTilePositionArb(1..100),
|
||||
) { tilePos, delta ->
|
||||
tilePos < (tilePos + delta)
|
||||
}
|
||||
}
|
||||
|
||||
test("less than or equal to <=") {
|
||||
forAll(mapTilePositionArb()) { tilePos ->
|
||||
tilePos <= (tilePos)
|
||||
}
|
||||
}
|
||||
|
||||
test("greater than or equal to >=") {
|
||||
forAll(mapTilePositionArb()) { tilePos ->
|
||||
tilePos >= (tilePos)
|
||||
}
|
||||
}
|
||||
|
||||
test("greater than >") {
|
||||
forAll(
|
||||
mapTilePositionArb(),
|
||||
mapTilePositionArb(1..100),
|
||||
) { tilePos, delta ->
|
||||
tilePos > (tilePos - delta)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue