|
|
@ -1,15 +1,25 @@ |
|
|
|
#ifdef TEST |
|
|
|
#include "unity.h" |
|
|
|
#include "Schachbrett.h" |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdlib.h> |
|
|
|
#include <stdbool.h> |
|
|
|
#include "Spielstatus.h" |
|
|
|
#include "Moving.h" |
|
|
|
#include "Spieler.h" |
|
|
|
#include "Turm.h" |
|
|
|
#include "Bauer.h" |
|
|
|
#include "Koenig.h" |
|
|
|
#include "Turm.h" |
|
|
|
#include "Springer.h" |
|
|
|
#include "Koenig.h" |
|
|
|
#include "Dame.h" |
|
|
|
#include "Laeufer.h" |
|
|
|
#include <stdlib.h> |
|
|
|
#include "Historie.h" |
|
|
|
#include "Input.h" |
|
|
|
#include "Bauernumwandlung.h" |
|
|
|
#include "En_Passaut.h" |
|
|
|
#include "Misc.h" |
|
|
|
#include "Schachbrett.h" |
|
|
|
#include "Speichern.h" |
|
|
|
#include "Tutorial.h" |
|
|
|
|
|
|
|
void setUp(void) { |
|
|
|
} |
|
|
@ -24,16 +34,19 @@ void test_Bauern_bewegen(void) { |
|
|
|
int endX = 0; |
|
|
|
int endY = 2; |
|
|
|
Player player = PLAYER_WHITE; |
|
|
|
int ** Historie = erstellen_historie(); |
|
|
|
int anzahl_Zuege = 1; |
|
|
|
|
|
|
|
|
|
|
|
TEST_ASSERT_NOT_NULL(brett); |
|
|
|
|
|
|
|
machezug( brett, startX, startY, endX, endY, player); |
|
|
|
machezug(brett,startX,startY,endX,endY,player,anzahl_Zuege,Historie); |
|
|
|
|
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt_Bauer(brett,startX,startY,endX,endY,player)); |
|
|
|
print_Schachfeld(brett); |
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL('P', brett[2][0]); |
|
|
|
TEST_ASSERT_EQUAL(' ', brett[1][0]); |
|
|
|
TEST_ASSERT_EQUAL('P', brett[1][0]); |
|
|
|
TEST_ASSERT_EQUAL(' ', brett[2][0]); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 8; i++) { |
|
|
@ -45,13 +58,15 @@ void test_Bauern_bewegen(void) { |
|
|
|
void test_istzugerlaubt_Koenig_Verknuepfung(void) { |
|
|
|
char **Brett = Schachbrett_erstellen(); |
|
|
|
Player player = PLAYER_WHITE; |
|
|
|
int ** Historie = erstellen_historie(); |
|
|
|
int anzahl_Zuege = 1; |
|
|
|
//Vorbereitung für Test |
|
|
|
Brett[1][4] = ' '; |
|
|
|
Brett[2][4] = 'p'; |
|
|
|
|
|
|
|
// Test bewegung |
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt(Brett, 4, 0, 4, 1, player)); // e1 zu e2 |
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt(Brett, 4, 1, 4, 2, player)); // e2 zu e3 (Einnehmen von Figur) |
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt(Brett, 4, 0, 4, 1, player,anzahl_Zuege,Historie)); // e1 zu e2 |
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt(Brett, 4, 1, 4, 2, player,anzahl_Zuege,Historie)); // e2 zu e3 (Einnehmen von Figur) |
|
|
|
|
|
|
|
Schachbrettspeicher_freigeben(Brett); |
|
|
|
Brett = Schachbrett_erstellen(); |
|
|
@ -61,12 +76,13 @@ void test_istzugerlaubt_Koenig_Verknuepfung(void) { |
|
|
|
Brett[5][4] = 'P'; |
|
|
|
|
|
|
|
// Test bewegung |
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt(Brett, 4, 7, 4, 6, player)); // e8 zu e7 |
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt(Brett, 4, 6, 4, 5, player)); // e7 zu e6 (Einnehmen von Figur) |
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt(Brett, 4, 7, 4, 6, player,anzahl_Zuege,Historie)); // e8 zu e7 |
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt(Brett, 4, 6, 4, 5, player,anzahl_Zuege,Historie)); // e7 zu e6 (Einnehmen von Figur) |
|
|
|
|
|
|
|
Schachbrettspeicher_freigeben(Brett); |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
void test_Bauer_Y_Verknuepfung_Bewegung(void) { |
|
|
|
|
|
|
|
char** brett = Schachbrett_erstellen(); |
|
|
@ -88,14 +104,16 @@ void test_Bauer_Y_Verknuepfung_Bewegung(void) { |
|
|
|
} |
|
|
|
free(brett); |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
void test_istzugerlaubt_Springer_Verknuepfung(void) { |
|
|
|
char **Brett = Schachbrett_erstellen(); |
|
|
|
int ** Historie = erstellen_historie(); |
|
|
|
int anzahl_Zuege = 1; |
|
|
|
|
|
|
|
// Viele Test um legale Züge zu prüfen |
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt(Brett, 1, 0, 0, 2, PLAYER_WHITE)); |
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt(Brett, 1, 0, 0, 2, PLAYER_WHITE,anzahl_Zuege,Historie)); |
|
|
|
|
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt(Brett, 4, 3, 6, 2, PLAYER_BLACK)); |
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt(Brett, 4, 3, 6, 2, PLAYER_BLACK,anzahl_Zuege,Historie)); |
|
|
|
|
|
|
|
|
|
|
|
Schachbrettspeicher_freigeben(Brett); |
|
|
@ -109,9 +127,11 @@ void test_istzugerlaubt(void){ |
|
|
|
int endY = 1; |
|
|
|
Player player = PLAYER_WHITE; |
|
|
|
|
|
|
|
int ** Historie = erstellen_historie(); |
|
|
|
int anzahl_Zuege = 1; |
|
|
|
//istzugerlaubt(brett,startX,startY,endX,endY,player); |
|
|
|
|
|
|
|
TEST_ASSERT_FALSE(istzugerlaubt(brett,startX,startY,endX,endY,player)); |
|
|
|
TEST_ASSERT_FALSE(istzugerlaubt(brett,startX,startY,endX,endY,player,anzahl_Zuege,Historie)); |
|
|
|
for (int i = 0; i < 8; i++) { |
|
|
|
free(brett[i]); |
|
|
|
} |
|
|
@ -130,6 +150,8 @@ void test_istzugerlaubt_Turm(void){ |
|
|
|
int endY = 2; |
|
|
|
Player player = PLAYER_WHITE; |
|
|
|
|
|
|
|
int ** Historie = erstellen_historie(); |
|
|
|
int anzahl_Zuege = 1; |
|
|
|
|
|
|
|
TEST_ASSERT_NOT_NULL(brett); |
|
|
|
|
|
|
@ -137,7 +159,7 @@ void test_istzugerlaubt_Turm(void){ |
|
|
|
print_Schachfeld(brett); |
|
|
|
|
|
|
|
|
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt(brett, startX, startY, endX, endY, player)); |
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt(brett, startX, startY, endX, endY, player,anzahl_Zuege,Historie)); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 8; i++) { |
|
|
@ -145,19 +167,5 @@ void test_istzugerlaubt_Turm(void){ |
|
|
|
} |
|
|
|
free(brett); |
|
|
|
} |
|
|
|
void test_Laeufer_black_Moving(void) { |
|
|
|
char** brett = Schachbrett_erstellen(); |
|
|
|
Player player = PLAYER_BLACK; |
|
|
|
// Prüfen, ob der Zug eine Diagonale ist == true |
|
|
|
brett[6][6] = 'b'; |
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt(brett, 6, 6, 3, 3, player)); |
|
|
|
|
|
|
|
for (int i = 0; i < 8; i++) { |
|
|
|
free(brett[i]); |
|
|
|
} |
|
|
|
free(brett); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif // TEST |