From 1cee089f5eba1a6e7b7fa15fd45eaa9b52a69b25 Mon Sep 17 00:00:00 2001 From: Habib Date: Wed, 7 Feb 2024 03:02:48 +0100 Subject: [PATCH] =?UTF-8?q?x=5Fwins=5F00=5F11=5F22()=20definiert=20und=20e?= =?UTF-8?q?inen=20Test=20f=C3=BCr=20die=20Funktion=20erstellt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/funktionen.c | 6 ++++++ src/test/test_funktionen.c | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/c/funktionen.c b/src/c/funktionen.c index 9ac25d1..63a8976 100644 --- a/src/c/funktionen.c +++ b/src/c/funktionen.c @@ -79,6 +79,12 @@ int x_wins_20_21_22(char board[][3]) { } } +int x_wins_00_11_22(char board[][3]) { + if (board[0][0] == 'X' && board[1][1] == 'X' && board[2][2] == 'X') { + return 1; + } +} + int string_character_counter(char string[]) { int stringLength = 0; diff --git a/src/test/test_funktionen.c b/src/test/test_funktionen.c index 640ac1b..288590c 100644 --- a/src/test/test_funktionen.c +++ b/src/test/test_funktionen.c @@ -166,6 +166,21 @@ void test_x_wins_onIndex_20_21_22(void) TEST_ASSERT_EQUAL_INT(expected, actual); } +void test_x_wins_onIndex_00_11_22(void) +{ + /* arrange */ + int actual; + int expected = 1; + + char board[][3] = {{'X',' ',' '}, {' ','X',' '}, {' ',' ','X'}}; + + /* act */ + actual = x_wins_00_11_22(board); + + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} + void test_stringLaenge_von_Kokosnuss(void) { /* arrange */