mirror of
https://github.com/kierankihn/uno-game.git
synced 2025-12-27 02:13:18 +08:00
test(game): add test cases for Player
This commit is contained in:
@@ -7,6 +7,7 @@ project(uno-game-test)
|
|||||||
|
|
||||||
add_executable(uno-game-test unit/game/CardTest.cpp
|
add_executable(uno-game-test unit/game/CardTest.cpp
|
||||||
unit/game/CardTileTest.cpp
|
unit/game/CardTileTest.cpp
|
||||||
|
unit/game/PlayerTest.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(uno-game-test
|
target_link_libraries(uno-game-test
|
||||||
|
|||||||
40
test/unit/game/PlayerTest.cpp
Normal file
40
test/unit/game/PlayerTest.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* @file PlayerTest.cpp
|
||||||
|
*
|
||||||
|
* @author Yuzhe Guo
|
||||||
|
* @date 2025.11.16
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../../../src/game/Card.h"
|
||||||
|
#include "../../../src/game/Player.h"
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
TEST(player_test, player_test_1)
|
||||||
|
{
|
||||||
|
UNO::GAME::HandCard handCard(std::array<UNO::GAME::Card, 7>{
|
||||||
|
UNO::GAME::Card(UNO::GAME::CardColor::BLUE, UNO::GAME::CardType::REVERSE),
|
||||||
|
UNO::GAME::Card(UNO::GAME::CardColor::RED, UNO::GAME::CardType::SKIP),
|
||||||
|
UNO::GAME::Card(UNO::GAME::CardColor::BLUE, UNO::GAME::CardType::NUM3),
|
||||||
|
UNO::GAME::Card(UNO::GAME::CardColor::WILD, UNO::GAME::CardType::WILDDRAWFOUR),
|
||||||
|
UNO::GAME::Card(UNO::GAME::CardColor::GREEN, UNO::GAME::CardType::NUM9),
|
||||||
|
UNO::GAME::Card(UNO::GAME::CardColor::RED, UNO::GAME::CardType::NUM1),
|
||||||
|
UNO::GAME::Card(UNO::GAME::CardColor::WILD, UNO::GAME::CardType::WILD)
|
||||||
|
});
|
||||||
|
|
||||||
|
ASSERT_EQ(handCard.getCards().begin()->getColor(), UNO::GAME::CardColor::RED);
|
||||||
|
ASSERT_EQ(handCard.getCards().begin()->getType(), UNO::GAME::CardType::NUM1);
|
||||||
|
|
||||||
|
handCard.play(handCard.getCards().begin());
|
||||||
|
|
||||||
|
ASSERT_EQ(handCard.getCards().begin()->getColor(), UNO::GAME::CardColor::RED);
|
||||||
|
ASSERT_EQ(handCard.getCards().begin()->getType(), UNO::GAME::CardType::SKIP);
|
||||||
|
|
||||||
|
handCard.draw(UNO::GAME::Card(UNO::GAME::CardColor::RED, UNO::GAME::CardType::NUM0));
|
||||||
|
|
||||||
|
ASSERT_EQ(handCard.getCards().begin()->getColor(), UNO::GAME::CardColor::RED);
|
||||||
|
ASSERT_EQ(handCard.getCards().begin()->getType(), UNO::GAME::CardType::NUM0);
|
||||||
|
|
||||||
|
ASSERT_EQ(handCard.isEmpty(), false);
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user