Test forsyth (FEN) export

pull/1/merge
Thibault Duplessis 2012-03-05 00:35:40 +01:00
parent 8a4fab7eed
commit 0f71f5e83e
2 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,17 @@
package lila.chess
package format
import Pos.posAt
/**
* Transform a game to standard Forsyth Edwards Notation
* http://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation
*/
object Forsyth extends Format[Game] {
def <<(source: String): Game = {
Game()
}
def >>(game: Game): String = ""
}

View File

@ -0,0 +1,43 @@
package lila.chess
package format
import Pos._
class ForsythTest extends ChessTest {
val f = Forsyth
"the forsyth notation" should {
"export" in {
val moves = List(E2 -> E4, C7 -> C5, G1 -> F3, G8 -> H6, A2 -> A3)
"new game" in {
f >> Game() must_== "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
}
"one move" in {
Game().playMoveList(moves take 1) must beSuccess.like {
case g => f >> g must_== "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1"
}
}
"2 moves" in {
Game().playMoveList(moves take 2) must beSuccess.like {
case g => f >> g must_== "rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 2"
}
}
"3 moves" in {
Game().playMoveList(moves take 3) must beSuccess.like {
case g => f >> g must_== "rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2"
}
}
"4 moves" in {
Game().playMoveList(moves take 4) must beSuccess.like {
case g => f >> g must_== "rnbqkb1r/pp1ppppp/7n/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 2 3"
}
}
"5 moves" in {
Game().playMoveList(moves take 5) must beSuccess.like {
case g => f >> g must_== "rnbqkb1r/pp1ppppp/7n/2p5/4P3/P4N2/1PPP1PPP/RNBQKB1R b KQkq - 0 3"
}
}
}
}
}