diff --git a/test/poker2/poker.c b/test/poker2/poker.c index bb6449df..bc933286 100644 --- a/test/poker2/poker.c +++ b/test/poker2/poker.c @@ -1007,7 +1007,36 @@ void test_pokerWinnerGetForPlayer_should_CalculatePair(void) { TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_NINE, winning.set[4]); } -int test_poker() { +void test_pokerWinnerGetForPlayer_should_CalculateTwoPair(void) { + poker2_t poker; + uint8_t i; + poker2player_t *player; + poker2playerwinning_t winning; + + pokerInit(&poker); + i = pokerPlayerAdd(&poker); + player = poker.players + i; + + poker.communitySize = 5; + poker.community[0] = CARD_HEARTS_ACE; + poker.community[1] = CARD_CLUBS_THREE; + poker.community[2] = CARD_SPADES_ACE; + poker.community[3] = CARD_SPADES_QUEEN; + poker.community[4] = CARD_HEARTS_SIX; + player->cardCount = 2; + player->cards[0] = CARD_CLUBS_TWO; + player->cards[1] = CARD_DIAMONDS_TWO; + + pokerWinnerGetForPlayer(&poker, player, &winning); + TEST_ASSERT_EQUAL_UINT8(POKER_WINNING_TYPE_TWO_PAIR, winning.type); + TEST_ASSERT_EQUAL_UINT8(CARD_CLUBS_TWO, winning.set[0]); + TEST_ASSERT_EQUAL_UINT8(CARD_DIAMONDS_TWO, winning.set[1]); + TEST_ASSERT_EQUAL_UINT8(CARD_HEARTS_ACE, winning.set[2]); + TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_ACE, winning.set[3]); + TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_QUEEN, winning.set[4]); +} + +int test_poker2() { UNITY_BEGIN(); RUN_TEST(test_pokerInit_should_InitializePokerGame); @@ -1049,6 +1078,7 @@ int test_poker() { RUN_TEST(test_pokerWinnerFillRemaining_should_FillTheRestOfTheArray); RUN_TEST(test_pokerWinnerGetForPlayer_should_CalculateHighCard); RUN_TEST(test_pokerWinnerGetForPlayer_should_CalculatePair); + RUN_TEST(test_pokerWinnerGetForPlayer_should_CalculateTwoPair); return UNITY_END(); } \ No newline at end of file diff --git a/test/tests.c b/test/tests.c index 5bf81215..67598416 100644 --- a/test/tests.c +++ b/test/tests.c @@ -11,6 +11,6 @@ int main() { return ( test_card() || - test_poker() + test_poker2() ) || 0; } \ No newline at end of file