1 #include "chesspiecetest.h"
6 #include <types/chess/rook.h>
7 #include <types/chess/bishop.h>
8 #include <types/chess/queen.h>
9 #include <types/chess/king.h>
12 using namespace Chess
;
14 CPPUNIT_TEST_SUITE_REGISTRATION(ChessPieceTest
);
16 Variant
* chess_variant_factory();
18 void ChessPieceTest::setUp() {
19 m_chess
= chess_variant_factory();
20 m_namer
= requestComponent
<INamer
>(m_chess
, "namer");
23 void ChessPieceTest::tearDown() {
27 void ChessPieceTest::test_basic() {
28 Piece
p(White::self(), Rook::self());
30 static_cast<const IColor
*>(White::self()),
33 static_cast<const IType
*>(Rook::self()),
37 void ChessPieceTest::test_names() {
38 Piece
p(Black::self(), Bishop::self());
39 CPPUNIT_ASSERT(p
.color()->name() == "black");
40 CPPUNIT_ASSERT(p
.type()->name() == "bishop");
41 CPPUNIT_ASSERT(m_namer
->name(p
) == "black_bishop");
44 void ChessPieceTest::test_compare() {
45 Piece
a(Black::self(), King::self());
46 Piece
b(White::self(), Queen::self());
47 Piece
c(Black::self(), King::self());
49 CPPUNIT_ASSERT(a
!= b
);
50 CPPUNIT_ASSERT(!(a
== b
));
51 CPPUNIT_ASSERT(a
== c
);
52 CPPUNIT_ASSERT(c
== a
);
53 CPPUNIT_ASSERT(a
== a
);