mirror of
https://github.com/kierankihn/uno-game.git
synced 2025-12-27 02:13:18 +08:00
test(game): refine GameStateTest while-loop logic and assertions
- Adjusted while-loop conditions to streamline test execution. - Enhanced `canBePlayedOn` validation by passing `drawCount`. - Added assertion to validate card count consistency during gameplay.
This commit is contained in:
@@ -115,10 +115,6 @@ TEST(game_state_test, game_state_test_2)
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if (serverGameState.getCurrentPlayer()->getRemainingCardCount() == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
for (auto it = serverGameState.getCurrentPlayer()->getCards().begin();; it++) {
|
||||
const auto player = serverGameState.getCurrentPlayer();
|
||||
auto prevCards = player->getCards();
|
||||
@@ -140,7 +136,8 @@ TEST(game_state_test, game_state_test_2)
|
||||
|
||||
break;
|
||||
}
|
||||
if (it->canBePlayedOn(serverGameState.getDiscardPile().getFront())) {
|
||||
|
||||
if (it->canBePlayedOn(serverGameState.getDiscardPile().getFront(), serverGameState.getDrawCount())) {
|
||||
auto card = *it;
|
||||
size_t prevCount = player->getCards().count(card);
|
||||
|
||||
@@ -159,5 +156,11 @@ TEST(game_state_test, game_state_test_2)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_EQ(serverGameState.getCurrentPlayer()->getRemainingCardCount(), serverGameState.getCurrentPlayer()->getCards().size());
|
||||
|
||||
if (serverGameState.getCurrentPlayer()->getRemainingCardCount() == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user