/** * Copyright (c) 2021 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #include "poker.h" void test_pokerInit_should_InitializePokerGame(void) { poker2_t poker; pokerInit(&poker); TEST_ASSERT_EQUAL_INT8(0, poker.playerCount); } void test_pokerResetRound_should_ResetTheRound(void) { poker2_t poker; pokerInit(&poker); poker.potCount = 0x03; poker.graveSize = 0x10; poker.communitySize = 0x03; poker.deckSize = 0x0; pokerResetRound(&poker); TEST_ASSERT_NOT_EQUAL_UINT8(0, poker.deckSize); TEST_ASSERT_EQUAL_UINT8(0, poker.graveSize); TEST_ASSERT_EQUAL_UINT8(0, poker.communitySize); TEST_ASSERT_EQUAL_UINT8(1, poker.potCount); } void test_pokerPotAdd_should_AddAPot(void) { poker2_t poker; pokerInit(&poker); TEST_ASSERT_EQUAL_UINT8(1, poker.potCount); TEST_ASSERT_EQUAL_UINT8(1, pokerPotAdd(&poker)); TEST_ASSERT_EQUAL_UINT8(2, poker.potCount); } void test_pokerPotAdd_should_ResetThePot(void) { poker2_t poker; poker2pot_t *pot; uint8_t i; pokerInit(&poker); i = pokerPotAdd(&poker); pot = poker.pots + i; TEST_ASSERT_EQUAL_UINT8(0, pot->playerCount); TEST_ASSERT_EQUAL_INT32(0, pot->chips); } void test_pokerPotAddPlayer_should_AddAPlayer(void) { poker2_t poker; poker2pot_t *pot; pokerInit(&poker); pokerPlayerAdd(&poker); pokerPlayerAdd(&poker); pot = poker.pots + 0; TEST_ASSERT_EQUAL_UINT8(0, pot->playerCount); pokerPotAddPlayer(pot, 1); TEST_ASSERT_EQUAL_UINT8(1, pot->playerCount); TEST_ASSERT_EQUAL_UINT8(0x01, pot->players[0]); pokerPotAddPlayer(pot, 0); TEST_ASSERT_EQUAL_UINT8(2, pot->playerCount); TEST_ASSERT_EQUAL_UINT8(0x00, pot->players[1]); } void test_pokerPlayerAdd_should_AddAPlayer(void) { poker2_t poker; pokerInit(&poker); TEST_ASSERT_EQUAL_UINT8(0, poker.playerCount); TEST_ASSERT_EQUAL(0, pokerPlayerAdd(&poker)); TEST_ASSERT_EQUAL_UINT8(1, poker.playerCount); TEST_ASSERT_EQUAL(1, pokerPlayerAdd(&poker)); TEST_ASSERT_EQUAL_UINT8(2, poker.playerCount); } void test_pokerPlayerAdd_should_ResetThePlayer(void) { poker2_t poker; poker2player_t *player; pokerInit(&poker); player = poker.players + pokerPlayerAdd(&poker); TEST_ASSERT_EQUAL_INT32(0, player->chips); TEST_ASSERT_EQUAL_UINT8(0, player->state); TEST_ASSERT_EQUAL_UINT8(0, player->cardCount); } int test_poker2() { UNITY_BEGIN(); RUN_TEST(test_pokerInit_should_InitializePokerGame); RUN_TEST(test_pokerResetRound_should_ResetTheRound); RUN_TEST(test_pokerPotAdd_should_AddAPot); RUN_TEST(test_pokerPotAdd_should_ResetThePot); RUN_TEST(test_pokerPotAddPlayer_should_AddAPlayer); RUN_TEST(test_pokerPlayerAdd_should_ResetThePlayer); return UNITY_END(); }