1 #include "../../src/game.h"
2 #include "gtest/gtest.h"
4 class KillersTest
: public testing::Test
10 TEST_F(KillersTest
, Constructor
)
12 for (int d
= 0; d
< MAX_PLY
; ++d
) {
14 for (const Move
&killer_move
: game
.killers(d
)) {
15 EXPECT_EQ(Move(), killer_move
);
18 EXPECT_EQ(MAX_KILLERS
, n
);
22 TEST_F(KillersTest
, SetKiller
)
24 for (int d
= 0; d
< MAX_PLY
; ++d
) {
25 for (int i
= 0; i
< MAX_KILLERS
; ++i
) {
26 Square to
= static_cast<Square
>(E4
+ i
);
27 game
.set_killer(Move(E2
, to
, QUIET_MOVE
), d
);
30 for (int d
= 0; d
< MAX_PLY
; ++d
) {
31 int i
= MAX_KILLERS
- 1;
32 for (const Move
&killer_move
: game
.killers(d
)) {
33 Square to
= static_cast<Square
>(E4
+ i
);
34 EXPECT_EQ(Move(E2
, to
, QUIET_MOVE
), killer_move
);
35 EXPECT_NE(Move(), killer_move
);
41 TEST_F(KillersTest
, ClearKiller
)
43 for (int d
= 0; d
< MAX_PLY
; ++d
) {
44 for (int i
= 0; i
< MAX_KILLERS
; ++i
) {
45 Square to
= static_cast<Square
>(E4
+ i
);
46 game
.set_killer(Move(E2
, to
, QUIET_MOVE
), d
);
50 for (int d
= 0; d
< MAX_PLY
; ++d
) {
51 for (const Move
&killer_move
: game
.killers(d
)) {
52 EXPECT_EQ(Move(), killer_move
);
57 TEST_F(KillersTest
, IsKiller
)
59 for (int d
= 0; d
< MAX_PLY
; ++d
) {
60 for (int i
= 0; i
< MAX_KILLERS
; ++i
) {
61 Square to
= static_cast<Square
>(E4
+ i
);
62 game
.set_killer(Move(E2
, to
, QUIET_MOVE
), d
);
65 for (int d
= 0; d
< MAX_PLY
; ++d
) {
66 EXPECT_FALSE(game
.is_killer(Move(E2
, E3
, QUIET_MOVE
), d
));
67 EXPECT_FALSE(game
.is_killer(Move(), d
));
68 for (int i
= 0; i
< MAX_KILLERS
; ++i
) {
69 Square to
= static_cast<Square
>(E4
+ i
);
70 EXPECT_TRUE(game
.is_killer(Move(E2
, to
, QUIET_MOVE
), d
));