More poker unit tests.
This commit is contained in:
@ -187,9 +187,56 @@ void test_pokerPlayerChipsAdd_should_TurnOutStateOff(void) {
|
||||
player = poker.players + playerIndex;
|
||||
|
||||
player->state |= POKER_PLAYER_STATE_OUT;
|
||||
TEST_ASSERT_EQUAL(true, player->state & POKER_PLAYER_STATE_OUT);
|
||||
TEST_ASSERT_BITS_HIGH(POKER_PLAYER_STATE_OUT, player->state);
|
||||
pokerPlayerChipsAdd(player, 32);
|
||||
TEST_ASSERT_EQUAL(false, player->state & POKER_PLAYER_STATE_OUT);
|
||||
TEST_ASSERT_BIT_LOW(POKER_PLAYER_STATE_OUT, player->state);
|
||||
}
|
||||
|
||||
void test_pokerPLayerDealAll_should_DealCardsToEveryone(void) {
|
||||
poker2_t poker;
|
||||
pokerInit(&poker);
|
||||
|
||||
pokerPlayerAdd(&poker);
|
||||
pokerPlayerAdd(&poker);
|
||||
pokerPlayerAdd(&poker);
|
||||
|
||||
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE, poker.deckSize);
|
||||
TEST_ASSERT_EQUAL_UINT8(0, poker.players[0].cardCount);
|
||||
TEST_ASSERT_EQUAL_UINT8(0, poker.players[1].cardCount);
|
||||
TEST_ASSERT_EQUAL_UINT8(0, poker.players[2].cardCount);
|
||||
|
||||
pokerPlayerDealAll(&poker, 0x01);
|
||||
TEST_ASSERT_EQUAL_UINT8(1, poker.players[0].cardCount);
|
||||
TEST_ASSERT_EQUAL_UINT8(1, poker.players[1].cardCount);
|
||||
TEST_ASSERT_EQUAL_UINT8(1, poker.players[2].cardCount);
|
||||
|
||||
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_ACE, poker.players[0].cards[0]);
|
||||
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_KING, poker.players[1].cards[0]);
|
||||
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_QUEEN, poker.players[2].cards[0]);
|
||||
}
|
||||
|
||||
void test_pokerPLayerDealAll_should_DealMultipleCardsToEveryone(void) {
|
||||
poker2_t poker;
|
||||
pokerInit(&poker);
|
||||
|
||||
pokerPlayerAdd(&poker);
|
||||
pokerPlayerAdd(&poker);
|
||||
pokerPlayerAdd(&poker);
|
||||
|
||||
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE, poker.deckSize);
|
||||
TEST_ASSERT_EQUAL_UINT8(0, poker.players[0].cardCount);
|
||||
|
||||
pokerPlayerDealAll(&poker, 0x02);
|
||||
TEST_ASSERT_EQUAL_UINT8(2, poker.players[0].cardCount);
|
||||
TEST_ASSERT_EQUAL_UINT8(2, poker.players[1].cardCount);
|
||||
TEST_ASSERT_EQUAL_UINT8(2, poker.players[2].cardCount);
|
||||
|
||||
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_ACE, poker.players[0].cards[0]);
|
||||
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_KING, poker.players[0].cards[1]);
|
||||
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_QUEEN, poker.players[1].cards[0]);
|
||||
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_JACK, poker.players[1].cards[1]);
|
||||
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_TEN, poker.players[2].cards[0]);
|
||||
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_NINE, poker.players[2].cards[1]);
|
||||
}
|
||||
|
||||
int test_poker2() {
|
||||
@ -206,6 +253,8 @@ int test_poker2() {
|
||||
RUN_TEST(test_pokerPlayerDeal_should_DealCardsToThePlayer);
|
||||
RUN_TEST(test_pokerPlayerChipsAdd_should_AddChipsToThePlayer);
|
||||
RUN_TEST(test_pokerPlayerChipsAdd_should_TurnOutStateOff);
|
||||
RUN_TEST(test_pokerPLayerDealAll_should_DealCardsToEveryone);
|
||||
RUN_TEST(test_pokerPLayerDealAll_should_DealMultipleCardsToEveryone);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
Reference in New Issue
Block a user