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.

113 lines
2.3 KiB

#ifdef TEST
#include "unity.h"
#include <stdlib.h>
#include "Schachbrett.h"
#include "Historie.h"
#include "En_Passaut.h"
#include "Bauer.h"
#include "Spieler.h"
void setUp(void) {
}
void tearDown(void) {
}
void test_En_Passaut_Weiss(void) {
int MAX_ZUEGE = 70;
int ZUG_INFO = 5;
// Historie erstellen
int** meineHistorie = erstellen_historie();
// Testdaten
int startX = 1;
int startY = 6;
int endX = 1;
int endY = 4;
Player currentPlayer = PLAYER_BLACK;
int anzahl_Zuege = 0;
// Züge zur Historie hinzufügen
hinzufuegen_historie(meineHistorie, startX, startY, endX, endY, currentPlayer, anzahl_Zuege);
char** brett = Schachbrett_erstellen();
clear_Schachbrett(brett);
TEST_ASSERT_NOT_NULL(brett);
brett[endY][endX] = 'p';
anzahl_Zuege++;
startX = 2;
startY = 4;
endX = 1;
endY = 5;
currentPlayer = PLAYER_WHITE;
TEST_ASSERT_TRUE(ist_En_Passaut_erlaubt_Bauer(brett,startX,startY,endX,endY,currentPlayer,anzahl_Zuege,meineHistorie));
for (int i = 0; i < 8; i++) {
free(brett[i]);
}
free(brett);
// Speicher freigeben
for (int i = 0; i < MAX_ZUEGE; i++) {
free(meineHistorie[i]);
}
}
void test_En_Passaut_Schwarz(void) {
int MAX_ZUEGE = 70;
int ZUG_INFO = 5;
// Historie erstellen
int** meineHistorie = erstellen_historie();
// Testdaten
int startX = 1;
int startY = 1;
int endX = 1;
int endY = 3;
Player currentPlayer = PLAYER_WHITE;
int anzahl_Zuege = 0;
// Züge zur Historie hinzufügen
hinzufuegen_historie(meineHistorie, startX, startY, endX, endY, currentPlayer, anzahl_Zuege);
char** brett = Schachbrett_erstellen();
clear_Schachbrett(brett);
TEST_ASSERT_NOT_NULL(brett);
brett[endY][endX] = 'P';
anzahl_Zuege++;
startX = 2;
startY = 3;
endX = 1;
endY = 2;
currentPlayer = PLAYER_BLACK;
TEST_ASSERT_TRUE(ist_En_Passaut_erlaubt_Bauer(brett,startX,startY,endX,endY,currentPlayer,anzahl_Zuege,meineHistorie));
for (int i = 0; i < 8; i++) {
free(brett[i]);
}
free(brett);
// Speicher freigeben
for (int i = 0; i < MAX_ZUEGE; i++) {
free(meineHistorie[i]);
}
}
#endif // TEST