You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.1 KiB
46 lines
1.1 KiB
#ifdef TEST
|
|
#include "unity.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdbool.h>
|
|
#include "Spieler.h"
|
|
#include "Koenig.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_GreiftSpringerAn(void) {
|
|
char** Brett = ErstelleTestBrett();
|
|
|
|
// Plaziert ein schwarzen Springer (3,4) und testet 'Angriff' auf e3 (4,2)
|
|
Brett[4][3] = 'n';
|
|
Player player = PLAYER_WHITE;
|
|
TEST_ASSERT_TRUE(GreiftSpringerAn(Brett, 4, 2, player));
|
|
|
|
// Plaziert ein weißen Springer (5,2) und testet 'Angriff' auf e5 (4,4)
|
|
Brett[2][5] = 'N';
|
|
player = PLAYER_BLACK;
|
|
TEST_ASSERT_TRUE(GreiftSpringerAn(Brett, 4, 4, player));
|
|
|
|
// Testet Feld ohne Bedrohung
|
|
TEST_ASSERT_FALSE(GreiftSpringerAn(Brett, 0, 0, player));
|
|
|
|
freeTestBrett(Brett);
|
|
}
|
|
#endif // TEST
|
|
|