Add test for pins

This commit is contained in:
ekzyis 2024-09-26 09:48:12 +02:00
parent 908cc1cfda
commit be247e1f46
2 changed files with 10 additions and 1 deletions

View File

@ -294,7 +294,6 @@ func (b *Board) Move(move string) error {
// TODO: parse ambiguous captures for all pieces
// TODO: parse checkmates e.g. e5#
// TODO: parse O-O as kingside castle and O-O-O as queenside castle
// TODO: make sure pinned pieces cannot move
move_ := func() error {

View File

@ -472,6 +472,16 @@ func TestBoardCheck(t *testing.T) {
assertParse(t, b, "Kxf7")
}
func TestBoardPin(t *testing.T) {
t.Parallel()
b := chess.NewBoard()
assertParse(t, b, "d4 e5 Nc3 Bb4")
assertMoveError(t, b, "Ne4", "invalid move Ne4: king is in check")
}
func assertParse(t *testing.T, b *chess.Board, moves string) {
assert.NoError(t, b.Parse(moves))
}