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.
45 lines
1.8 KiB
45 lines
1.8 KiB
#ifdef TEST
|
|
#include "unity.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdbool.h>
|
|
#include "Springer.h"
|
|
#include "Schachbrett.h"
|
|
#include "Spieler.h"
|
|
|
|
void test_istzugerlaubt_Springer_LegalMove(void) {
|
|
char **Brett = Schachbrett_erstellen();
|
|
|
|
// Viele Test um legale Züge zu prüfen
|
|
TEST_ASSERT_TRUE(istzugerlaubt_Springer(Brett, 1, 0, 0, 2, PLAYER_WHITE));
|
|
TEST_ASSERT_TRUE(istzugerlaubt_Springer(Brett, 1, 0, 2, 2, PLAYER_WHITE));
|
|
TEST_ASSERT_TRUE(istzugerlaubt_Springer(Brett, 4, 3, 3, 5, PLAYER_WHITE));
|
|
TEST_ASSERT_TRUE(istzugerlaubt_Springer(Brett, 4, 3, 2, 2, PLAYER_WHITE));
|
|
TEST_ASSERT_TRUE(istzugerlaubt_Springer(Brett, 4, 3, 6, 2, PLAYER_BLACK));
|
|
TEST_ASSERT_TRUE(istzugerlaubt_Springer(Brett, 6, 7, 5, 5, PLAYER_BLACK));
|
|
TEST_ASSERT_TRUE(istzugerlaubt_Springer(Brett, 6, 7, 7, 5, PLAYER_BLACK));
|
|
TEST_ASSERT_TRUE(istzugerlaubt_Springer(Brett, 4, 3, 5, 5, PLAYER_BLACK));
|
|
|
|
Schachbrettspeicher_freigeben(Brett);
|
|
}
|
|
void test_istzugerlaubt_Springer_IllegalMove(void) {
|
|
char **Brett = Schachbrett_erstellen();
|
|
|
|
// Landet auf eigener Figur
|
|
TEST_ASSERT_FALSE(istzugerlaubt_Springer(Brett, 6, 7, 4, 6, PLAYER_BLACK));
|
|
TEST_ASSERT_FALSE(istzugerlaubt_Springer(Brett, 1, 7, 3, 6, PLAYER_BLACK));
|
|
TEST_ASSERT_FALSE(istzugerlaubt_Springer(Brett, 6, 0, 4, 1, PLAYER_WHITE));
|
|
TEST_ASSERT_FALSE(istzugerlaubt_Springer(Brett, 1, 0, 3, 1, PLAYER_WHITE));
|
|
|
|
// versucht sich geradeaus zu bewegen
|
|
TEST_ASSERT_FALSE(istzugerlaubt_Springer(Brett, 1, 0, 1, 3, PLAYER_WHITE));
|
|
|
|
// Versucht Diagonal zu bewegen
|
|
TEST_ASSERT_FALSE(istzugerlaubt_Springer(Brett, 7, 0, 6, 1, PLAYER_WHITE));
|
|
|
|
// Vom Brett springen
|
|
TEST_ASSERT_FALSE(istzugerlaubt_Springer(Brett, 7, 0, 8, 2, PLAYER_WHITE));
|
|
|
|
Schachbrettspeicher_freigeben(Brett);
|
|
}
|
|
#endif // TEST
|