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
34 lines
750 B
#ifdef TEST
|
|
#include <stdlib.h>
|
|
#include "unity.h"
|
|
#include "Input.h"
|
|
|
|
|
|
void setUp(void) {
|
|
}
|
|
|
|
void tearDown(void) {
|
|
}
|
|
|
|
void test_getUserInput(void) {
|
|
|
|
const char *test_input = "a1";
|
|
FILE *tempInputFile;
|
|
// Datei erstellen
|
|
tempInputFile = fopen("temp_input.txt", "w");
|
|
fprintf(tempInputFile, "%s\n", test_input);
|
|
fclose(tempInputFile);
|
|
|
|
// aus der Datei lesen um User input zu simulieren
|
|
tempInputFile = freopen("temp_input.txt", "r", stdin);
|
|
|
|
|
|
char *actual_input = getUserInput();
|
|
TEST_ASSERT_EQUAL_STRING(test_input, actual_input);
|
|
|
|
//Clean-up
|
|
free(actual_input); // siehe kommentar in input.c
|
|
fclose(tempInputFile);
|
|
remove("temp_input.txt"); // Datei automatisch löschen
|
|
}
|
|
#endif // TEST
|