Update NEWS
[purplehaze.git] / test / unit / test_piece.cpp
blob8483e6c2893104ffb5ab77cb69f7634d037a4188
1 #include "../../src/piece.h"
2 #include "gtest/gtest.h"
4 TEST(PieceTest, Constructor)
6 for (const Color &c : COLORS) {
7 for (const PieceType &t : PIECE_TYPES) {
8 for (int i = 0; i < 9; ++i) {
9 Piece p(c, t, i);
11 // Test getters
12 EXPECT_EQ(c, p.color());
13 EXPECT_NE(!c, p.color());
14 EXPECT_EQ(t, p.type());
15 EXPECT_EQ(i, p.index());
17 EXPECT_TRUE(p.is(c));
18 EXPECT_FALSE(p.is(!c));
19 EXPECT_TRUE(p.is(t));
20 EXPECT_TRUE(p.is(c, t));
21 EXPECT_FALSE(p.is(!c, t));
23 // Test comparison operators
24 for (const Color &c2 : COLORS) {
25 for (const PieceType &t2 : PIECE_TYPES) {
26 for (int j = 0; j < 9; ++j) {
27 Piece p2(c2, t2, j);
28 if (c == c2 && t == t2 && i == j) {
29 EXPECT_EQ(p2, p);
30 } else {
31 EXPECT_NE(p2, p);
41 TEST(PieceTest, Size)
43 EXPECT_EQ(sizeof(unsigned char), sizeof(Piece));