1 #include "chessmovetest.h"
2 #include "prototype/chess/move.h"
3 #include "prototype/chess/piece.h"
5 typedef HLVariant::Chess::Piece ChessPiece
;
7 CPPUNIT_TEST_SUITE_REGISTRATION(ChessMoveTest
);
9 void ChessMoveTest::setUp() { }
11 void ChessMoveTest::tearDown() { }
13 void ChessMoveTest::test_capture_square() {
14 ChessMove
m(Point(4, 3), Point(3, 2));
15 CPPUNIT_ASSERT(m
.captureSquare() == Point(3, 2));
17 m
.setType(ChessMove::EN_PASSANT_CAPTURE
);
18 CPPUNIT_ASSERT(m
.captureSquare() == Point(3, 3));
21 void ChessMoveTest::test_en_passant_trigger() {
22 ChessMove
m(Point(4, 6), Point(4, 4));
23 m
.setType(ChessMove::EN_PASSANT_TRIGGER
);
24 CPPUNIT_ASSERT(m
.enPassantTrigger() == Point(4, 5));
26 ChessMove
m2(Point(3, 1), Point(3, 3));
27 m2
.setType(ChessMove::EN_PASSANT_TRIGGER
);
28 CPPUNIT_ASSERT(m2
.enPassantTrigger() == Point(3, 2));
31 void ChessMoveTest::test_promotion() {
32 ChessMove
m(Point(5, 1), Point(5, 0), ChessPiece::ROOK
);
34 CPPUNIT_ASSERT_EQUAL(-1, m
.promoteTo());
35 m
.setType(ChessMove::PROMOTION
);
36 CPPUNIT_ASSERT_EQUAL((int)ChessPiece::ROOK
, m
.promoteTo());