File: chesspiecetest.cpp

package info (click to toggle)
tagua 1.0~alpha2-15
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 8,028 kB
  • ctags: 7,178
  • sloc: cpp: 26,149; ansic: 13,039; makefile: 182; ruby: 87; sh: 39
file content (36 lines) | stat: -rw-r--r-- 993 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "chesspiecetest.h"
#include "hlvariant/chess/piece.h"

typedef HLVariant::Chess::Piece ChessPiece;

CPPUNIT_TEST_SUITE_REGISTRATION(ChessPieceTest);

void ChessPieceTest::setUp() { }

void ChessPieceTest::tearDown() { }

void ChessPieceTest::test_basic() {
  ChessPiece p(ChessPiece::WHITE, ChessPiece::ROOK);
  CPPUNIT_ASSERT_EQUAL(ChessPiece::WHITE, p.color());
  CPPUNIT_ASSERT_EQUAL(ChessPiece::ROOK, p.type());
}

void ChessPieceTest::test_names() {
  ChessPiece p(ChessPiece::BLACK, ChessPiece::BISHOP);
  CPPUNIT_ASSERT(p.colorName() == "black");
  CPPUNIT_ASSERT(p.typeName() == "bishop");
  CPPUNIT_ASSERT(p.name() == "black_bishop");
}

void ChessPieceTest::test_compare() {
  ChessPiece a(ChessPiece::BLACK, ChessPiece::KING);
  ChessPiece b(ChessPiece::WHITE, ChessPiece::QUEEN);
  ChessPiece c(ChessPiece::BLACK, ChessPiece::KING);
  
  CPPUNIT_ASSERT(a != b);
  CPPUNIT_ASSERT(!(a == b));
  CPPUNIT_ASSERT(a == c);
  CPPUNIT_ASSERT(c == a);
  CPPUNIT_ASSERT(a == a);
}