fdai7892
11 months ago
11 changed files with 1100 additions and 26 deletions
-
4build/test/cache/defines_dependency.yml
-
509build/test/cache/test_duellist_spielesammlung_projekt.c
-
5build/test/dependencies/test_duellist_spielesammlung_projekt.d
-
BINbuild/test/out/c/test_duellist_spielesammlung_projekt.o
-
BINbuild/test/out/c/test_duellist_spielesammlung_projekt_runner.o
-
509build/test/preprocess/files/test_duellist_spielesammlung_projekt.c
-
4build/test/preprocess/includes/test_duellist_spielesammlung_projekt.c
-
14build/test/results/test_duellist_spielesammlung_projekt.pass
-
66build/test/runners/test_duellist_spielesammlung_projekt_runner.c
-
12src/main/duellist-spielesammlung-projekt.c
-
3src/main/duellist-spielesammlung-projekt.h
@ -1 +1,3 @@ |
|||||
--- {} |
|
||||
|
--- |
||||
|
src/main/duellist-spielesammlung-projekt.c: |
||||
|
- TEST |
@ -0,0 +1,509 @@ |
|||||
|
#include "src/main/duellist-spielesammlung-projekt.h" |
||||
|
#include "C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
void setUp(void) {} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void tearDown(void) {} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_coinflip_player_x_starts(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = initializeGame(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((SUCCESS)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(19), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
do {if ((game.currentPlayer == PLAYER_X || game.currentPlayer == PLAYER_O)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(20)));}} while(0); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_coinflip_player_o_starts(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = initializeGame(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((SUCCESS)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(31), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
do {if ((game.currentPlayer == PLAYER_X || game.currentPlayer == PLAYER_O)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(32)));}} while(0); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_vertical_win(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{PLAYER_X, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_O }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = checkGameResult(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((GAME_WIN)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(46), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_horizontal_win(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, PLAYER_X, PLAYER_X}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_O }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = checkGameResult(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((GAME_WIN)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(60), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void test_diagonal_win(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, PLAYER_X, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, PLAYER_X}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_O }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = checkGameResult(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((GAME_WIN)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(73), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_valid_move_and_switch_player(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{EMPTY, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_X }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult moveResult = makeMove(&game, 1, 1); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((SUCCESS)), (UNITY_INT)((moveResult)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(87), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((PLAYER_O)), (UNITY_INT)((game.currentPlayer)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(88), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_invalid_input(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_O }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = makeMove(&game, 0, 0); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((INVALID_MOVE)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(103), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_valid_input(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{EMPTY, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_X }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = makeMove(&game, 1, 1); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((SUCCESS)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(117), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_invalid_input_type1(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_O }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = makeMove(&game, -1, 0); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((INVALID_MOVE)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(132), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_invalid_input_type2(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_O }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = makeMove(&game, 0, 3); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((INVALID_MOVE)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(146), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_getNumberOfMoves_returns_correct_number_of_moves(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, PLAYER_O, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_X }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
int moves = getNumberOfMoves(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((moves)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(160), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_BoardFull_returns_false_when_board_is_not_full(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, PLAYER_O, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_X }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
int boardFull = BoardFull(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
do {if (!(boardFull)) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(174)));}} while(0); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void test_BoardFull_returns_true_when_board_is_full(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, PLAYER_X, PLAYER_O}, |
||||
|
|
||||
|
{PLAYER_O, PLAYER_O, PLAYER_X}, |
||||
|
|
||||
|
{PLAYER_X, PLAYER_X, PLAYER_O}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_X }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
int boardFull = BoardFull(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
do {if ((boardFull)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(187)));}} while(0); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void test_getCurrentPlayer_returns_correct_player(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, PLAYER_O, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_O }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
Player currentPlayer = getCurrentPlayer(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((PLAYER_O)), (UNITY_INT)((currentPlayer)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(200), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void test_FieldEmpty_returns_true_for_empty_field(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, PLAYER_O, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}} }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
int result = FieldEmpty(&game, 0, 2); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(212), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_FieldEmpty_returns_false_for_nonempty_field(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, PLAYER_O, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}} }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
int result = FieldEmpty(&game, 0, 0); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(225), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
@ -1,2 +1,5 @@ |
|||||
build/test/out/c/test_duellist_spielesammlung_projekt.o: \ |
build/test/out/c/test_duellist_spielesammlung_projekt.o: \ |
||||
src/test/test_duellist_spielesammlung_projekt.c |
|
||||
|
src/test/test_duellist_spielesammlung_projekt.c \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ |
||||
|
src/main/duellist-spielesammlung-projekt.h |
@ -0,0 +1,509 @@ |
|||||
|
#include "src/main/duellist-spielesammlung-projekt.h" |
||||
|
#include "C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
void setUp(void) {} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void tearDown(void) {} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_coinflip_player_x_starts(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = initializeGame(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((SUCCESS)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(19), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
do {if ((game.currentPlayer == PLAYER_X || game.currentPlayer == PLAYER_O)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(20)));}} while(0); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_coinflip_player_o_starts(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = initializeGame(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((SUCCESS)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(31), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
do {if ((game.currentPlayer == PLAYER_X || game.currentPlayer == PLAYER_O)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(32)));}} while(0); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_vertical_win(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{PLAYER_X, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_O }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = checkGameResult(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((GAME_WIN)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(46), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_horizontal_win(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, PLAYER_X, PLAYER_X}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_O }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = checkGameResult(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((GAME_WIN)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(60), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void test_diagonal_win(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, PLAYER_X, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, PLAYER_X}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_O }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = checkGameResult(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((GAME_WIN)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(73), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_valid_move_and_switch_player(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{EMPTY, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_X }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult moveResult = makeMove(&game, 1, 1); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((SUCCESS)), (UNITY_INT)((moveResult)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(87), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((PLAYER_O)), (UNITY_INT)((game.currentPlayer)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(88), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_invalid_input(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_O }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = makeMove(&game, 0, 0); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((INVALID_MOVE)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(103), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_valid_input(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{EMPTY, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_X }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = makeMove(&game, 1, 1); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((SUCCESS)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(117), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_invalid_input_type1(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_O }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = makeMove(&game, -1, 0); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((INVALID_MOVE)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(132), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_invalid_input_type2(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_O }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
GameResult result = makeMove(&game, 0, 3); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((INVALID_MOVE)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(146), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_getNumberOfMoves_returns_correct_number_of_moves(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, PLAYER_O, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_X }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
int moves = getNumberOfMoves(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((moves)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(160), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_BoardFull_returns_false_when_board_is_not_full(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, PLAYER_O, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_X }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
int boardFull = BoardFull(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
do {if (!(boardFull)) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(174)));}} while(0); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void test_BoardFull_returns_true_when_board_is_full(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, PLAYER_X, PLAYER_O}, |
||||
|
|
||||
|
{PLAYER_O, PLAYER_O, PLAYER_X}, |
||||
|
|
||||
|
{PLAYER_X, PLAYER_X, PLAYER_O}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_X }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
int boardFull = BoardFull(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
do {if ((boardFull)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(187)));}} while(0); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void test_getCurrentPlayer_returns_correct_player(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, PLAYER_O, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}}, |
||||
|
|
||||
|
.currentPlayer = PLAYER_O }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
Player currentPlayer = getCurrentPlayer(&game); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((PLAYER_O)), (UNITY_INT)((currentPlayer)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(200), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void test_FieldEmpty_returns_true_for_empty_field(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, PLAYER_O, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}} }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
int result = FieldEmpty(&game, 0, 2); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(212), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_FieldEmpty_returns_false_for_nonempty_field(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
TicTacToeGame game = { .board = {{PLAYER_X, EMPTY, EMPTY}, |
||||
|
|
||||
|
{EMPTY, PLAYER_O, EMPTY}, |
||||
|
|
||||
|
{EMPTY, EMPTY, EMPTY}} }; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
int result = FieldEmpty(&game, 0, 0); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(225), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
@ -1 +1,3 @@ |
|||||
--- [] |
|
||||
|
--- |
||||
|
- C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h |
||||
|
- src/main/duellist-spielesammlung-projekt.h |
@ -1,14 +0,0 @@ |
|||||
--- |
|
||||
:source: |
|
||||
:path: src/test |
|
||||
:file: test_duellist_spielesammlung_projekt.c |
|
||||
:successes: [] |
|
||||
:failures: [] |
|
||||
:ignores: [] |
|
||||
:counts: |
|
||||
:total: 0 |
|
||||
:passed: 0 |
|
||||
:failed: 0 |
|
||||
:ignored: 0 |
|
||||
:stdout: [] |
|
||||
:time: 0.014711899915710092 |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue