|
@ -105,4 +105,50 @@ void test_SchachDurchTurm(void) { |
|
|
|
|
|
|
|
|
freeTestBrett(Brett); |
|
|
freeTestBrett(Brett); |
|
|
} |
|
|
} |
|
|
|
|
|
void test_SchachDurchSpringer(void) { |
|
|
|
|
|
char** Brett = ErstelleTestBrett(); |
|
|
|
|
|
|
|
|
|
|
|
// Weißer König bedroht durch schwarzen Springer |
|
|
|
|
|
Brett[4][4] = 'K'; |
|
|
|
|
|
Brett[3][6] = 'n'; |
|
|
|
|
|
TEST_ASSERT_TRUE(istKoenigImSchach(Brett, PLAYER_WHITE)); |
|
|
|
|
|
|
|
|
|
|
|
freeTestBrett(Brett); |
|
|
|
|
|
Brett = ErstelleTestBrett(); |
|
|
|
|
|
|
|
|
|
|
|
// Schwarzer König bedroht durch weißen Springer |
|
|
|
|
|
Brett[3][3] = 'k'; |
|
|
|
|
|
Brett[5][4] = 'N'; |
|
|
|
|
|
TEST_ASSERT_TRUE(istKoenigImSchach(Brett, PLAYER_BLACK)); |
|
|
|
|
|
|
|
|
|
|
|
freeTestBrett(Brett); |
|
|
|
|
|
Brett = ErstelleTestBrett(); |
|
|
|
|
|
|
|
|
|
|
|
// Weißer könig nicht bedroht |
|
|
|
|
|
Brett[4][4] = 'K'; |
|
|
|
|
|
Brett[7][7] = 'n'; |
|
|
|
|
|
TEST_ASSERT_FALSE(istKoenigImSchach(Brett, PLAYER_WHITE)); |
|
|
|
|
|
|
|
|
|
|
|
freeTestBrett(Brett); |
|
|
|
|
|
Brett = ErstelleTestBrett(); |
|
|
|
|
|
|
|
|
|
|
|
// Schwarzer könig durch mehrere Springer bedroht |
|
|
|
|
|
Brett[0][0] = 'k'; |
|
|
|
|
|
Brett[1][2] = 'N'; |
|
|
|
|
|
Brett[2][1] = 'N'; |
|
|
|
|
|
TEST_ASSERT_TRUE(istKoenigImSchach(Brett, PLAYER_BLACK)); |
|
|
|
|
|
|
|
|
|
|
|
freeTestBrett(Brett); |
|
|
|
|
|
Brett = ErstelleTestBrett(); |
|
|
|
|
|
|
|
|
|
|
|
// Schwarzer König wird trotz Mauer angegriffen |
|
|
|
|
|
Brett[0][0] = 'k'; |
|
|
|
|
|
Brett[0][1] = 'p'; |
|
|
|
|
|
Brett[1][0] = 'p'; |
|
|
|
|
|
Brett[1][1] = 'p'; |
|
|
|
|
|
Brett[1][2] = 'N'; |
|
|
|
|
|
TEST_ASSERT_TRUE(istKoenigImSchach(Brett, PLAYER_BLACK)); |
|
|
|
|
|
|
|
|
|
|
|
freeTestBrett(Brett); |
|
|
|
|
|
} |
|
|
#endif // TEST |
|
|
#endif // TEST |