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.

85 lines
1.5 KiB

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