From 57dd871368486ae4333e60036932b81759b029e5 Mon Sep 17 00:00:00 2001 From: fdai7775 Date: Fri, 2 Feb 2024 13:06:30 +0000 Subject: [PATCH] Test fixed test_checkWinner --- src/main/c/GameTic_Tac_Toe/tictactoe.c | 6 ++++++ src/main/c/GameTic_Tac_Toe/tictactoe.h | 1 + test/test_tictactoe.c | 3 +++ 3 files changed, 10 insertions(+) diff --git a/src/main/c/GameTic_Tac_Toe/tictactoe.c b/src/main/c/GameTic_Tac_Toe/tictactoe.c index e15cf80..84a2430 100644 --- a/src/main/c/GameTic_Tac_Toe/tictactoe.c +++ b/src/main/c/GameTic_Tac_Toe/tictactoe.c @@ -8,6 +8,12 @@ char currentPlayer = 'X'; const char PLAYER_X = 'X'; const char PLAYER_O = 'O'; +void reset_board(){ + board[3][3] = {{'1', '2', '3'}, + {'4', '5', '6'}, + {'7', '8', '9'}}; +} + // Funktionen zur Anzeige des Spielbretts void displayBoard() { printf("Tic-Tac-Toe\n"); diff --git a/src/main/c/GameTic_Tac_Toe/tictactoe.h b/src/main/c/GameTic_Tac_Toe/tictactoe.h index 89d5ab9..d007eb4 100644 --- a/src/main/c/GameTic_Tac_Toe/tictactoe.h +++ b/src/main/c/GameTic_Tac_Toe/tictactoe.h @@ -9,5 +9,6 @@ void start_tictactoe(); char checkWinner(); void makeMove(int choice); void displayBoard(); +void reset_board(); #endif diff --git a/test/test_tictactoe.c b/test/test_tictactoe.c index b72d780..a74a3da 100644 --- a/test/test_tictactoe.c +++ b/test/test_tictactoe.c @@ -8,6 +8,7 @@ void setUp(void){ //Wenn Funktion Vorraussetzungen braucht } void tearDown(void){ + printf("1\n"); } @@ -65,6 +66,7 @@ void test_checkWinner_vertikalerGewinner(void) { /* überprüfen */ TEST_ASSERT_EQUAL_CHAR('O', result); + reset_board(); } void test_checkWinner_horizontalerGewinner(void) { @@ -84,6 +86,7 @@ void test_checkWinner_horizontalerGewinner(void) { /* überprüfen */ TEST_ASSERT_EQUAL_CHAR('X', result); + reset_board() } #endif // TEST