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.

98 lines
1.6 KiB

  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "Schachbrett.h"
  4. #include "Spieler.h"
  5. #include "Turm.h"
  6. #include <stdlib.h>
  7. void setUp(void) {
  8. }
  9. void tearDown(void) {
  10. }
  11. void test_Turm_Y_Bewegung(void) {
  12. char** brett = Schachbrett_erstellen();
  13. int startX = 0;
  14. int startY = 0;
  15. int endX = 0;
  16. int endY = 3;
  17. Player player = PLAYER_WHITE;
  18. TEST_ASSERT_NOT_NULL(brett);
  19. brett[1][0] = ' ';
  20. brett[2][0] = ' ';
  21. brett[3][0] = ' ';
  22. print_Schachfeld(brett);
  23. TEST_ASSERT_TRUE(istzugerlaubt_Turm( brett, startX, startY, endX, endY, player));
  24. for (int i = 0; i < 8; i++) {
  25. free(brett[i]);
  26. }
  27. free(brett);
  28. }
  29. void test_Turm_X_Bewegung(void) {
  30. char** brett = Schachbrett_erstellen();
  31. int startX = 0;
  32. int startY = 2;
  33. int endX = 4;
  34. int endY = 2;
  35. Player player = PLAYER_WHITE;
  36. TEST_ASSERT_NOT_NULL(brett);
  37. brett[2][0] = 'R';
  38. print_Schachfeld(brett);
  39. TEST_ASSERT_TRUE(istzugerlaubt_Turm( brett, startX, startY, endX, endY, player));
  40. for (int i = 0; i < 8; i++) {
  41. free(brett[i]);
  42. }
  43. free(brett);
  44. }
  45. void test_Turm_negative_Y_Bewegung(void) {
  46. char** brett = Schachbrett_erstellen();
  47. int startX = 0;
  48. int startY = 4;
  49. int endX = 0;
  50. int endY = 2;
  51. Player player = PLAYER_WHITE;
  52. TEST_ASSERT_NOT_NULL(brett);
  53. brett[4][0] = 'r';
  54. print_Schachfeld(brett);
  55. TEST_ASSERT_TRUE(istzugerlaubt_Turm(brett, startX, startY, endX, endY, player));
  56. for (int i = 0; i < 8; i++) {
  57. free(brett[i]);
  58. }
  59. free(brett);
  60. }
  61. #endif // TEST