Fixed test dir.
This commit is contained in:
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -28,4 +28,4 @@ jobs:
|
|||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: |
|
run: |
|
||||||
./build/bin/tests
|
./build/test/tests
|
@ -31,7 +31,7 @@ uint8_t pokerPotAdd(poker2_t *poker) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void pokerPotAddPlayer(poker2pot_t *pot, uint8_t playerIndex) {
|
void pokerPotAddPlayer(poker2pot_t *pot, uint8_t playerIndex) {
|
||||||
if(!arrayContains(
|
if(arrayContains(
|
||||||
sizeof(uint8_t), pot->players, pot->playerCount, &playerIndex
|
sizeof(uint8_t), pot->players, pot->playerCount, &playerIndex
|
||||||
)) return;
|
)) return;
|
||||||
pot->players[pot->playerCount++] = playerIndex;
|
pot->players[pot->playerCount++] = playerIndex;
|
||||||
|
@ -3,4 +3,4 @@ file(GLOB_RECURSE SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.c)
|
|||||||
add_executable(tests ${SRCS})
|
add_executable(tests ${SRCS})
|
||||||
target_link_libraries(tests game unity)
|
target_link_libraries(tests game unity)
|
||||||
|
|
||||||
add_test(card tests)
|
add_test(tests tests)
|
@ -5,8 +5,7 @@
|
|||||||
* https://opensource.org/licenses/MIT
|
* https://opensource.org/licenses/MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <unity.h>
|
#include "card.h"
|
||||||
#include <poker/card.h>
|
|
||||||
|
|
||||||
void setUp(void) {
|
void setUp(void) {
|
||||||
}
|
}
|
||||||
@ -239,7 +238,7 @@ void test_cardWriteDeck_should_ReturnCardsWritten(void) {
|
|||||||
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE, cardWriteDeck(cards));
|
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE, cardWriteDeck(cards));
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int test_card() {
|
||||||
UNITY_BEGIN();
|
UNITY_BEGIN();
|
||||||
|
|
||||||
RUN_TEST(test_cardGetSuit_should_ReturnCardsSuit);
|
RUN_TEST(test_cardGetSuit_should_ReturnCardsSuit);
|
10
test/poker/card.h
Normal file
10
test/poker/card.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// Copyright (c) 2021 Dominic Masters
|
||||||
|
//
|
||||||
|
// This software is released under the MIT License.
|
||||||
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <unity.h>
|
||||||
|
#include <poker/card.h>
|
||||||
|
|
||||||
|
int test_card();
|
107
test/poker2/poker.c
Normal file
107
test/poker2/poker.c
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
}
|
10
test/poker2/poker.h
Normal file
10
test/poker2/poker.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// Copyright (c) 2021 Dominic Masters
|
||||||
|
//
|
||||||
|
// This software is released under the MIT License.
|
||||||
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <unity.h>
|
||||||
|
#include <poker2/poker.h>
|
||||||
|
|
||||||
|
int test_poker2();
|
16
test/tests.c
Normal file
16
test/tests.c
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2021 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "poker/card.h"
|
||||||
|
#include "poker/poker.h"
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
return (
|
||||||
|
!test_card() &&
|
||||||
|
!test_poker2()
|
||||||
|
);
|
||||||
|
}
|
Reference in New Issue
Block a user