|
|
|
@ -90,7 +90,7 @@ void test_pokerResetBettingRound_should_ResetTheBettingRound(void) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_pokerNewDealer_should_FindANewDealer(void) {
|
|
|
|
|
void test_pokerDealerNew_should_FindANewDealer(void) {
|
|
|
|
|
poker_t poker;
|
|
|
|
|
pokerInit(&poker);
|
|
|
|
|
|
|
|
|
@ -104,28 +104,28 @@ void test_pokerNewDealer_should_FindANewDealer(void) {
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.playerSmallBlind);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.playerBigBlind);
|
|
|
|
|
|
|
|
|
|
pokerNewDealer(&poker);
|
|
|
|
|
pokerDealerNew(&poker);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(1, poker.playerDealer);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(2, poker.playerSmallBlind);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(3, poker.playerBigBlind);
|
|
|
|
|
|
|
|
|
|
pokerNewDealer(&poker);
|
|
|
|
|
pokerDealerNew(&poker);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(2, poker.playerDealer);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(3, poker.playerSmallBlind);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(4, poker.playerBigBlind);
|
|
|
|
|
|
|
|
|
|
pokerNewDealer(&poker);
|
|
|
|
|
pokerDealerNew(&poker);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(3, poker.playerDealer);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(4, poker.playerSmallBlind);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.playerBigBlind);
|
|
|
|
|
|
|
|
|
|
pokerNewDealer(&poker);
|
|
|
|
|
pokerDealerNew(&poker);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(4, poker.playerDealer);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.playerSmallBlind);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(1, poker.playerBigBlind);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_pokerSetDealer_should_SetANewSetOfPlayers(void) {
|
|
|
|
|
void test_pokerDealerSet_should_SetANewSetOfPlayers(void) {
|
|
|
|
|
poker_t poker;
|
|
|
|
|
pokerInit(&poker);
|
|
|
|
|
|
|
|
|
@ -135,38 +135,38 @@ void test_pokerSetDealer_should_SetANewSetOfPlayers(void) {
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 1000);
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 1000);
|
|
|
|
|
|
|
|
|
|
pokerSetDealer(&poker, 0x00);
|
|
|
|
|
pokerDealerSet(&poker, 0x00);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.playerDealer);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(1, poker.playerSmallBlind);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(2, poker.playerBigBlind);
|
|
|
|
|
|
|
|
|
|
pokerSetDealer(&poker, 0x01);
|
|
|
|
|
pokerDealerSet(&poker, 0x01);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(1, poker.playerDealer);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(2, poker.playerSmallBlind);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(3, poker.playerBigBlind);
|
|
|
|
|
|
|
|
|
|
pokerSetDealer(&poker, 0x02);
|
|
|
|
|
pokerDealerSet(&poker, 0x02);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(2, poker.playerDealer);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(3, poker.playerSmallBlind);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(4, poker.playerBigBlind);
|
|
|
|
|
|
|
|
|
|
pokerSetDealer(&poker, 0x03);
|
|
|
|
|
pokerDealerSet(&poker, 0x03);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(3, poker.playerDealer);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(4, poker.playerSmallBlind);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.playerBigBlind);
|
|
|
|
|
|
|
|
|
|
pokerSetDealer(&poker, 0x04);
|
|
|
|
|
pokerDealerSet(&poker, 0x04);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(4, poker.playerDealer);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.playerSmallBlind);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(1, poker.playerBigBlind);
|
|
|
|
|
|
|
|
|
|
pokerSetDealer(&poker, 0x00);
|
|
|
|
|
pokerDealerSet(&poker, 0x00);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.playerDealer);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(1, poker.playerSmallBlind);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(2, poker.playerBigBlind);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_pokerSetDealer_should_SkipOutPlayers(void) {
|
|
|
|
|
void test_pokerDealerSet_should_SkipOutPlayers(void) {
|
|
|
|
|
poker_t poker;
|
|
|
|
|
pokerInit(&poker);
|
|
|
|
|
|
|
|
|
@ -176,27 +176,27 @@ void test_pokerSetDealer_should_SkipOutPlayers(void) {
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 1000);
|
|
|
|
|
pokerPlayerAdd(&poker);
|
|
|
|
|
|
|
|
|
|
pokerSetDealer(&poker, 0x00);
|
|
|
|
|
pokerDealerSet(&poker, 0x00);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.playerDealer);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(1, poker.playerSmallBlind);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(3, poker.playerBigBlind);
|
|
|
|
|
|
|
|
|
|
pokerSetDealer(&poker, 0x01);
|
|
|
|
|
pokerDealerSet(&poker, 0x01);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(1, poker.playerDealer);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(3, poker.playerSmallBlind);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.playerBigBlind);
|
|
|
|
|
|
|
|
|
|
pokerSetDealer(&poker, 0x02);
|
|
|
|
|
pokerDealerSet(&poker, 0x02);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(3, poker.playerDealer);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.playerSmallBlind);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(1, poker.playerBigBlind);
|
|
|
|
|
|
|
|
|
|
pokerSetDealer(&poker, 0x03);
|
|
|
|
|
pokerDealerSet(&poker, 0x03);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(3, poker.playerDealer);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.playerSmallBlind);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(1, poker.playerBigBlind);
|
|
|
|
|
|
|
|
|
|
pokerSetDealer(&poker, 0x04);
|
|
|
|
|
pokerDealerSet(&poker, 0x04);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.playerDealer);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(1, poker.playerSmallBlind);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(3, poker.playerBigBlind);
|
|
|
|
@ -212,7 +212,7 @@ void test_pokerTakeBlinds_should_TakeTheBlinds(void) {
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 1000);
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 1000);
|
|
|
|
|
|
|
|
|
|
pokerNewDealer(&poker);
|
|
|
|
|
pokerDealerNew(&poker);
|
|
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(1000, (poker.players + 0)->chips);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(1000, (poker.players + 1)->chips);
|
|
|
|
@ -228,7 +228,7 @@ void test_pokerTakeBlinds_should_TakeTheBlinds(void) {
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(800, (poker.players + 3)->chips);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(1000, (poker.players + 4)->chips);
|
|
|
|
|
|
|
|
|
|
pokerNewDealer(&poker);
|
|
|
|
|
pokerDealerNew(&poker);
|
|
|
|
|
pokerTakeBlinds(&poker, 100, 200);
|
|
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(1000, (poker.players + 0)->chips);
|
|
|
|
@ -342,19 +342,19 @@ void test_pokerPlayerAdd_should_ResetThePlayer(void) {
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(POKER_PLAYER_STATE_OUT, player->state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_pokerTurn_should_TurnCardsFromTheDeck(void) {
|
|
|
|
|
void test_pokerDealerTurn_should_TurnCardsFromTheDeck(void) {
|
|
|
|
|
poker_t poker;
|
|
|
|
|
pokerInit(&poker);
|
|
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE, poker.deckSize);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.communitySize);
|
|
|
|
|
|
|
|
|
|
pokerTurn(&poker, 1);
|
|
|
|
|
pokerDealerTurn(&poker, 1);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE - 1, poker.deckSize);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(1, poker.communitySize);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_ACE, poker.community[0]);
|
|
|
|
|
|
|
|
|
|
pokerTurn(&poker, 3);
|
|
|
|
|
pokerDealerTurn(&poker, 3);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE - 4, poker.deckSize);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(4, poker.communitySize);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_KING, poker.community[1]);
|
|
|
|
@ -362,19 +362,19 @@ void test_pokerTurn_should_TurnCardsFromTheDeck(void) {
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_JACK, poker.community[3]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_pokerBurn_should_SendCardsToTheGrave(void) {
|
|
|
|
|
void test_pokerDealerBurn_should_SendCardsToTheGrave(void) {
|
|
|
|
|
poker_t poker;
|
|
|
|
|
pokerInit(&poker);
|
|
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE, poker.deckSize);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.graveSize);
|
|
|
|
|
|
|
|
|
|
pokerBurn(&poker, 1);
|
|
|
|
|
pokerDealerBurn(&poker, 1);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE - 1, poker.deckSize);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(1, poker.graveSize);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_ACE, poker.grave[0]);
|
|
|
|
|
|
|
|
|
|
pokerBurn(&poker, 3);
|
|
|
|
|
pokerDealerBurn(&poker, 3);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE - 4, poker.deckSize);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(4, poker.graveSize);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_KING, poker.grave[1]);
|
|
|
|
@ -393,15 +393,15 @@ void test_pokerGetCallValue_should_CalculateTheCallValue(void) {
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + second, 10000);
|
|
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(0, pokerGetCallValue(&poker));
|
|
|
|
|
pokerPlayerBet(&poker, first, 100);
|
|
|
|
|
pokerBetForPlayer(&poker, first, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(100, pokerGetCallValue(&poker));
|
|
|
|
|
pokerPlayerBet(&poker, second, 150);
|
|
|
|
|
pokerBetForPlayer(&poker, second, 150);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(150, pokerGetCallValue(&poker));
|
|
|
|
|
|
|
|
|
|
pokerPotAdd(&poker);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(150, pokerGetCallValue(&poker));
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(0, poker.pots[1].chips);
|
|
|
|
|
pokerPlayerBet(&poker, second, 50);
|
|
|
|
|
pokerBetForPlayer(&poker, second, 50);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(200, pokerGetCallValue(&poker));
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(50, poker.pots[1].chips);
|
|
|
|
|
}
|
|
|
|
@ -413,15 +413,15 @@ void test_pokerGetCallValue_should_SkipOutPlayers(void) {
|
|
|
|
|
|
|
|
|
|
i = pokerPlayerAdd(&poker);
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + i, 10000);
|
|
|
|
|
pokerPlayerBet(&poker, i, 300);
|
|
|
|
|
pokerBetForPlayer(&poker, i, 300);
|
|
|
|
|
|
|
|
|
|
i = pokerPlayerAdd(&poker);
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + i, 10000);
|
|
|
|
|
pokerPlayerBet(&poker, i, 500);
|
|
|
|
|
pokerBetForPlayer(&poker, i, 500);
|
|
|
|
|
|
|
|
|
|
i = pokerPlayerAdd(&poker);
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + i, 10000);
|
|
|
|
|
pokerPlayerBet(&poker, i, 200);
|
|
|
|
|
pokerBetForPlayer(&poker, i, 200);
|
|
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(500, pokerGetCallValue(&poker));
|
|
|
|
|
poker.players[1].state |= POKER_PLAYER_STATE_OUT;
|
|
|
|
@ -430,7 +430,7 @@ void test_pokerGetCallValue_should_SkipOutPlayers(void) {
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(200, pokerGetCallValue(&poker));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_pokerPlayerDeal_should_DealCardsToThePlayer(void) {
|
|
|
|
|
void test_pokerDeal_should_DealCardsToThePlayer(void) {
|
|
|
|
|
poker_t poker;
|
|
|
|
|
uint8_t playerIndex;
|
|
|
|
|
pokerplayer_t *player;
|
|
|
|
@ -443,12 +443,12 @@ void test_pokerPlayerDeal_should_DealCardsToThePlayer(void) {
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE, poker.deckSize);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, player->cardCount);
|
|
|
|
|
|
|
|
|
|
pokerPlayerDeal(&poker, player, 0x01);
|
|
|
|
|
pokerDeal(&poker, player, 0x01);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE - 1, poker.deckSize);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(1, player->cardCount);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_ACE, player->cards[0]);
|
|
|
|
|
|
|
|
|
|
pokerPlayerDeal(&poker, player, 0x01);
|
|
|
|
|
pokerDeal(&poker, player, 0x01);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE - 2, poker.deckSize);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(2, player->cardCount);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_KING, player->cards[1]);
|
|
|
|
@ -487,7 +487,7 @@ void test_pokerPlayerChipsAdd_should_TurnOutStateOff(void) {
|
|
|
|
|
TEST_ASSERT_BITS_LOW(POKER_PLAYER_STATE_OUT, player->state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_pokerPlayerDealAll_should_DealCardsToEveryone(void) {
|
|
|
|
|
void test_pokerDealAllPlayers_should_DealCardsToEveryone(void) {
|
|
|
|
|
poker_t poker;
|
|
|
|
|
pokerInit(&poker);
|
|
|
|
|
|
|
|
|
@ -500,7 +500,7 @@ void test_pokerPlayerDealAll_should_DealCardsToEveryone(void) {
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.players[1].cardCount);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.players[2].cardCount);
|
|
|
|
|
|
|
|
|
|
pokerPlayerDealAll(&poker, 1);
|
|
|
|
|
pokerDealAllPlayers(&poker, 1);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE - 3, poker.deckSize);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(1, poker.players[0].cardCount);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(1, poker.players[1].cardCount);
|
|
|
|
@ -511,7 +511,7 @@ void test_pokerPlayerDealAll_should_DealCardsToEveryone(void) {
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_QUEEN, poker.players[2].cards[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_pokerPlayerDealAll_should_DealMultipleCardsToEveryone(void) {
|
|
|
|
|
void test_pokerDealAllPlayers_should_DealMultipleCardsToEveryone(void) {
|
|
|
|
|
poker_t poker;
|
|
|
|
|
pokerInit(&poker);
|
|
|
|
|
|
|
|
|
@ -522,7 +522,7 @@ void test_pokerPlayerDealAll_should_DealMultipleCardsToEveryone(void) {
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE, poker.deckSize);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.players[0].cardCount);
|
|
|
|
|
|
|
|
|
|
pokerPlayerDealAll(&poker, 0x02);
|
|
|
|
|
pokerDealAllPlayers(&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);
|
|
|
|
@ -535,7 +535,7 @@ void test_pokerPlayerDealAll_should_DealMultipleCardsToEveryone(void) {
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_NINE, poker.players[2].cards[1]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_pokerPlayerDealAll_should_NotDealToOutPlayers(void) {
|
|
|
|
|
void test_pokerDealAllPlayers_should_NotDealToOutPlayers(void) {
|
|
|
|
|
poker_t poker;
|
|
|
|
|
pokerInit(&poker);
|
|
|
|
|
|
|
|
|
@ -546,7 +546,7 @@ void test_pokerPlayerDealAll_should_NotDealToOutPlayers(void) {
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE, poker.deckSize);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.players[0].cardCount);
|
|
|
|
|
|
|
|
|
|
pokerPlayerDealAll(&poker, 0x02);
|
|
|
|
|
pokerDealAllPlayers(&poker, 0x02);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(2, poker.players[0].cardCount);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.players[1].cardCount);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(2, poker.players[2].cardCount);
|
|
|
|
@ -557,7 +557,7 @@ void test_pokerPlayerDealAll_should_NotDealToOutPlayers(void) {
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_JACK, poker.players[2].cards[1]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_pokerPlayerDealAll_should_NotDealToFoldedPlayers(void) {
|
|
|
|
|
void test_pokerDealAllPlayers_should_NotDealToFoldedPlayers(void) {
|
|
|
|
|
poker_t poker;
|
|
|
|
|
pokerInit(&poker);
|
|
|
|
|
|
|
|
|
@ -566,7 +566,7 @@ void test_pokerPlayerDealAll_should_NotDealToFoldedPlayers(void) {
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 100);
|
|
|
|
|
poker.players[0].state |= POKER_PLAYER_STATE_FOLDED;
|
|
|
|
|
|
|
|
|
|
pokerPlayerDealAll(&poker, 2);
|
|
|
|
|
pokerDealAllPlayers(&poker, 2);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0, poker.players[0].cardCount);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(2, poker.players[1].cardCount);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(2, poker.players[2].cardCount);
|
|
|
|
@ -588,15 +588,15 @@ void test_pokerPlayerDoesNeedToBetThisRound_should_CheckCallValue(void) {
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + first, 10000);
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + second, 10000);
|
|
|
|
|
|
|
|
|
|
pokerPlayerBet(&poker, first, 100);
|
|
|
|
|
pokerBetForPlayer(&poker, first, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, first));
|
|
|
|
|
TEST_ASSERT_EQUAL(true, pokerPlayerDoesNeedToBetThisRound(&poker, second));
|
|
|
|
|
|
|
|
|
|
pokerPlayerBet(&poker, second, 200);
|
|
|
|
|
pokerBetForPlayer(&poker, second, 200);
|
|
|
|
|
TEST_ASSERT_EQUAL(true, pokerPlayerDoesNeedToBetThisRound(&poker, first));
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, second));
|
|
|
|
|
|
|
|
|
|
pokerPlayerBet(&poker, first, 100);
|
|
|
|
|
pokerBetForPlayer(&poker, first, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, first));
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, second));
|
|
|
|
|
}
|
|
|
|
@ -613,11 +613,11 @@ void test_pokerPlayerDoesNeedToBetThisRound_should_CheckWhetherHasBetYet(void) {
|
|
|
|
|
TEST_ASSERT_EQUAL(true, pokerPlayerDoesNeedToBetThisRound(&poker, first));
|
|
|
|
|
TEST_ASSERT_EQUAL(true, pokerPlayerDoesNeedToBetThisRound(&poker, second));
|
|
|
|
|
|
|
|
|
|
pokerPlayerBet(&poker, first, 100);
|
|
|
|
|
pokerBetForPlayer(&poker, first, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, first));
|
|
|
|
|
TEST_ASSERT_EQUAL(true, pokerPlayerDoesNeedToBetThisRound(&poker, second));
|
|
|
|
|
|
|
|
|
|
pokerPlayerBet(&poker, second, 100);
|
|
|
|
|
pokerBetForPlayer(&poker, second, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, first));
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, second));
|
|
|
|
|
}
|
|
|
|
@ -634,7 +634,7 @@ void test_pokerPlayerDoesNeedToBetThisRound_should_IgnoreFoldedPlayers(void) {
|
|
|
|
|
TEST_ASSERT_EQUAL(true, pokerPlayerDoesNeedToBetThisRound(&poker, first));
|
|
|
|
|
TEST_ASSERT_EQUAL(true, pokerPlayerDoesNeedToBetThisRound(&poker, second));
|
|
|
|
|
|
|
|
|
|
pokerPlayerBet(&poker, first, 100);
|
|
|
|
|
pokerBetForPlayer(&poker, first, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, first));
|
|
|
|
|
TEST_ASSERT_EQUAL(true, pokerPlayerDoesNeedToBetThisRound(&poker, second));
|
|
|
|
|
|
|
|
|
@ -642,12 +642,12 @@ void test_pokerPlayerDoesNeedToBetThisRound_should_IgnoreFoldedPlayers(void) {
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, first));
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, second));
|
|
|
|
|
|
|
|
|
|
pokerPlayerBet(&poker, first, 100);
|
|
|
|
|
pokerBetForPlayer(&poker, first, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, first));
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, second));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_pokerPlayerGetRemainingBetter_should_ReturnRemainingBetters(void) {
|
|
|
|
|
void test_pokerBetGetRemainingPlayer_should_ReturnRemainingBetters(void) {
|
|
|
|
|
poker_t poker;
|
|
|
|
|
uint8_t p0, p1, p2, p3, p4;
|
|
|
|
|
pokerInit(&poker);
|
|
|
|
@ -664,46 +664,45 @@ void test_pokerPlayerGetRemainingBetter_should_ReturnRemainingBetters(void) {
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + p2, 10000);
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + p3, 10000);
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + p4, 10000);
|
|
|
|
|
pokerNewDealer(&poker);
|
|
|
|
|
pokerDealerNew(&poker);
|
|
|
|
|
|
|
|
|
|
// Blind + 1
|
|
|
|
|
TEST_ASSERT_EQUAL(0x04, pokerPlayerGetRemainingBetter(&poker));
|
|
|
|
|
TEST_ASSERT_EQUAL(0x04, pokerBetGetRemainingPlayer(&poker));
|
|
|
|
|
|
|
|
|
|
// Blind + 2
|
|
|
|
|
pokerPlayerBet(&poker, 0x04, pokerGetCallValue(&poker));
|
|
|
|
|
TEST_ASSERT_EQUAL(0x00, pokerPlayerGetRemainingBetter(&poker));
|
|
|
|
|
pokerBetForPlayer(&poker, 0x04, pokerGetCallValue(&poker));
|
|
|
|
|
TEST_ASSERT_EQUAL(0x00, pokerBetGetRemainingPlayer(&poker));
|
|
|
|
|
|
|
|
|
|
// Blind + 3
|
|
|
|
|
pokerPlayerBet(&poker, 0x00, pokerGetCallValue(&poker));
|
|
|
|
|
TEST_ASSERT_EQUAL(0x01, pokerPlayerGetRemainingBetter(&poker));
|
|
|
|
|
pokerBetForPlayer(&poker, 0x00, pokerGetCallValue(&poker));
|
|
|
|
|
TEST_ASSERT_EQUAL(0x01, pokerBetGetRemainingPlayer(&poker));
|
|
|
|
|
|
|
|
|
|
// Blind + 4 / Small Blind
|
|
|
|
|
pokerPlayerBet(&poker, 0x01, pokerGetCallValue(&poker));
|
|
|
|
|
TEST_ASSERT_EQUAL(0x02, pokerPlayerGetRemainingBetter(&poker));
|
|
|
|
|
pokerBetForPlayer(&poker, 0x01, pokerGetCallValue(&poker));
|
|
|
|
|
TEST_ASSERT_EQUAL(0x02, pokerBetGetRemainingPlayer(&poker));
|
|
|
|
|
|
|
|
|
|
// Blind + 5 / Big Blind
|
|
|
|
|
pokerPlayerBet(
|
|
|
|
|
pokerBetForPlayer(
|
|
|
|
|
&poker, 0x02, pokerGetCallValue(&poker) - poker.players[0x01].currentBet
|
|
|
|
|
);
|
|
|
|
|
TEST_ASSERT_EQUAL(0x03, pokerPlayerGetRemainingBetter(&poker));
|
|
|
|
|
TEST_ASSERT_EQUAL(0x03, pokerBetGetRemainingPlayer(&poker));
|
|
|
|
|
|
|
|
|
|
// No remaining players.
|
|
|
|
|
pokerPlayerBet(&poker, 0x03, 0);
|
|
|
|
|
TEST_ASSERT_EQUAL(0xFF, pokerPlayerGetRemainingBetter(&poker));
|
|
|
|
|
pokerBetForPlayer(&poker, 0x03, 0);
|
|
|
|
|
TEST_ASSERT_EQUAL(0xFF, pokerBetGetRemainingPlayer(&poker));
|
|
|
|
|
|
|
|
|
|
// Raise
|
|
|
|
|
pokerPlayerBet(&poker, 0x03, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL(0x04, pokerPlayerGetRemainingBetter(&poker));
|
|
|
|
|
pokerBetForPlayer(&poker, 0x03, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL(0x04, pokerBetGetRemainingPlayer(&poker));
|
|
|
|
|
|
|
|
|
|
// Raise
|
|
|
|
|
pokerPlayerBet(&poker, 0x04, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL(0x00, pokerPlayerGetRemainingBetter(&poker));
|
|
|
|
|
pokerBetForPlayer(&poker, 0x04, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL(0x00, pokerBetGetRemainingPlayer(&poker));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_pokerPlayerGetNextBetter_should_GetTheNextBetter(void) {
|
|
|
|
|
void test_pokerBetGetNextPlayer_should_GetTheNextBetter(void) {
|
|
|
|
|
poker_t poker;
|
|
|
|
|
uint8_t p0, p1, p2, p3, p4;
|
|
|
|
|
uint8_t better;
|
|
|
|
|
pokerInit(&poker);
|
|
|
|
|
|
|
|
|
|
p0 = pokerPlayerAdd(&poker);
|
|
|
|
@ -717,52 +716,54 @@ void test_pokerPlayerGetNextBetter_should_GetTheNextBetter(void) {
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + p2, 10000);
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + p3, 10000);
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + p4, 10000);
|
|
|
|
|
pokerNewDealer(&poker);
|
|
|
|
|
pokerDealerNew(&poker);
|
|
|
|
|
|
|
|
|
|
// Start at blind+1
|
|
|
|
|
better = poker.playerBigBlind;
|
|
|
|
|
better = pokerPlayerGetNextBetter(&poker, better);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x04, better);
|
|
|
|
|
poker.better = poker.playerBigBlind;
|
|
|
|
|
poker.better = pokerBetGetNextPlayer(&poker);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x04, poker.better);
|
|
|
|
|
|
|
|
|
|
// Blind+2
|
|
|
|
|
pokerPlayerBet(&poker, better, pokerGetCallValue(&poker));
|
|
|
|
|
better = pokerPlayerGetNextBetter(&poker, better);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x00, better);
|
|
|
|
|
pokerBetForPlayer(&poker, poker.better, pokerGetCallValue(&poker));
|
|
|
|
|
poker.better = pokerBetGetNextPlayer(&poker);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x00, poker.better);
|
|
|
|
|
|
|
|
|
|
// BLind+3
|
|
|
|
|
pokerPlayerBet(&poker, better, pokerGetCallValue(&poker));
|
|
|
|
|
better = pokerPlayerGetNextBetter(&poker, better);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x01, better);
|
|
|
|
|
pokerBetForPlayer(&poker, poker.better, pokerGetCallValue(&poker));
|
|
|
|
|
poker.better = pokerBetGetNextPlayer(&poker);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x01, poker.better);
|
|
|
|
|
|
|
|
|
|
// Dealer
|
|
|
|
|
pokerPlayerBet(&poker, better, pokerGetCallValue(&poker));
|
|
|
|
|
better = pokerPlayerGetNextBetter(&poker, better);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x02, better);
|
|
|
|
|
pokerBetForPlayer(&poker, poker.better, pokerGetCallValue(&poker));
|
|
|
|
|
poker.better = pokerBetGetNextPlayer(&poker);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x02, poker.better);
|
|
|
|
|
|
|
|
|
|
// Small blind
|
|
|
|
|
pokerPlayerBet(
|
|
|
|
|
&poker, better, pokerGetCallValue(&poker) - poker.players[0x02].currentBet
|
|
|
|
|
pokerBetForPlayer(
|
|
|
|
|
&poker, poker.better,
|
|
|
|
|
pokerGetCallValue(&poker) - poker.players[0x02].currentBet
|
|
|
|
|
);
|
|
|
|
|
better = pokerPlayerGetNextBetter(&poker, better);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x03, better);
|
|
|
|
|
poker.better = pokerBetGetNextPlayer(&poker);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x03, poker.better);
|
|
|
|
|
|
|
|
|
|
// Big Blind
|
|
|
|
|
pokerPlayerBet(
|
|
|
|
|
&poker, better, pokerGetCallValue(&poker) - poker.players[0x03].currentBet
|
|
|
|
|
pokerBetForPlayer(
|
|
|
|
|
&poker, poker.better,
|
|
|
|
|
pokerGetCallValue(&poker) - poker.players[0x03].currentBet
|
|
|
|
|
);
|
|
|
|
|
better = pokerPlayerGetNextBetter(&poker, better);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0xFF, better);
|
|
|
|
|
poker.better = pokerBetGetNextPlayer(&poker);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0xFF, poker.better);
|
|
|
|
|
|
|
|
|
|
// Raise
|
|
|
|
|
better = poker.playerBigBlind;
|
|
|
|
|
pokerPlayerBet(&poker, better, 100);
|
|
|
|
|
better = pokerPlayerGetNextBetter(&poker, better);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x04, better);
|
|
|
|
|
poker.better = poker.playerBigBlind;
|
|
|
|
|
pokerBetForPlayer(&poker, poker.better, 100);
|
|
|
|
|
poker.better = pokerBetGetNextPlayer(&poker);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x04, poker.better);
|
|
|
|
|
|
|
|
|
|
// Raise
|
|
|
|
|
pokerPlayerBet(&poker, better, 100);
|
|
|
|
|
better = pokerPlayerGetNextBetter(&poker, better);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x00, better);
|
|
|
|
|
pokerBetForPlayer(&poker, poker.better, 100);
|
|
|
|
|
poker.better = pokerBetGetNextPlayer(&poker);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x00, poker.better);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_pokerPlayerGetCallBet_should_GetCallBet(void) {
|
|
|
|
@ -774,17 +775,17 @@ void test_pokerPlayerGetCallBet_should_GetCallBet(void) {
|
|
|
|
|
p1 = pokerPlayerAdd(&poker);
|
|
|
|
|
p2 = pokerPlayerAdd(&poker);
|
|
|
|
|
|
|
|
|
|
pokerPlayerBet(&poker, p0, 100);
|
|
|
|
|
pokerBetForPlayer(&poker, p0, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(0, pokerPlayerGetCallBet(&poker,poker.players+p0));
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(100, pokerPlayerGetCallBet(&poker,poker.players+p1));
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(100, pokerPlayerGetCallBet(&poker,poker.players+p2));
|
|
|
|
|
|
|
|
|
|
pokerPlayerBet(&poker, p1, 200);
|
|
|
|
|
pokerBetForPlayer(&poker, p1, 200);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(100, pokerPlayerGetCallBet(&poker,poker.players+p0));
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(0, pokerPlayerGetCallBet(&poker,poker.players+p1));
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(200, pokerPlayerGetCallBet(&poker,poker.players+p2));
|
|
|
|
|
|
|
|
|
|
pokerPlayerBet(&poker, p2, 300);
|
|
|
|
|
pokerBetForPlayer(&poker, p2, 300);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(200, pokerPlayerGetCallBet(&poker,poker.players+p0));
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(100, pokerPlayerGetCallBet(&poker,poker.players+p1));
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(0, pokerPlayerGetCallBet(&poker,poker.players+p2));
|
|
|
|
@ -816,7 +817,7 @@ void test_pokerInRoundGetCount_should_ReturnCountOfPlayersInRound(void) {
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x00, pokerInRoundGetCount(&poker));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_pokerPlayerGetRemainintBetterCount_should_ReturnCountNeedsToBet(void){
|
|
|
|
|
void test_pokerBetGetRemainingPlayerCount_should_ReturnCountNeedsToBet(void){
|
|
|
|
|
poker_t poker;
|
|
|
|
|
uint8_t p0, p1, p2;
|
|
|
|
|
|
|
|
|
@ -825,24 +826,24 @@ void test_pokerPlayerGetRemainintBetterCount_should_ReturnCountNeedsToBet(void){
|
|
|
|
|
p1 = pokerPlayerAdd(&poker);
|
|
|
|
|
p2 = pokerPlayerAdd(&poker);
|
|
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x00, pokerPlayerGetRemainingBetterCount(&poker));
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x00, pokerBetGetRemainingPlayerCount(&poker));
|
|
|
|
|
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + p0, 1000);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x01, pokerPlayerGetRemainingBetterCount(&poker));
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x01, pokerBetGetRemainingPlayerCount(&poker));
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + p2, 1000);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x02, pokerPlayerGetRemainingBetterCount(&poker));
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x02, pokerBetGetRemainingPlayerCount(&poker));
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + p1, 1000);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x03, pokerPlayerGetRemainingBetterCount(&poker));
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x03, pokerBetGetRemainingPlayerCount(&poker));
|
|
|
|
|
|
|
|
|
|
poker.players[0].state |= POKER_PLAYER_STATE_FOLDED;
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x02, pokerPlayerGetRemainingBetterCount(&poker));
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x02, pokerBetGetRemainingPlayerCount(&poker));
|
|
|
|
|
poker.players[1].state |= POKER_PLAYER_STATE_HAS_BET_THIS_ROUND;
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x01, pokerPlayerGetRemainingBetterCount(&poker));
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x01, pokerBetGetRemainingPlayerCount(&poker));
|
|
|
|
|
poker.players[2].chips = 0;
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x00, pokerPlayerGetRemainingBetterCount(&poker));
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(0x00, pokerBetGetRemainingPlayerCount(&poker));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_pokerPlayerBetPot_should_AddChipsToThePot(void) {
|
|
|
|
|
void test_pokerBet_should_AddChipsToThePot(void) {
|
|
|
|
|
poker_t poker;
|
|
|
|
|
pokerpot_t *pot;
|
|
|
|
|
pokerplayer_t *player;
|
|
|
|
@ -857,12 +858,12 @@ void test_pokerPlayerBetPot_should_AddChipsToThePot(void) {
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(0, pot->chips);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(1000, player->chips);
|
|
|
|
|
|
|
|
|
|
pokerPlayerBetPot(&poker, pot, i, 100);
|
|
|
|
|
pokerBet(&poker, pot, i, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(100, pot->chips);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(900, player->chips);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_pokerPlayerBetPot_should_UpdatePlayerState(void) {
|
|
|
|
|
void test_pokerBet_should_UpdatePlayerState(void) {
|
|
|
|
|
poker_t poker;
|
|
|
|
|
uint8_t i;
|
|
|
|
|
pokerplayer_t *player;
|
|
|
|
@ -875,15 +876,15 @@ void test_pokerPlayerBetPot_should_UpdatePlayerState(void) {
|
|
|
|
|
TEST_ASSERT_BITS_LOW(POKER_PLAYER_STATE_HAS_BET_THIS_ROUND, player->state);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(0, player->currentBet);
|
|
|
|
|
|
|
|
|
|
pokerPlayerBetPot(&poker, poker.pots, i, 100);
|
|
|
|
|
pokerBet(&poker, poker.pots, i, 100);
|
|
|
|
|
TEST_ASSERT_BITS_HIGH(POKER_PLAYER_STATE_HAS_BET_THIS_ROUND, player->state);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(100, player->currentBet);
|
|
|
|
|
|
|
|
|
|
pokerPlayerBetPot(&poker, poker.pots, i, 250);
|
|
|
|
|
pokerBet(&poker, poker.pots, i, 250);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(350, player->currentBet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_pokerPlayerBet_should_BetToTheActivePot(void) {
|
|
|
|
|
void test_pokerBetForPlayer_should_BetToTheActivePot(void) {
|
|
|
|
|
poker_t poker;
|
|
|
|
|
pokerpot_t *pot;
|
|
|
|
|
uint8_t i, j;
|
|
|
|
@ -894,11 +895,11 @@ void test_pokerPlayerBet_should_BetToTheActivePot(void) {
|
|
|
|
|
pot = poker.pots;
|
|
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(0, pot->chips);
|
|
|
|
|
pokerPlayerBet(&poker, i, 100);
|
|
|
|
|
pokerBetForPlayer(&poker, i, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(100, pot->chips);
|
|
|
|
|
|
|
|
|
|
j = pokerPotAdd(&poker);
|
|
|
|
|
pokerPlayerBet(&poker, i, 50);
|
|
|
|
|
pokerBetForPlayer(&poker, i, 50);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(100, pot->chips);
|
|
|
|
|
pot = poker.pots + j;
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(50, pot->chips);
|
|
|
|
@ -916,27 +917,27 @@ void test_pokerPlayerCanCheck_should_CompareThePotAndPlayerBet(void) {
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + p1, 1000);
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + p2, 1000);
|
|
|
|
|
|
|
|
|
|
pokerPlayerBet(&poker, p0, 100);
|
|
|
|
|
pokerBetForPlayer(&poker, p0, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p0));
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerCanCheck(&poker, poker.players+p1));
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerCanCheck(&poker, poker.players+p2));
|
|
|
|
|
|
|
|
|
|
pokerPlayerBet(&poker, p1, 100);
|
|
|
|
|
pokerBetForPlayer(&poker, p1, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p0));
|
|
|
|
|
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p1));
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerCanCheck(&poker, poker.players+p2));
|
|
|
|
|
|
|
|
|
|
pokerPlayerBet(&poker, p2, 100);
|
|
|
|
|
pokerBetForPlayer(&poker, p2, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p0));
|
|
|
|
|
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p1));
|
|
|
|
|
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p2));
|
|
|
|
|
|
|
|
|
|
pokerPlayerBet(&poker, p2, 100);
|
|
|
|
|
pokerBetForPlayer(&poker, p2, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerCanCheck(&poker, poker.players+p0));
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerCanCheck(&poker, poker.players+p1));
|
|
|
|
|
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p2));
|
|
|
|
|
|
|
|
|
|
pokerPlayerBet(&poker, p1, 100);
|
|
|
|
|
pokerBetForPlayer(&poker, p1, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL(false, pokerPlayerCanCheck(&poker, poker.players+p0));
|
|
|
|
|
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p1));
|
|
|
|
|
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p2));
|
|
|
|
@ -992,15 +993,15 @@ void test_pokerTurnBet_should_ReturnACallAction(void) {
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 1000);
|
|
|
|
|
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 1000);
|
|
|
|
|
|
|
|
|
|
pokerPlayerBet(&poker, 0, 300);
|
|
|
|
|
pokerPlayerBet(&poker, 1, 500);
|
|
|
|
|
pokerBetForPlayer(&poker, 0, 300);
|
|
|
|
|
pokerBetForPlayer(&poker, 1, 500);
|
|
|
|
|
|
|
|
|
|
turn = pokerTurnBet(&poker, 0x00, 200);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(200, turn.chips);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(POKER_TURN_TYPE_CALL, turn.type);
|
|
|
|
|
TEST_ASSERT_EQUAL_FLOAT(1.0f, turn.confidence);
|
|
|
|
|
|
|
|
|
|
pokerPlayerBet(&poker, 0, 300);
|
|
|
|
|
pokerBetForPlayer(&poker, 0, 300);
|
|
|
|
|
turn = pokerTurnBet(&poker, 0x01, 100);
|
|
|
|
|
TEST_ASSERT_EQUAL_INT32(100, turn.chips);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(POKER_TURN_TYPE_CALL, turn.type);
|
|
|
|
@ -1034,11 +1035,11 @@ void test_pokerHandGetFull_should_ReturnTheFullHand(void) {
|
|
|
|
|
i = pokerPlayerAdd(&poker);
|
|
|
|
|
player = poker.players + i;
|
|
|
|
|
|
|
|
|
|
pokerPlayerDeal(&poker, player, POKER_PLAYER_HAND_SIZE_MAX);
|
|
|
|
|
pokerDeal(&poker, player, POKER_PLAYER_HAND_SIZE_MAX);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_ACE, player->cards[0]);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_KING, player->cards[1]);
|
|
|
|
|
|
|
|
|
|
pokerTurn(&poker, POKER_COMMUNITY_SIZE_MAX);
|
|
|
|
|
pokerDealerTurn(&poker, POKER_COMMUNITY_SIZE_MAX);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_QUEEN, poker.community[0]);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_JACK, poker.community[1]);
|
|
|
|
|
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_TEN, poker.community[2]);
|
|
|
|
@ -1593,35 +1594,33 @@ int test_poker() {
|
|
|
|
|
RUN_TEST(test_pokerPotAdd_should_AddAPot);
|
|
|
|
|
RUN_TEST(test_pokerPotAdd_should_ResetThePot);
|
|
|
|
|
RUN_TEST(test_pokerPotHasPlayer_should_DetermineIfPlayerInThePot);
|
|
|
|
|
RUN_TEST(test_pokerNewDealer_should_FindANewDealer);
|
|
|
|
|
RUN_TEST(test_pokerSetDealer_should_SetANewSetOfPlayers);
|
|
|
|
|
RUN_TEST(test_pokerSetDealer_should_SkipOutPlayers);
|
|
|
|
|
RUN_TEST(test_pokerDealerNew_should_FindANewDealer);
|
|
|
|
|
RUN_TEST(test_pokerDealerSet_should_SetANewSetOfPlayers);
|
|
|
|
|
RUN_TEST(test_pokerDealerSet_should_SkipOutPlayers);
|
|
|
|
|
RUN_TEST(test_pokerTakeBlinds_should_TakeTheBlinds);
|
|
|
|
|
RUN_TEST(test_pokerPotAddPlayer_should_AddAPlayer);
|
|
|
|
|
RUN_TEST(test_pokerPlayerAdd_should_ResetThePlayer);
|
|
|
|
|
RUN_TEST(test_pokerTurn_should_TurnCardsFromTheDeck);
|
|
|
|
|
RUN_TEST(test_pokerBurn_should_SendCardsToTheGrave);
|
|
|
|
|
RUN_TEST(test_pokerDealerTurn_should_TurnCardsFromTheDeck);
|
|
|
|
|
RUN_TEST(test_pokerDealerBurn_should_SendCardsToTheGrave);
|
|
|
|
|
RUN_TEST(test_pokerGetCallValue_should_CalculateTheCallValue);
|
|
|
|
|
RUN_TEST(test_pokerPlayerDeal_should_DealCardsToThePlayer);
|
|
|
|
|
RUN_TEST(test_pokerDeal_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);
|
|
|
|
|
RUN_TEST(test_pokerPlayerDealAll_should_NotDealToOutPlayers);
|
|
|
|
|
RUN_TEST(test_pokerPlayerDealAll_should_NotDealToFoldedPlayers);
|
|
|
|
|
RUN_TEST(test_pokerDealAllPlayers_should_DealCardsToEveryone);
|
|
|
|
|
RUN_TEST(test_pokerDealAllPlayers_should_DealMultipleCardsToEveryone);
|
|
|
|
|
RUN_TEST(test_pokerDealAllPlayers_should_NotDealToOutPlayers);
|
|
|
|
|
RUN_TEST(test_pokerDealAllPlayers_should_NotDealToFoldedPlayers);
|
|
|
|
|
RUN_TEST(test_pokerPlayerDoesNeedToBetThisRound_should_CheckCallValue);
|
|
|
|
|
RUN_TEST(test_pokerPlayerDoesNeedToBetThisRound_should_CheckWhetherHasBetYet);
|
|
|
|
|
RUN_TEST(test_pokerPlayerDoesNeedToBetThisRound_should_IgnoreFoldedPlayers);
|
|
|
|
|
RUN_TEST(test_pokerPlayerGetRemainingBetter_should_ReturnRemainingBetters);
|
|
|
|
|
RUN_TEST(test_pokerPlayerGetNextBetter_should_GetTheNextBetter);
|
|
|
|
|
RUN_TEST(test_pokerBetGetRemainingPlayer_should_ReturnRemainingBetters);
|
|
|
|
|
RUN_TEST(test_pokerBetGetNextPlayer_should_GetTheNextBetter);
|
|
|
|
|
RUN_TEST(test_pokerPlayerGetCallBet_should_GetCallBet);
|
|
|
|
|
RUN_TEST(test_pokerInRoundGetCount_should_ReturnCountOfPlayersInRound);
|
|
|
|
|
RUN_TEST(
|
|
|
|
|
test_pokerPlayerGetRemainintBetterCount_should_ReturnCountNeedsToBet
|
|
|
|
|
);
|
|
|
|
|
RUN_TEST(test_pokerPlayerBetPot_should_AddChipsToThePot);
|
|
|
|
|
RUN_TEST(test_pokerPlayerBetPot_should_UpdatePlayerState);
|
|
|
|
|
RUN_TEST(test_pokerPlayerBet_should_BetToTheActivePot);
|
|
|
|
|
RUN_TEST(test_pokerBetGetRemainingPlayerCount_should_ReturnCountNeedsToBet);
|
|
|
|
|
RUN_TEST(test_pokerBet_should_AddChipsToThePot);
|
|
|
|
|
RUN_TEST(test_pokerBet_should_UpdatePlayerState);
|
|
|
|
|
RUN_TEST(test_pokerBetForPlayer_should_BetToTheActivePot);
|
|
|
|
|
RUN_TEST(test_pokerPlayerCanCheck_should_CompareThePotAndPlayerBet);
|
|
|
|
|
RUN_TEST(test_pokerTurnFold_should_ReturnAFoldAction);
|
|
|
|
|
RUN_TEST(test_pokerTurnBet_should_ReturnACheckAction);
|
|
|
|
|