Browse Source

Test vertikal Gewinner

remotes/origin/Ariana
fdai7775 11 months ago
parent
commit
48c322c761
  1. 2
      src/main/c/GameTic_Tac_Toe/tictactoe.h
  2. 26
      test/test_tictactoe.c

2
src/main/c/GameTic_Tac_Toe/tictactoe.h

@ -1,7 +1,9 @@
#ifndef TICTACTOE_H #ifndef TICTACTOE_H
#define TICTACTOE_H #define TICTACTOE_H
int isValidMove(int choice);
char checkLine(char a, char b, char c); char checkLine(char a, char b, char c);
void start_tictactoe(); void start_tictactoe();
char checkWinner();
#endif #endif

26
test/test_tictactoe.c

@ -46,6 +46,7 @@ void test_checkLine_horizontalerGewinner(void) {
TEST_ASSERT_EQUAL_CHAR('X', result); TEST_ASSERT_EQUAL_CHAR('X', result);
} }
void test_isValidMove_gueltigerZug(void) { void test_isValidMove_gueltigerZug(void) {
/* arrangieren */ /* arrangieren */
int result; int result;
@ -57,4 +58,29 @@ void test_isValidMove_gueltigerZug(void) {
/* überprüfen */ /* überprüfen */
TEST_ASSERT_EQUAL_INT(1, result); TEST_ASSERT_EQUAL_INT(1, result);
} }
void test_checkWinner_vertikalerGewinner(void) {
/* arrangieren */
char result;
// 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 vertikalen Gewinner
board[0][0] = 'O';
board[1][0] = 'O';
board[2][0] = 'O';
/* handeln */
result = checkWinner();
/* überprüfen */
TEST_ASSERT_EQUAL_CHAR('O', result);
}
#endif // TEST #endif // TEST
Loading…
Cancel
Save