Browse Source
Im Schach stehen + Test für Bauer, Anton Lohrey
remotes/origin/Läufer-fertig,-Hendrik-Voß
Im Schach stehen + Test für Bauer, Anton Lohrey
remotes/origin/Läufer-fertig,-Hendrik-Voß
fdai7492
11 months ago
3 changed files with 90 additions and 0 deletions
@ -0,0 +1,65 @@ |
|||
#ifdef TEST |
|||
#include "unity.h" |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <stdbool.h> |
|||
#include "Spieler.h" |
|||
#include "Koenig.h" |
|||
#include "Schachbrett.h" |
|||
|
|||
char** ErstelleTestBrett() { |
|||
char** Brett = malloc(8 * sizeof(char*)); |
|||
for (int i = 0; i < 8; i++) { |
|||
Brett[i] = malloc(8 * sizeof(char)); |
|||
for (int j = 0; j < 8; j++) { |
|||
Brett[i][j] = ' '; //Erstelle komplett leeres Brett |
|||
} |
|||
} |
|||
return Brett; |
|||
} |
|||
|
|||
void freeTestBrett(char** Brett) { |
|||
for (int i = 0; i < 8; i++) { |
|||
free(Brett[i]); |
|||
} |
|||
free(Brett); |
|||
} |
|||
void test_SchachDurchBauer(void) { |
|||
char** Brett = ErstelleTestBrett(); |
|||
|
|||
Brett[4][4] = 'K'; |
|||
Brett[5][5] = 'p'; |
|||
|
|||
TEST_ASSERT_TRUE(istKoenigImSchach(Brett, PLAYER_WHITE)); |
|||
|
|||
freeTestBrett(Brett); |
|||
Brett = ErstelleTestBrett(); |
|||
|
|||
Brett[3][3] = 'k'; |
|||
Brett[2][2] = 'P'; |
|||
TEST_ASSERT_TRUE(istKoenigImSchach(Brett, PLAYER_BLACK)); |
|||
|
|||
freeTestBrett(Brett); |
|||
Brett = ErstelleTestBrett(); |
|||
|
|||
Brett[3][3] = 'k'; |
|||
Brett[2][4] = 'P'; |
|||
TEST_ASSERT_TRUE(istKoenigImSchach(Brett, PLAYER_BLACK)); |
|||
|
|||
freeTestBrett(Brett); |
|||
Brett = ErstelleTestBrett(); |
|||
|
|||
Brett[4][4] = 'K'; |
|||
Brett[3][4] = 'P'; |
|||
TEST_ASSERT_FALSE(istKoenigImSchach(Brett, PLAYER_WHITE)); |
|||
|
|||
freeTestBrett(Brett); |
|||
Brett = ErstelleTestBrett(); |
|||
|
|||
Brett[3][3] = 'k'; |
|||
Brett[1][3] = 'P'; |
|||
TEST_ASSERT_FALSE(istKoenigImSchach(Brett, PLAYER_BLACK)); |
|||
|
|||
freeTestBrett(Brett); |
|||
} |
|||
#endif // TEST |
Write
Preview
Loading…
Cancel
Save
Reference in new issue