Browse Source
Merge branch 'Ariana' into 'main'
Merge branch 'Ariana' into 'main'
Ariana See merge request pmuw_projekt/pmuw_projekt_notebinder!35remotes/origin/Saba
fdai8032
11 months ago
5 changed files with 142 additions and 19 deletions
-
9.gitlab/.gitlab-webide.yml
-
46src/main/c/GameTic_Tac_Toe/tictactoe.c
-
13src/main/c/GameTic_Tac_Toe/tictactoe.h
-
6src/main/c/main.c
-
87test/test_tictactoe.c
@ -0,0 +1,9 @@ |
|||||
|
terminal: |
||||
|
# This can be any image that has the necessary runtime environment for your project. |
||||
|
image: node:10-alpine |
||||
|
before_script: |
||||
|
- apk update |
||||
|
script: sleep 60 |
||||
|
variables: |
||||
|
RAILS_ENV: "test" |
||||
|
NODE_ENV: "test" |
@ -1 +1,14 @@ |
|||||
|
#ifndef TICTACTOE_H |
||||
|
#define TICTACTOE_H |
||||
|
|
||||
|
#define BOARD_SIZE 3 |
||||
|
|
||||
|
int isValidMove(int choice); |
||||
|
char checkLine(char a, char b, char c); |
||||
|
void start_tictactoe(); |
||||
|
char checkWinner(); |
||||
|
void makeMove(int choice); |
||||
|
void displayBoard(); |
||||
|
void reset_board(); |
||||
|
|
||||
|
#endif |
@ -1 +1,88 @@ |
|||||
|
|
||||
|
#ifdef TEST |
||||
|
#include "unity.h" |
||||
|
#include "tictactoe.h" |
||||
|
|
||||
|
|
||||
|
void setUp(void){ |
||||
|
//Wenn Funktion Vorraussetzungen braucht |
||||
|
} |
||||
|
void tearDown(void){ |
||||
|
reset_board(); |
||||
|
displayBoard(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void test_if_not_identical(void){ |
||||
|
/* arrange */ |
||||
|
char result; |
||||
|
char a = 'a', b = 'b', c = 'c'; |
||||
|
|
||||
|
result = checkLine(a, b, c); |
||||
|
|
||||
|
/* assert */ |
||||
|
TEST_ASSERT_EQUAL_CHAR(' ', result); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void test_if_identical(void){ |
||||
|
/* arrange */ |
||||
|
char result; |
||||
|
char a = 'a', b = 'a', c = 'a'; |
||||
|
|
||||
|
result = checkLine(a, b, c); |
||||
|
|
||||
|
/* assert */ |
||||
|
TEST_ASSERT_EQUAL_CHAR(a, result); |
||||
|
} |
||||
|
|
||||
|
void test_isValidMove_gueltigerZug(void) { |
||||
|
/* arrangieren */ |
||||
|
int result; |
||||
|
int choice = 5; |
||||
|
|
||||
|
/* handeln */ |
||||
|
result = isValidMove(choice); |
||||
|
|
||||
|
/* überprüfen */ |
||||
|
TEST_ASSERT_EQUAL_INT(1, result); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void test_checkWinner_vertikalerGewinner(void) { |
||||
|
/* arrangieren */ |
||||
|
char result; |
||||
|
|
||||
|
// Setze die Daten für einen vertikalen Gewinne |
||||
|
makeMove(1); |
||||
|
makeMove(2); |
||||
|
makeMove(4); |
||||
|
makeMove(3); |
||||
|
makeMove(7); |
||||
|
|
||||
|
/* handeln */ |
||||
|
result = checkWinner(); |
||||
|
|
||||
|
/* überprüfen */ |
||||
|
TEST_ASSERT_EQUAL_CHAR('O', result); |
||||
|
} |
||||
|
|
||||
|
void test_checkWinner_horizontalerGewinner(void) { |
||||
|
/* arrangieren */ |
||||
|
char result; |
||||
|
|
||||
|
//makeMove(1); |
||||
|
//makeMove(4); |
||||
|
//makeMove(2); |
||||
|
//makeMove(5); |
||||
|
//makeMove(3); |
||||
|
|
||||
|
/* handeln */ |
||||
|
result = checkWinner(); |
||||
|
|
||||
|
/* überprüfen */ |
||||
|
TEST_ASSERT_EQUAL_CHAR('X', result); |
||||
|
reset_board(); |
||||
|
} |
||||
|
|
||||
|
#endif // TEST |
Write
Preview
Loading…
Cancel
Save
Reference in new issue