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.

106 lines
1.8 KiB

  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "unistd.h"
  4. #include "Modules.c"
  5. void setUp(void)
  6. {
  7. }
  8. void tearDown(void)
  9. {
  10. }
  11. void test_checkBallPosition_output_if_goal(void)
  12. {
  13. /* arrange */
  14. binX = 1;
  15. binY = 1;
  16. ballX = 1;
  17. ballY = 3;
  18. /* act */
  19. int output = checkBallPosition();
  20. /* assert */
  21. TEST_ASSERT_EQUAL(1, output);
  22. }
  23. void test_checkBallPosition_output_if_no_goal(void)
  24. {
  25. /* arrange */
  26. binX = 1;
  27. binY = 1;
  28. ballX = 1;
  29. ballY = 1;
  30. /* act */
  31. int output = checkBallPosition();
  32. /* assert */
  33. TEST_ASSERT_EQUAL(2, output);
  34. }
  35. void test_sortScoreboard_check_if_file_is_created(void) {
  36. /* arrange */
  37. /* act */
  38. if (access("ScoreBoard.txt", 0) == 0) {
  39. remove("ScoreBoard.txt");
  40. }
  41. sortScoreboard();
  42. int output = access("ScoreBoard.txt", 0);
  43. /* assert */
  44. TEST_ASSERT_EQUAL(0, output);
  45. }
  46. void test_clearField_check_if_Playgroung_clear(void)
  47. {
  48. /* arrange */
  49. field[3][3]='T';
  50. int output = 0;
  51. /* act */
  52. clearField();
  53. for (int i = 0; i < fieldWidth; i++)
  54. {
  55. for (int j = 0; j < fieldHeigth; j++)
  56. {
  57. if(field[i][j] != ' ')
  58. {
  59. output=1;
  60. }
  61. }
  62. }
  63. /* assert */
  64. TEST_ASSERT_EQUAL(0, output);
  65. }
  66. void test_getStartPosition_check_given_position(void)
  67. {
  68. /* arrange */
  69. int output = 0;
  70. int width = 10;
  71. int heigth = 10;
  72. /* act */
  73. buildBin(width, heigth);
  74. if (field[width][heigth] != 'V' ||
  75. field[width + 1][heigth + 1] != '\\' ||
  76. field[width + 2][heigth + 2] != '\\' ||
  77. field[width - 1][heigth + 1] != '/' ||
  78. field[width - 2][heigth + 2] != '/' ||
  79. field[width][heigth + 1] != ' ')
  80. output = 1;
  81. /* assert */
  82. TEST_ASSERT_EQUAL(0, output);
  83. }
  84. #endif // TEST