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
#define TICTACTOE_H
int isValidMove(int choice);
char checkLine(char a, char b, char c);
void start_tictactoe();
char checkWinner();
#endif

26
test/test_tictactoe.c

@ -46,6 +46,7 @@ void test_checkLine_horizontalerGewinner(void) {
TEST_ASSERT_EQUAL_CHAR('X', result);
}
void test_isValidMove_gueltigerZug(void) {
/* arrangieren */
int result;
@ -57,4 +58,29 @@ void test_isValidMove_gueltigerZug(void) {
/* überprüfen */
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
Loading…
Cancel
Save