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.
108 lines
1.9 KiB
108 lines
1.9 KiB
#ifdef TEST
|
|
#include "unity.h"
|
|
#include "Schachbrett.h"
|
|
#include "Moving.h"
|
|
#include "Spieler.h"
|
|
#include "Turm.h"
|
|
#include "Bauer.h"
|
|
#include <stdlib.h>
|
|
|
|
void setUp(void) {
|
|
}
|
|
|
|
void tearDown(void) {
|
|
}
|
|
|
|
void test_Bauern_bewegen(void) {
|
|
char** brett = Schachbrett_erstellen();
|
|
int startX = 0;
|
|
int startY = 1;
|
|
int endX = 0;
|
|
int endY = 2;
|
|
Player player = PLAYER_WHITE;
|
|
|
|
|
|
TEST_ASSERT_NOT_NULL(brett);
|
|
|
|
machezug( brett, startX, startY, endX, endY, player);
|
|
|
|
print_Schachfeld(brett);
|
|
|
|
TEST_ASSERT_EQUAL('P', brett[2][0]);
|
|
TEST_ASSERT_EQUAL(' ', brett[1][0]);
|
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
free(brett[i]);
|
|
}
|
|
free(brett);
|
|
}
|
|
|
|
void test_Bauer_Y_Verknuepfung_Bewegung(void) {
|
|
|
|
char** brett = Schachbrett_erstellen();
|
|
int startX = 1;
|
|
int startY = 1;
|
|
int endX = 1;
|
|
int endY = 2;
|
|
Player player = PLAYER_WHITE;
|
|
|
|
|
|
TEST_ASSERT_NOT_NULL(brett);
|
|
|
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt( brett, startX, startY, endX, endY, player));
|
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
free(brett[i]);
|
|
}
|
|
free(brett);
|
|
}
|
|
|
|
void test_istzugerlaubt(void){
|
|
char** brett = Schachbrett_erstellen();
|
|
int startX = 1;
|
|
int startY = 1;
|
|
int endX = 1;
|
|
int endY = 1;
|
|
Player player = PLAYER_WHITE;
|
|
|
|
//istzugerlaubt(brett,startX,startY,endX,endY,player);
|
|
|
|
TEST_ASSERT_FALSE(istzugerlaubt(brett,startX,startY,endX,endY,player));
|
|
for (int i = 0; i < 8; i++) {
|
|
free(brett[i]);
|
|
}
|
|
free(brett);
|
|
|
|
|
|
|
|
}
|
|
|
|
void test_istzugerlaubt_Turm(void){
|
|
|
|
char** brett = Schachbrett_erstellen();
|
|
int startX = 0;
|
|
int startY = 4;
|
|
int endX = 0;
|
|
int endY = 2;
|
|
Player player = PLAYER_WHITE;
|
|
|
|
|
|
TEST_ASSERT_NOT_NULL(brett);
|
|
|
|
brett[4][0] = 'r';
|
|
print_Schachfeld(brett);
|
|
|
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt(brett, startX, startY, endX, endY, player));
|
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
free(brett[i]);
|
|
}
|
|
free(brett);
|
|
}
|
|
|
|
#endif // TEST
|