11package sc.plugin2023
22
3- import io.kotest.assertions.throwables.shouldThrow
43import io.kotest.core.spec.style.FunSpec
54import io.kotest.inspectors.forAll
6- import io.kotest.matchers.booleans.shouldBeFalse
5+ import io.kotest.matchers.*
76import io.kotest.matchers.collections.*
87import io.kotest.matchers.ints.*
9- import io.kotest.matchers.maps.shouldBeEmpty
108import io.kotest.matchers.maps.shouldHaveSize
119import io.kotest.matchers.nulls.*
12- import io.kotest.matchers.shouldBe
1310import io.kotest.matchers.string.*
11+ import sc.api.plugins.Coordinates
1412import sc.api.plugins.Team
1513import sc.helpers.shouldSerializeTo
1614import sc.helpers.testXStream
17- import sc.plugin2023.Move
18- import sc.api.plugins.Coordinates
19- import sc.api.plugins.TwoDBoard
20- import sc.framework.plugins.Constants
21- import sc.helpers.checkSerialization
2215import sc.plugin2023.util.PluginConstants
23- import sc.shared.MoveMistake
24- import sc.shared.InvalidMoveException
2516
2617class BoardTest : FunSpec ({
2718 context("Board generation") {
@@ -32,9 +23,19 @@ class BoardTest: FunSpec({
3223 it.penguin.shouldBeNull()
3324 it.fish shouldBeInRange 1 ..4
3425 }
26+
3527 generatedBoard.getPenguins() shouldHaveSize 0
36- generatedBoard[0 y 0 ] = Team .ONE
28+ generatedBoard[1 y 1 ] = Team .ONE
3729 generatedBoard.getPenguins() shouldHaveSize 1
30+
31+ arrayOf(-1 y 1, -2 y 0, -1 y 3, -1 y 0).forAll {
32+ generatedBoard.getOrNull(it).shouldBeNull()
33+ }
34+ (0 until PluginConstants .BOARD_SIZE ).map { (it * 2) y 2 }.forAll {
35+ val field = generatedBoard[it]
36+ field.fish shouldBeInRange 1 ..4
37+ generatedBoard[it.x, it.y] shouldBe field
38+ }
3839 }
3940 test("clones well") {
4041 val board = makeBoard(0 y 0 to 1)
@@ -58,6 +59,7 @@ class BoardTest: FunSpec({
5859 }
5960 }
6061 context("Board calculates diffs") {
62+ // TODO
6163 // val board = makeBoard(0 y 0 to "r", 2 y 0 to "r")
6264 // test("empty for itself") {
6365 // board.diff(board).shouldBeEmpty()
@@ -99,6 +101,6 @@ class BoardTest: FunSpec({
99101infix fun Int.y (other : Int ) = Coordinates (this , other)
100102
101103fun makeBoard (vararg list : Pair <Coordinates , Int >) =
102- Board (List (PluginConstants .BOARD_SIZE ) { MutableList (PluginConstants .BOARD_SIZE ) { Field (1 ) } }).apply {
103- list.forEach { set(it.first, Team .values().getOrNull(it.second)) }
104- }
104+ Board (List (PluginConstants .BOARD_SIZE ) { MutableList (PluginConstants .BOARD_SIZE ) { Field (1 ) } }).apply {
105+ list.forEach { set(it.first, Team .values().getOrNull(it.second)) }
106+ }
0 commit comments