Merge branch 'release-2.1.0'
[purplehaze.git] / test / unit / test_killers.cpp
blob653021b30369cbca5b842183b60b517a3a8b11aa
1 #include "../../src/game.h"
2 #include "gtest/gtest.h"
4 class KillersTest : public testing::Test
6 protected:
7 Game game;
8 };
10 TEST_F(KillersTest, Constructor)
12 for (int d = 0; d < MAX_PLY; ++d) {
13 int n = 0;
14 for (const Move &killer_move : game.killers(d)) {
15 EXPECT_EQ(Move(), killer_move);
16 ++n;
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);
36 --i;
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);
49 game.clear_killers();
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));