Browse Source

Feldsicherheit fertig + tests, Anton Lohrey

remotes/origin/Läufer-fertig,-Hendrik-Voß
fdai7492 11 months ago
parent
commit
4f9f666099
  1. 3
      src/Koenig.c
  2. 29
      test/test_Feldsicherheit.c

3
src/Koenig.c

@ -229,7 +229,8 @@ bool istzugerlaubt_Koenig(char** Brett, int startX, int startY, int endX, int en
if (player == PLAYER_BLACK && islower(endPosition))
return false;
// mehr checks noch benötigt
if (istFeldUnsicher(Brett, endX, endY, player))
return false;
return true;
}

29
test/test_Feldsicherheit.c

@ -162,5 +162,34 @@ void test_GreiftKoenigAn(void) {
freeTestBrett(Brett);
}
void test_istFeldUnsicher(void) {
char** Brett = ErstelleTestBrett();
Brett[4][4] = 'p';
print_Schachfeld(Brett);
TEST_ASSERT_TRUE(istFeldUnsicher(Brett, 5, 3, player));
TEST_ASSERT_FALSE(istFeldUnsicher(Brett, 0, 0, player));
Brett[4][4] = ' ';
Brett[0][1] = 'N';
player = PLAYER_BLACK;
TEST_ASSERT_TRUE(istFeldUnsicher(Brett, 2, 2, player));
TEST_ASSERT_FALSE(istFeldUnsicher(Brett, 0, 0, player));
Brett[0][1] = ' ';
Brett[7][0] = 'r';
player = PLAYER_WHITE;
TEST_ASSERT_TRUE(istFeldUnsicher(Brett, 0, 0, player));
TEST_ASSERT_FALSE(istFeldUnsicher(Brett, 4, 4, player));
Brett[7][0] = ' ';
Brett[3][3] = 'Q';
player = PLAYER_BLACK;
TEST_ASSERT_TRUE(istFeldUnsicher(Brett, 7, 7, player));
TEST_ASSERT_TRUE(istFeldUnsicher(Brett, 3, 0, player));
freeTestBrett(Brett);
}
#endif // TEST
Loading…
Cancel
Save