Update NEWS
[purplehaze.git] / test / unit / test_searchmove.cpp
blob7fed18b5ba624c9f4f5777305d85a1876500ad1e
1 #include "../../src/protocol.h"
2 #include "gtest/gtest.h"
4 class SearchMoveTest : public testing::Test
6 protected:
7 Protocol proto;
8 std::string fen;
10 virtual void SetUp() {
11 proto.new_game();
12 proto.set_output_thinking(true);
15 std::string search(int time = 20) {
16 proto.set_board(fen);
17 proto.set_time(1, time);
18 return proto.search_move(true);
22 TEST_F(SearchMoveTest, Fine70Position)
24 fen = "8/k7/3p4/p2P1p2/P2P1P2/8/8/K7 w - -";
25 EXPECT_EQ("Kb1", search());
28 TEST_F(SearchMoveTest, RetiEndgamePosition)
30 fen = "7K/8/k1P5/7p/8/8/8/8 w - -";
31 EXPECT_EQ("Kg7", search());
34 TEST_F(SearchMoveTest, Zugzwang1Position)
36 fen = "8/8/p1p5/1p5p/1P5p/8/PPP2K1p/4R1rk w - - 0 1";
37 EXPECT_EQ("Rf1", search());
40 TEST_F(SearchMoveTest, Zugzwang2Position)
42 fen = "1q1k4/2Rr4/8/2Q3K1/8/8/8/8 w - - 0 1";
43 EXPECT_EQ("Kh6", search());
46 TEST_F(SearchMoveTest, BishopPromotionPosition)
48 fen = "1q6/P6k/8/5N1K/8/8/8/8 w - - 0 1";
49 EXPECT_EQ("axb8=B", search());
52 TEST_F(SearchMoveTest, CastlePosition)
54 fen = "r1bqkb1r/1ppp1ppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQK2R w KQkq -";
55 EXPECT_EQ("O-O", search());
58 TEST_F(SearchMoveTest, Mate1Position)
60 // Mate in 1
61 fen = "8/2r4p/p4p1Q/1p2bp2/8/6k1/P5P1/3B2K1 w - -";
62 EXPECT_EQ("Qh2+", search());
65 TEST_F(SearchMoveTest, Mate2Position)
67 // Mate in 3
68 fen = "7k/1p5p/5b2/p3pr2/4n3/4B1rP/PP1N3K/3R1R2 b - -";
69 EXPECT_EQ("Rh5", search());
72 TEST_F(SearchMoveTest, Lose1Position)
74 // Lose in 2
75 fen = "7k/1p5p/5b2/p3p2r/4n3/4B1rP/PP1N3K/3R1R2 w - -";
76 EXPECT_EQ("Nxe4", search());