From 66aba9dc6824828334ed76d3256d942ff5143fed Mon Sep 17 00:00:00 2001 From: KaffeeMaus Date: Fri, 26 Jan 2024 11:33:39 +0100 Subject: [PATCH] added a test case for the command by id caller --- src/main/c/Georg/tictactoe.h | 1 + src/test/c/Georg/test_tictactoe.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/main/c/Georg/tictactoe.h b/src/main/c/Georg/tictactoe.h index 077ef48..19f2f6e 100644 --- a/src/main/c/Georg/tictactoe.h +++ b/src/main/c/Georg/tictactoe.h @@ -21,6 +21,7 @@ int handleCommand( char* input ); struct command* createCommands(); /* commands */ +commandFunction getCommandById(struct command* commands, int id); int startMenu(); int startGame(); diff --git a/src/test/c/Georg/test_tictactoe.c b/src/test/c/Georg/test_tictactoe.c index fa1e452..7e40ecc 100644 --- a/src/test/c/Georg/test_tictactoe.c +++ b/src/test/c/Georg/test_tictactoe.c @@ -86,4 +86,16 @@ void test_createCommandlist(void){ for (size_t i = 0; i < arraySize; i++) { TEST_ASSERT_EQUAL_INT( 1, commands[i].fun() ); } +} + +void test_callCommandById(void){ + // arrange + struct command* commands = NULL; + + // act + commands = createCommands(); + commandFunction actualCommand = getCommandById( commands, 1); + + // assert + TEST_ASSERT_EQUAL_PTR( startMenu, actualCommand ); } \ No newline at end of file