Add castle tests
parent
043340dfcd
commit
bee9d5a75b
|
@ -47,6 +47,5 @@ case object Pawn extends Role {
|
|||
|
||||
object Role {
|
||||
|
||||
val all = List(King, Queen, Rook, Bishop, Knight, Pawn)
|
||||
|
||||
lazy val all = List(King, Queen, Rook, Bishop, Knight, Pawn)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package lila
|
||||
package model
|
||||
|
||||
import Pos._
|
||||
|
||||
class CastleTest extends LilaSpec {
|
||||
|
||||
"a king" should {
|
||||
|
||||
val king = White - King
|
||||
|
||||
"castle" in {
|
||||
"king side" in {
|
||||
"impossible" in {
|
||||
"pieces in the way" in {
|
||||
Board().movesFrom(E1) must bePoss()
|
||||
}
|
||||
}
|
||||
"possible" in {
|
||||
val board = """
|
||||
PPPPPPPP
|
||||
R QK R"""
|
||||
"viable moves" in {
|
||||
board movesFrom E1 must bePoss(F1, G1)
|
||||
}
|
||||
}
|
||||
}
|
||||
"queen side" in {
|
||||
"impossible" in {
|
||||
"pieces in the way" in {
|
||||
Board() movesFrom E1 must bePoss()
|
||||
}
|
||||
}
|
||||
"possible" in {
|
||||
val board = """
|
||||
PPPPPP
|
||||
R KB"""
|
||||
"viable moves" in {
|
||||
board movesFrom E1 must bePoss(D1, C1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,6 +21,12 @@ class KingTest extends LilaSpec {
|
|||
moves(H8) must bePoss(H7, G7, G8)
|
||||
}
|
||||
|
||||
"move behind pawn barrier" in {
|
||||
"""
|
||||
PPPPPPPP
|
||||
R QK NR""" movesFrom(E1) must bePoss(F1)
|
||||
}
|
||||
|
||||
"not move to positions that are occupied by the same colour" in {
|
||||
val board = """
|
||||
k B
|
||||
|
|
Loading…
Reference in New Issue