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.

129 lines
2.3 KiB

  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "Schachbrett.h"
  4. #include "Spieler.h"
  5. #include "Bauer.h"
  6. #include <stdlib.h>
  7. void setUp(void) {
  8. }
  9. void tearDown(void) {
  10. }
  11. void test_Bauer_X_Bewegung(void) {
  12. char** brett = Schachbrett_erstellen();
  13. int startX = 1;
  14. int startY = 1;
  15. int endX = 2;
  16. int endY = 1;
  17. Player player = PLAYER_WHITE;
  18. TEST_ASSERT_NOT_NULL(brett);
  19. TEST_ASSERT_FALSE(istzugerlaubt_Bauer( brett, startX, startY, endX, endY, player));
  20. for (int i = 0; i < 8; i++) {
  21. free(brett[i]);
  22. }
  23. free(brett);
  24. }
  25. void test_Bauer_Schlag_Bewegung(void) {
  26. char** brett = Schachbrett_erstellen();
  27. int startX = 6;
  28. int startY = 2;
  29. int endX = 5;
  30. int endY = 3;
  31. Player player = PLAYER_WHITE;
  32. TEST_ASSERT_NOT_NULL(brett);
  33. brett[startY][startX] = 'P';
  34. brett[endY][endX] = 'p';
  35. print_Schachfeld(brett,8,8);
  36. TEST_ASSERT_FALSE(istzugerlaubt_Bauer( brett, startX, startY, endX, endY, player));
  37. for (int i = 0; i < 8; i++) {
  38. free(brett[i]);
  39. }
  40. free(brett);
  41. }
  42. void test_Bauer_Schwarz_Y_Bewegung(void) {
  43. char** brett = Schachbrett_erstellen();
  44. int startX = 1;
  45. int startY = 6;
  46. int endX = 1;
  47. int endY = 5;
  48. Player player = PLAYER_BLACK;
  49. TEST_ASSERT_NOT_NULL(brett);
  50. TEST_ASSERT_TRUE(istzugerlaubt_Bauer( brett, startX, startY, endX, endY, player));
  51. for (int i = 0; i < 8; i++) {
  52. free(brett[i]);
  53. }
  54. free(brett);
  55. }
  56. void test_Bauer_Y_Bewegung(void) {
  57. char** brett = Schachbrett_erstellen();
  58. int startX = 1;
  59. int startY = 1;
  60. int endX = 1;
  61. int endY = 2;
  62. Player player = PLAYER_WHITE;
  63. TEST_ASSERT_NOT_NULL(brett);
  64. TEST_ASSERT_TRUE(istzugerlaubt_Bauer( brett, startX, startY, endX, endY, player));
  65. for (int i = 0; i < 8; i++) {
  66. free(brett[i]);
  67. }
  68. free(brett);
  69. }
  70. void test_Bauer_Start_Bewegung(void) {
  71. char** brett = Schachbrett_erstellen();
  72. int startX = 2;
  73. int startY = 1;
  74. int endX = 2;
  75. int endY = 3;
  76. Player player = PLAYER_WHITE;
  77. TEST_ASSERT_NOT_NULL(brett);
  78. TEST_ASSERT_TRUE(istzugerlaubt_Bauer( brett, startX, startY, endX, endY, player));
  79. for (int i = 0; i < 8; i++) {
  80. free(brett[i]);
  81. }
  82. free(brett);
  83. }
  84. #endif // TEST