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.

132 lines
2.4 KiB

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