From 65abd7a8fab4960919dba625bc0033859c90915e Mon Sep 17 00:00:00 2001 From: Habib Date: Sun, 4 Feb 2024 16:39:28 +0100 Subject: [PATCH] =?UTF-8?q?(=C3=84nderung=20an=20Unittest-Code=20und=20Pro?= =?UTF-8?q?duktiv-Code=20im=20selben=20Commit,=20wie=20von=20dem=20Herrn?= =?UTF-8?q?=20Papendieck=20erw=C3=BCnscht)=20x=5Fwins=5F01=5F11=5F21()=20d?= =?UTF-8?q?efiniert=20und=20einen=20Test=20f=C3=BCr=20die=20Funktion=20ers?= =?UTF-8?q?tellt?= 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 5d112b6..d09e661 100644 --- a/src/c/funktionen.c +++ b/src/c/funktionen.c @@ -47,4 +47,10 @@ int x_wins_00_10_20(char board[][3]) { if (board[0][0] == 'X' && board[1][0] == 'X' && board[2][0] == 'X') { return 1; } +} + +int x_wins_01_11_21(char board[][3]) { + if (board[0][1] == 'X' && board[1][1] == 'X' && board[2][1] == 'X') { + return 1; + } } \ No newline at end of file diff --git a/src/test/test_funktionen.c b/src/test/test_funktionen.c index 09ca587..2f16f48 100644 --- a/src/test/test_funktionen.c +++ b/src/test/test_funktionen.c @@ -91,4 +91,19 @@ void test_x_wins_onIndex_00_10_20(void) TEST_ASSERT_EQUAL_INT(expected, actual); } +void test_x_wins_onIndex_01_11_21(void) +{ + /* arrange */ + int actual; + int expected = 1; + + char board[][3] = {{' ','X',' '}, {' ','X',' '}, {' ','X',' '}}; + + /* act */ + actual = x_wins_01_11_21(board); + + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, actual); +} + #endif \ No newline at end of file