@@ -9,7 +9,7 @@ import io.kotest.matchers.maps.shouldBeEmpty
9
9
import io.kotest.matchers.maps.shouldHaveSize
10
10
import io.kotest.matchers.shouldBe
11
11
import io.kotest.matchers.string.shouldHaveLineCount
12
- import io.kotest.matchers.string.shouldNotContain
12
+ import io.kotest.matchers.string.shouldMatch
13
13
import sc.api.plugins.Team
14
14
import sc.plugin2022.PieceType.*
15
15
import sc.plugin2022.util.Constants
@@ -22,7 +22,7 @@ class BoardTest: FunSpec({
22
22
test("does not misplace pieces") {
23
23
generatedBoard shouldHaveSize Constants .BOARD_SIZE * 2
24
24
generatedBoard.keys.forAll {
25
- it.y shouldBeOneOf listOf(0, Constants .BOARD_SIZE - 1)
25
+ it.x shouldBeOneOf listOf(0, Constants .BOARD_SIZE - 1)
26
26
}
27
27
generatedBoard.values shouldContainExactlyInAnyOrder values().flatMap { type ->
28
28
Team .values().map { team ->
@@ -33,13 +33,10 @@ class BoardTest: FunSpec({
33
33
test("is stringified apropriately") {
34
34
val string = generatedBoard.toString()
35
35
string shouldHaveLineCount 8
36
+ val lineRegex = Regex ("\\w\\w------------\\w\\w")
36
37
val lines = string.lines()
37
- lines.first() shouldNotContain " -"
38
- lines.last() shouldNotContain " -"
39
- lines.first().reversed().toLowerCase() shouldBe lines.last()
40
- lines.subList(1, 7).forAll {
41
- it shouldBe " ----------------"
42
- }
38
+ lines.forAll { it shouldMatch lineRegex }
39
+ lines.joinToString("") { it.substring(0, 2).toLowerCase() }.reversed() shouldBe lines.joinToString("") { it.takeLast(2) }
43
40
}
44
41
test("clones well") {
45
42
val board = makeBoard(0 y 0 to "R ", 1 y 2 to "m")
@@ -72,33 +69,33 @@ class BoardTest: FunSpec({
72
69
context("amber") {
73
70
context("from position") {
74
71
test("not when reaching target line of opponent") {
75
- val board = makeBoard(0 y 6 to "m")
76
- board.movePiece(Move (0 y 6, 0 y 7 )) shouldBe 0
72
+ val board = makeBoard(6 y 0 to "m")
73
+ board.movePiece(Move (6 y 0, 7 y 0 )) shouldBe 0
77
74
board shouldHaveSize 1
78
75
}
79
76
test("moewe") {
80
- val board = makeBoard(0 y 6 to "M ")
81
- board.movePiece(Move (0 y 6, 0 y 7 )) shouldBe 1
77
+ val board = makeBoard(6 y 0 to "M ")
78
+ board.movePiece(Move (6 y 0, 7 y 0 )) shouldBe 1
82
79
board.shouldBeEmpty()
83
80
}
84
81
test("not for Robbe ") {
85
- val board = makeBoard(0 y 6 to "R ")
86
- board.movePiece(Move (0 y 6, 2 y 7 )) shouldBe 0
82
+ val board = makeBoard(6 y 0 to "R ")
83
+ board.movePiece(Move (6 y 0, 7 y 2 )) shouldBe 0
87
84
board shouldHaveSize 1
88
85
}
89
86
}
90
87
context("from tower") {
91
- val board = makeBoard(0 y 1 to "M ", 0 y 0 to "S2 ", 1 y 0 to "m", 1 y 1 to "r")
88
+ val board = makeBoard(1 y 0 to "M ", 0 y 0 to "S2 ", 0 y 1 to "m", 1 y 1 to "r")
92
89
test("not onto own") {
93
90
shouldThrow<InvalidMoveException > {
94
- board.movePiece(Move (0 y 0, 0 y 1 ))
91
+ board.movePiece(Move (0 y 0, 1 y 0 ))
95
92
}.mistake shouldBe MoveMistake .DESTINATION_BLOCKED
96
93
}
97
94
test("move tower") {
98
95
board.movePiece(Move (0 y 0, 1 y 1)) shouldBe 1
99
96
}
100
97
test("move onto tower") {
101
- board.movePiece(Move (1 y 0 , 0 y 0)) shouldBe 2
98
+ board.movePiece(Move (0 y 1 , 0 y 0)) shouldBe 2
102
99
}
103
100
}
104
101
}
0 commit comments