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.

34 lines
750 B

  1. #ifdef TEST
  2. #include <stdlib.h>
  3. #include "unity.h"
  4. #include "Input.h"
  5. void setUp(void) {
  6. }
  7. void tearDown(void) {
  8. }
  9. void test_getUserInput(void) {
  10. const char *test_input = "a1";
  11. FILE *tempInputFile;
  12. // Datei erstellen
  13. tempInputFile = fopen("temp_input.txt", "w");
  14. fprintf(tempInputFile, "%s\n", test_input);
  15. fclose(tempInputFile);
  16. // aus der Datei lesen um User input zu simulieren
  17. tempInputFile = freopen("temp_input.txt", "r", stdin);
  18. char *actual_input = getUserInput();
  19. TEST_ASSERT_EQUAL_STRING(test_input, actual_input);
  20. //Clean-up
  21. free(actual_input); // siehe kommentar in input.c
  22. fclose(tempInputFile);
  23. remove("temp_input.txt"); // Datei automatisch löschen
  24. }
  25. #endif // TEST