-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpromotion_test.go
55 lines (45 loc) · 1.12 KB
/
promotion_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package chessplay_test
import (
"fmt"
"testing"
)
func Test_Promotion(t *testing.T) {
fen := "k1r5/5P2/8/8/8/8/8/KR6 w - - 0 1"
promoteTo := []string{"q", "r", "b", "n"}
for _, piece := range promoteTo {
fmt.Printf("FEN before promotion: %s", fen)
game := initGame(t, fen)
move := "f7f8" + piece
err := game.MoveStr(move)
if err != nil {
t.Fatal(err)
}
fmt.Printf("board after promotion: %s", fen)
fmt.Println(game.Position().Board().Draw())
}
}
func Test_EnPassant(t *testing.T) {
fen := "k7/8/8/1p6/2p5/8/1PP5/K7 w - - 0 1"
game := initGame(t, fen)
fmt.Println(game.Position().Board().Draw())
err := game.MoveStr("b2b4")
if err != nil {
t.Fatal(err)
}
fmt.Println(game.Position().Board().Draw())
err = game.MoveStr("c4b3")
if err != nil {
t.Fatal(err)
}
fmt.Println(game.Position().Board().Draw())
}
func Test_Castling(t *testing.T) {
fen := "rnbqk2r/pppp1ppp/3b1n2/4p3/4P3/3B1N2/PPPP1PPP/RNBQK2R w KQkq - 4 4"
game := initGame(t, fen)
fmt.Println(game.Position().Board().Draw())
err := game.MoveStr("e1g1")
if err != nil {
t.Fatal(err)
}
fmt.Println(game.Position().Board().Draw())
}