Split turn tests out.
This commit is contained in:
102
test/poker/turn.c
Normal file
102
test/poker/turn.c
Normal file
@ -0,0 +1,102 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "turn.h"
|
||||
|
||||
void test_pokerTurnFold_should_ReturnAFoldAction(void) {
|
||||
poker_t poker;
|
||||
pokerturn_t turn;
|
||||
pokerInit(&poker);
|
||||
pokerPlayerAdd(&poker);
|
||||
|
||||
turn = pokerTurnFold(&poker, 0x00);
|
||||
TEST_ASSERT_EQUAL_INT32(0, turn.chips);
|
||||
TEST_ASSERT_EQUAL_UINT8(POKER_TURN_TYPE_FOLD, turn.type);
|
||||
TEST_ASSERT_EQUAL_FLOAT(1.0f, turn.confidence);
|
||||
}
|
||||
|
||||
void test_pokerTurnBet_should_ReturnACheckAction(void) {
|
||||
poker_t poker;
|
||||
pokerturn_t turn;
|
||||
pokerInit(&poker);
|
||||
pokerPlayerAdd(&poker);
|
||||
|
||||
turn = pokerTurnBet(&poker, 0x00, 0);
|
||||
TEST_ASSERT_EQUAL_INT32(0, turn.chips);
|
||||
TEST_ASSERT_EQUAL_UINT8(POKER_TURN_TYPE_CHECK, turn.type);
|
||||
TEST_ASSERT_EQUAL_FLOAT(1.0f, turn.confidence);
|
||||
}
|
||||
|
||||
void test_pokerTurnBet_should_ReturnAnAllInAction(void) {
|
||||
poker_t poker;
|
||||
pokerturn_t turn;
|
||||
pokerInit(&poker);
|
||||
pokerPlayerAdd(&poker);
|
||||
pokerPlayerChipsAdd(poker.players, 500);
|
||||
|
||||
turn = pokerTurnBet(&poker, 0x00, 500);
|
||||
TEST_ASSERT_EQUAL_INT32(500, turn.chips);
|
||||
TEST_ASSERT_EQUAL_UINT8(POKER_TURN_TYPE_ALL_IN, turn.type);
|
||||
TEST_ASSERT_EQUAL_FLOAT(1.0f, turn.confidence);
|
||||
|
||||
pokerPlayerChipsAdd(poker.players, 500);
|
||||
turn = pokerTurnBet(&poker, 0x00, 1001);
|
||||
TEST_ASSERT_EQUAL_INT32(1000, turn.chips);
|
||||
TEST_ASSERT_EQUAL_UINT8(POKER_TURN_TYPE_ALL_IN, turn.type);
|
||||
TEST_ASSERT_EQUAL_FLOAT(1.0f, turn.confidence);
|
||||
}
|
||||
|
||||
void test_pokerTurnBet_should_ReturnACallAction(void) {
|
||||
poker_t poker;
|
||||
pokerturn_t turn;
|
||||
pokerInit(&poker);
|
||||
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 1000);
|
||||
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 1000);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
TEST_ASSERT_EQUAL_FLOAT(1.0f, turn.confidence);
|
||||
}
|
||||
|
||||
void test_pokerTurnBet_should_ReturnARaiseAction(void) {
|
||||
poker_t poker;
|
||||
pokerturn_t turn;
|
||||
pokerInit(&poker);
|
||||
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 1000);
|
||||
|
||||
turn = pokerTurnBet(&poker, 0x00, 300);
|
||||
TEST_ASSERT_EQUAL_INT32(300, turn.chips);
|
||||
TEST_ASSERT_EQUAL_UINT8(POKER_TURN_TYPE_BET, turn.type);
|
||||
TEST_ASSERT_EQUAL_FLOAT(1.0f, turn.confidence);
|
||||
|
||||
turn = pokerTurnBet(&poker, 0x00, 200);
|
||||
TEST_ASSERT_EQUAL_INT32(200, turn.chips);
|
||||
TEST_ASSERT_EQUAL_UINT8(POKER_TURN_TYPE_BET, turn.type);
|
||||
TEST_ASSERT_EQUAL_FLOAT(1.0f, turn.confidence);
|
||||
}
|
||||
|
||||
int test_turn_h() {
|
||||
UNITY_BEGIN();
|
||||
|
||||
RUN_TEST(test_pokerTurnFold_should_ReturnAFoldAction);
|
||||
RUN_TEST(test_pokerTurnBet_should_ReturnACheckAction);
|
||||
RUN_TEST(test_pokerTurnBet_should_ReturnAnAllInAction);
|
||||
RUN_TEST(test_pokerTurnBet_should_ReturnACallAction);
|
||||
RUN_TEST(test_pokerTurnBet_should_ReturnARaiseAction);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
Reference in New Issue
Block a user