Add a PromotionManager.
[tagua/yd.git] / tests / variants / chesspiecetest.cpp
blob2be631b095dcb7f756dc20d7d914173719d25ee0
1 #include "chesspiecetest.h"
2 #include <color.h>
3 #include <component.h>
4 #include <namer.h>
5 #include <piece.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>
10 #include <variant.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() {
24 delete m_chess;
27 void ChessPieceTest::test_basic() {
28 Piece p(White::self(), Rook::self());
29 CPPUNIT_ASSERT_EQUAL(
30 static_cast<const IColor*>(White::self()),
31 p.color());
32 CPPUNIT_ASSERT_EQUAL(
33 static_cast<const IType*>(Rook::self()),
34 p.type());
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);