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.
|
|
#ifdef TEST
#include "unity.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include "Spieler.h"
#include "Koenig.h"
#include "Schachbrett.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_SchachDurchBauer(void) { char** Brett = ErstelleTestBrett();
Brett[4][4] = 'K'; Brett[5][5] = 'p'; TEST_ASSERT_TRUE(istKoenigImSchach(Brett, PLAYER_WHITE));
freeTestBrett(Brett); Brett = ErstelleTestBrett(); Brett[3][3] = 'k'; Brett[2][2] = 'P'; TEST_ASSERT_TRUE(istKoenigImSchach(Brett, PLAYER_BLACK));
freeTestBrett(Brett); Brett = ErstelleTestBrett(); Brett[3][3] = 'k'; Brett[2][4] = 'P'; TEST_ASSERT_TRUE(istKoenigImSchach(Brett, PLAYER_BLACK));
freeTestBrett(Brett); Brett = ErstelleTestBrett(); Brett[4][4] = 'K'; Brett[3][4] = 'P'; TEST_ASSERT_FALSE(istKoenigImSchach(Brett, PLAYER_WHITE));
freeTestBrett(Brett); Brett = ErstelleTestBrett(); Brett[3][3] = 'k'; Brett[1][3] = 'P'; TEST_ASSERT_FALSE(istKoenigImSchach(Brett, PLAYER_BLACK));
freeTestBrett(Brett); } #endif // TEST
|