Wrote some tests

This commit is contained in:
2021-10-01 00:50:27 -07:00
parent 2c1863d5df
commit 53fee3b47e
3 changed files with 61 additions and 30 deletions

View File

@ -1,6 +1,6 @@
name: build
on:
pull_request:
push:
branches: [ master ]
jobs:
build:

View File

@ -1,27 +0,0 @@
// Copyright (c) 2021 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
# pragma once
// Target Settings
#cmakedefine SETTING_TARGET_WIN32 @SETTING_TARGET_WIN32@
#cmakedefine SETTING_TARGET @SETTING_TARGET@
// Platform Settings
#cmakedefine SETTING_PLATFORM_GLFW @SETTING_PLATFORM_GLFW@
#cmakedefine SETTING_PLATFORM @SETTING_PLATFORM@
// Additional settings
#cmakedefine SETTING_ASSET_PREFIX "@SETTING_ASSET_PREFIX@"
// Game Settings
#cmakedefine SETTING_GAME_POKER @SETTING_GAME_POKER@
#cmakedefine SETTING_GAME_DAWN @SETTING_GAME_DAWN@
#cmakedefine SETTING_GAME_SANDBOX @SETTING_GAME_SANDBOX@
#cmakedefine SETTING_GAME @SETTING_GAME@
#cmakedefine SETTING_GAME_NAME "@SETTING_GAME_NAME@"

View File

@ -14,7 +14,61 @@ void setUp(void) {
void tearDown(void) {
}
void test_cardWriteDeck_should_WriteCardsToArray() {
void test_cardGetSuit_should_ReturnCardsSuit(void) {
TEST_ASSERT_EQUAL_UINT8(CARD_SUIT_CLUBS, cardGetSuit(CARD_CLUBS_ACE));
TEST_ASSERT_EQUAL_UINT8(CARD_SUIT_CLUBS, cardGetSuit(CARD_CLUBS_TWO));
TEST_ASSERT_EQUAL_UINT8(CARD_SUIT_CLUBS, cardGetSuit(CARD_CLUBS_KING));
TEST_ASSERT_EQUAL_UINT8(CARD_SUIT_HEARTS, cardGetSuit(CARD_HEARTS_QUEEN));
TEST_ASSERT_EQUAL_UINT8(CARD_SUIT_HEARTS, cardGetSuit(CARD_HEARTS_TWO));
TEST_ASSERT_EQUAL_UINT8(CARD_SUIT_HEARTS, cardGetSuit(CARD_HEARTS_SEVEN));
TEST_ASSERT_EQUAL_UINT8(CARD_SUIT_SPADES, cardGetSuit(CARD_SPADES_TWO));
TEST_ASSERT_EQUAL_UINT8(CARD_SUIT_SPADES, cardGetSuit(CARD_SPADES_ACE));
TEST_ASSERT_EQUAL_UINT8(CARD_SUIT_DIAMONDS, cardGetSuit(CARD_DIAMONDS_ACE));
}
void test_cardGetNumber_should_ReturnCardsNumber(void) {
TEST_ASSERT_EQUAL_UINT8(CARD_ACE, cardGetNumber(CARD_CLUBS_ACE));
TEST_ASSERT_EQUAL_UINT8(CARD_TWO, cardGetNumber(CARD_CLUBS_TWO));
TEST_ASSERT_EQUAL_UINT8(CARD_KING, cardGetNumber(CARD_CLUBS_KING));
TEST_ASSERT_EQUAL_UINT8(CARD_QUEEN, cardGetNumber(CARD_HEARTS_QUEEN));
TEST_ASSERT_EQUAL_UINT8(CARD_TWO, cardGetNumber(CARD_HEARTS_TWO));
TEST_ASSERT_EQUAL_UINT8(CARD_SEVEN, cardGetNumber(CARD_HEARTS_SEVEN));
TEST_ASSERT_EQUAL_UINT8(CARD_TWO, cardGetNumber(CARD_SPADES_TWO));
TEST_ASSERT_EQUAL_UINT8(CARD_ACE, cardGetNumber(CARD_SPADES_ACE));
TEST_ASSERT_EQUAL_UINT8(CARD_ACE, cardGetNumber(CARD_DIAMONDS_ACE));
}
void test_cardGet_should_ReturnTheCard(void) {
TEST_ASSERT_EQUAL_UINT8(CARD_CLUBS_ACE, cardGet(CARD_ACE, CARD_SUIT_CLUBS));
TEST_ASSERT_EQUAL_UINT8(CARD_CLUBS_TWO, cardGet(CARD_TWO, CARD_SUIT_CLUBS));
TEST_ASSERT_EQUAL_UINT8(CARD_CLUBS_KING, cardGet(CARD_KING, CARD_SUIT_CLUBS));
TEST_ASSERT_EQUAL_UINT8(
CARD_HEARTS_QUEEN, cardGet(CARD_QUEEN, CARD_SUIT_HEARTS)
);
TEST_ASSERT_EQUAL_UINT8(
CARD_HEARTS_TWO, cardGet(CARD_TWO, CARD_SUIT_HEARTS)
);
TEST_ASSERT_EQUAL_UINT8(
CARD_HEARTS_SEVEN, cardGet(CARD_SEVEN, CARD_SUIT_HEARTS)
);
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_TWO, cardGet(CARD_TWO, CARD_SUIT_SPADES));
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_ACE, cardGet(CARD_ACE, CARD_SUIT_SPADES));
TEST_ASSERT_EQUAL_UINT8(
CARD_DIAMONDS_ACE, cardGet(CARD_ACE, CARD_SUIT_DIAMONDS)
);
}
void test_cardWriteDeck_should_WriteCardsToArray(void) {
card_t cards[CARD_DECK_SIZE];
cardWriteDeck(cards);
@ -30,7 +84,7 @@ void test_cardWriteDeck_should_WriteCardsToArray() {
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_ACE, cards[51]);
}
void test_cardWriteDeck_should_ReturnCardsWritten() {
void test_cardWriteDeck_should_ReturnCardsWritten(void) {
card_t cards[CARD_DECK_SIZE];
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE, cardWriteDeck(cards));
}
@ -38,6 +92,10 @@ void test_cardWriteDeck_should_ReturnCardsWritten() {
int main() {
UNITY_BEGIN();
RUN_TEST(test_cardGetSuit_should_ReturnCardsSuit);
RUN_TEST(test_cardGetNumber_should_ReturnCardsNumber);
RUN_TEST(test_cardGet_should_ReturnTheCard);
RUN_TEST(test_cardWriteDeck_should_WriteCardsToArray);
RUN_TEST(test_cardWriteDeck_should_ReturnCardsWritten);