From b7347b1dc0ea2629fd57c9bf22ab963e303cd81a Mon Sep 17 00:00:00 2001 From: fdai7775 Date: Fri, 2 Feb 2024 12:08:42 +0000 Subject: [PATCH] Test horizontaler Gewinner --- test/test_tictactoe.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/test/test_tictactoe.c b/test/test_tictactoe.c index 0609053..fdca226 100644 --- a/test/test_tictactoe.c +++ b/test/test_tictactoe.c @@ -34,19 +34,6 @@ void test_if_identical(void){ TEST_ASSERT_EQUAL_CHAR(a, result); } -void test_checkLine_horizontalerGewinner(void) { - /* arrange */ - char result; - char a = 'X', b = 'X', c = 'X'; - - /* assert */ - result = checkLine(a, b, c); - - /* überprüfen */ - TEST_ASSERT_EQUAL_CHAR('X', result); -} - - void test_isValidMove_gueltigerZug(void) { /* arrangieren */ int result; @@ -84,4 +71,28 @@ void test_checkWinner_vertikalerGewinner(void) { TEST_ASSERT_EQUAL_CHAR('O', result); } +void test_checkWinner_horizontalerGewinner(void) { + /* arrangieren */ + char result; + char board[3][3]; + + // Initialisiere das Spielfeld + for (int i = 0; i < BOARD_SIZE; i++) { + for (int j = 0; j < BOARD_SIZE; j++) { + board[i][j] = (char)('1' + i * BOARD_SIZE + j); + } + } + + // Setze die Daten für einen horizontalen Gewinner + board[0][0] = 'X'; + board[0][1] = 'X'; + board[0][2] = 'X'; + + /* handeln */ + result = checkWinner(); + + /* überprüfen */ + TEST_ASSERT_EQUAL_CHAR('X', result); +} + #endif // TEST