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.
208 lines
3.8 KiB
208 lines
3.8 KiB
#ifdef TEST
|
|
#include "unity.h"
|
|
#include "Schachbrett.h"
|
|
#include "Spieler.h"
|
|
#include "Dame.h"
|
|
#include <stdlib.h>
|
|
|
|
void test_Dame_Schlag_Bewegung(void) {
|
|
|
|
char** brett = Schachbrett_erstellen();
|
|
int startX = 0;
|
|
int startY = 3;
|
|
int endX = 3;
|
|
int endY = 6;
|
|
Player player = PLAYER_WHITE;
|
|
|
|
|
|
TEST_ASSERT_NOT_NULL(brett);
|
|
|
|
brett[3][0] = 'Q';
|
|
print_Schachfeld(brett);
|
|
|
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt_Dame(brett, startX, startY, endX, endY, player));
|
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
free(brett[i]);
|
|
}
|
|
free(brett);
|
|
}
|
|
|
|
void test_Dame_negative_horizontal_Bewegung(void) {
|
|
|
|
char** brett = Schachbrett_erstellen();
|
|
int startX = 3;
|
|
int startY = 4;
|
|
int endX = 3;
|
|
int endY = 2;
|
|
Player player = PLAYER_WHITE;
|
|
|
|
|
|
TEST_ASSERT_NOT_NULL(brett);
|
|
|
|
brett[4][3] = 'Q';
|
|
print_Schachfeld(brett);
|
|
|
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt_Dame(brett, startX, startY, endX, endY, player));
|
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
free(brett[i]);
|
|
}
|
|
free(brett);
|
|
}
|
|
|
|
void test_Dame_positive_horizontal_Bewegung(void) {
|
|
|
|
char** brett = Schachbrett_erstellen();
|
|
int startX = 3;
|
|
int startY = 2;
|
|
int endX = 3;
|
|
int endY = 4;
|
|
Player player = PLAYER_WHITE;
|
|
|
|
|
|
TEST_ASSERT_NOT_NULL(brett);
|
|
|
|
brett[2][3] = 'Q';
|
|
print_Schachfeld(brett);
|
|
|
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt_Dame(brett, startX, startY, endX, endY, player));
|
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
free(brett[i]);
|
|
}
|
|
free(brett);
|
|
}
|
|
|
|
void test_Dame_vertikal_Links_Bewegung(void) {
|
|
|
|
char** brett = Schachbrett_erstellen();
|
|
int startX = 6;
|
|
int startY = 3;
|
|
int endX = 4;
|
|
int endY = 3;
|
|
Player player = PLAYER_WHITE;
|
|
|
|
|
|
TEST_ASSERT_NOT_NULL(brett);
|
|
|
|
brett[3][6] = 'Q';
|
|
print_Schachfeld(brett);
|
|
|
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt_Dame( brett, startX, startY, endX, endY, player));
|
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
free(brett[i]);
|
|
}
|
|
free(brett);
|
|
}
|
|
|
|
void test_Dame_vertikal_Rechts_Bewegung(void) {
|
|
|
|
char** brett = Schachbrett_erstellen();
|
|
int startX = 3;
|
|
int startY = 3;
|
|
int endX = 6;
|
|
int endY = 3;
|
|
Player player = PLAYER_WHITE;
|
|
|
|
|
|
TEST_ASSERT_NOT_NULL(brett);
|
|
|
|
brett[3][3] = 'Q';
|
|
print_Schachfeld(brett);
|
|
|
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt_Dame( brett, startX, startY, endX, endY, player));
|
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
free(brett[i]);
|
|
}
|
|
free(brett);
|
|
}
|
|
|
|
void test_Dame_Diagonal_negative_X_Y_Bewegung(void) {
|
|
|
|
char** brett = Schachbrett_erstellen();
|
|
int startX = 3;
|
|
int startY = 4;
|
|
int endX = 1;
|
|
int endY = 2;
|
|
Player player = PLAYER_WHITE;
|
|
|
|
|
|
TEST_ASSERT_NOT_NULL(brett);
|
|
|
|
brett[4][3] = 'Q';
|
|
print_Schachfeld(brett);
|
|
|
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt_Dame( brett, startX, startY, endX, endY, player));
|
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
free(brett[i]);
|
|
}
|
|
free(brett);
|
|
}
|
|
|
|
void test_Dame_Diagonal_positive_X_Y_Bewegung(void) {
|
|
|
|
char** brett = Schachbrett_erstellen();
|
|
int startX = 4;
|
|
int startY = 3;
|
|
int endX = 5;
|
|
int endY = 4;
|
|
Player player = PLAYER_WHITE;
|
|
|
|
|
|
TEST_ASSERT_NOT_NULL(brett);
|
|
|
|
brett[3][4] = 'Q';
|
|
print_Schachfeld(brett);
|
|
|
|
|
|
TEST_ASSERT_TRUE(istzugerlaubt_Dame( brett, startX, startY, endX, endY, player));
|
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
free(brett[i]);
|
|
}
|
|
free(brett);
|
|
}
|
|
|
|
void test_Dame_Falsche_Bewegung(void) {
|
|
|
|
char** brett = Schachbrett_erstellen();
|
|
int startX = 3;
|
|
int startY = 0;
|
|
int endX = 3;
|
|
int endY = 4;
|
|
Player player = PLAYER_WHITE;
|
|
|
|
|
|
TEST_ASSERT_NOT_NULL(brett);
|
|
|
|
|
|
print_Schachfeld(brett);
|
|
|
|
|
|
TEST_ASSERT_FALSE(istzugerlaubt_Dame( brett, startX, startY, endX, endY, player));
|
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
free(brett[i]);
|
|
}
|
|
free(brett);
|
|
}
|
|
|
|
#endif // TEST
|