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.

91 lines
1.6 KiB

  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "schach.h"
  4. #include "string.h"
  5. void setUp(void)
  6. {
  7. }
  8. void tearDown(void)
  9. {
  10. }
  11. void test_print_Schachfeld(void){
  12. /* arrange */
  13. char expected = 'S';
  14. int x = 8;
  15. int y = 8;
  16. /* act */
  17. char** Spielfeld = create_Schachfeld(x, y);
  18. /* assert */
  19. TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[5][0]);
  20. TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[4][3]);
  21. }
  22. void test_print_Schachfeld_Turm_weiss(void){
  23. /* arrange */
  24. char expected = 'T';
  25. int x = 8;
  26. int y = 8;
  27. /* act */
  28. char** Spielfeld = create_Schachfeld(x, y);
  29. /* assert */
  30. TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[0][0]);
  31. TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[0][7]);
  32. }
  33. void test_print_Schachfeld_dame_schwarz(void){
  34. /* arrange */
  35. char expected = 'd';
  36. int x = 8;
  37. int y = 8;
  38. /* act */
  39. char** Spielfeld = create_Schachfeld(x, y);
  40. /* assert */
  41. TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[7][3]);
  42. //TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[0][7]);
  43. }
  44. void test_read_input(void) {
  45. /* arrange */
  46. const char *input = "8\n";
  47. int result = 0;
  48. int expected = 7;
  49. FILE *original_stdin = freopen(NULL, "r", stdin);
  50. FILE *tempInput = fopen("temp_input.txt", "w");
  51. fputs(input, tempInput);
  52. fclose(tempInput);
  53. tempInput = freopen("temp_input.txt", "r", stdin);
  54. /* act */
  55. result = read_input();
  56. /* assert */
  57. TEST_ASSERT_EQUAL_INT(expected, result);
  58. /* Clean up */
  59. fclose(tempInput);
  60. freopen("/dev/tty", "r", stdin);
  61. freopen(NULL, "r", stdin);
  62. }
  63. #endif // TEST