-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathqueen_actions_test.go
69 lines (61 loc) · 2.84 KB
/
queen_actions_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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package core
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestQueenActions(t *testing.T) {
ts := []struct {
name string
board Board
actions []Action
color color
xy XY
}{
{
name: "white queen: all actions including captures",
board: Board{
Board: []string{
"♜♞♝♛♚♝♞♜",
"♟♟♟♟♟♟♟♟",
" ",
" ",
" ♙♕ ",
" ",
"♙♙ ♙♙♙♙",
"♖♘♗ ♔♗♘♖",
},
Turn: "White",
},
color: ColorWhite,
xy: XY{3, 4},
actions: []Action{
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{3, 5}},
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{3, 6}},
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{3, 7}},
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{3, 3}},
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{3, 2}},
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{3, 1}, IsCapture: true, CapturedPiece: Piece{PieceType: PiecePawn, Owner: ColorBlack, XY: XY{3, 1}}},
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{4, 4}},
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{5, 4}},
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{6, 4}},
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{7, 4}},
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{4, 3}},
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{5, 2}},
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{6, 1}, IsCapture: true, CapturedPiece: Piece{PieceType: PiecePawn, Owner: ColorBlack, XY: XY{6, 1}}},
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{2, 3}},
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{1, 2}},
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{0, 1}, IsCapture: true, CapturedPiece: Piece{PieceType: PiecePawn, Owner: ColorBlack, XY: XY{0, 1}}},
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{2, 5}},
{FromPiece: Piece{PieceType: PieceQueen, Owner: ColorWhite, XY: XY{3, 4}}, ToXY: XY{4, 5}},
},
},
}
for _, tc := range ts {
t.Run(tc.name, func(t *testing.T) {
g, err := NewGameFromBoard(tc.board)
require.NoError(t, err)
assert.ElementsMatch(t, tc.actions, g.Pieces[tc.color][tc.xy].calculateAllActions(g))
})
}
}