Add castle tests

pull/1/merge
Thibault Duplessis 2012-02-25 13:52:28 +01:00
parent 043340dfcd
commit bee9d5a75b
3 changed files with 52 additions and 2 deletions

View File

@ -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)
}

View File

@ -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)
}
}
}
}
}
}

View File

@ -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