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.

60 lines
994 B

  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[0][7]);
  20. TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[1][0]);
  21. }
  22. void test_read_input(void) {
  23. /* arrange */
  24. const char *input = "8\n";
  25. int result = 0;
  26. int expected = 7;
  27. FILE *original_stdin = freopen(NULL, "r", stdin);
  28. FILE *tempInput = fopen("temp_input.txt", "w");
  29. fputs(input, tempInput);
  30. fclose(tempInput);
  31. tempInput = freopen("temp_input.txt", "r", stdin);
  32. /* act */
  33. result = read_input();
  34. /* assert */
  35. TEST_ASSERT_EQUAL_INT(expected, result);
  36. /* Clean up */
  37. fclose(tempInput);
  38. freopen("/dev/tty", "r", stdin);
  39. freopen(NULL, "r", stdin);
  40. }
  41. #endif // TEST