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.

108 lines
1.9 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 "Bauer.h"
  8. #include <stdlib.h>
  9. void setUp(void) {
  10. }
  11. void tearDown(void) {
  12. }
  13. void test_Bauern_bewegen(void) {
  14. char** brett = Schachbrett_erstellen();
  15. int startX = 0;
  16. int startY = 1;
  17. int endX = 0;
  18. int endY = 2;
  19. Player player = PLAYER_WHITE;
  20. TEST_ASSERT_NOT_NULL(brett);
  21. machezug( brett, startX, startY, endX, endY, player);
  22. print_Schachfeld(brett);
  23. TEST_ASSERT_EQUAL('P', brett[2][0]);
  24. TEST_ASSERT_EQUAL(' ', brett[1][0]);
  25. for (int i = 0; i < 8; i++) {
  26. free(brett[i]);
  27. }
  28. free(brett);
  29. }
  30. void test_Bauer_Y_Verknuepfung_Bewegung(void) {
  31. char** brett = Schachbrett_erstellen();
  32. int startX = 1;
  33. int startY = 1;
  34. int endX = 1;
  35. int endY = 2;
  36. Player player = PLAYER_WHITE;
  37. TEST_ASSERT_NOT_NULL(brett);
  38. TEST_ASSERT_TRUE(istzugerlaubt( brett, startX, startY, endX, endY, player));
  39. for (int i = 0; i < 8; i++) {
  40. free(brett[i]);
  41. }
  42. free(brett);
  43. }
  44. void test_istzugerlaubt(void){
  45. char** brett = Schachbrett_erstellen();
  46. int startX = 1;
  47. int startY = 1;
  48. int endX = 1;
  49. int endY = 1;
  50. Player player = PLAYER_WHITE;
  51. //istzugerlaubt(brett,startX,startY,endX,endY,player);
  52. TEST_ASSERT_FALSE(istzugerlaubt(brett,startX,startY,endX,endY,player));
  53. for (int i = 0; i < 8; i++) {
  54. free(brett[i]);
  55. }
  56. free(brett);
  57. }
  58. void test_istzugerlaubt_Turm(void){
  59. char** brett = Schachbrett_erstellen();
  60. int startX = 0;
  61. int startY = 4;
  62. int endX = 0;
  63. int endY = 2;
  64. Player player = PLAYER_WHITE;
  65. TEST_ASSERT_NOT_NULL(brett);
  66. brett[4][0] = 'r';
  67. print_Schachfeld(brett);
  68. TEST_ASSERT_TRUE(istzugerlaubt(brett, startX, startY, endX, endY, player));
  69. for (int i = 0; i < 8; i++) {
  70. free(brett[i]);
  71. }
  72. free(brett);
  73. }
  74. #endif // TEST