I have written a console application that waits for the user char input.
application has function:
typedef char *ProcessedDataType;
extern ProcessedDataType askUserInput(void){
int i = getchar();
ProcessedDataType local_var = userInputProcessed(i);
return ProcessedDataType;
}
static ProcessedDataType userInputProcessed(int i){
...
return PocessedDataType;
}
Now, I would like to test this function for several inputs. So where normally the cursor would be blinking for user input, now, automatically, entries from a file that contains the choice letters returns. This would then be asserted against the known result.
runTest{
// when console gets input 'A'
ProcessedDataType local_var = askUserInput();
assert('ProcessedA' == local_var); }
// when console gets input 'B'
ProcessedDataType local_var = askUserInput();
assert('ProcessedB' == local_var); }
// when console gets input 'C'
ProcessedDataType local_var = askUserInput();
assert('ProcessedC' == local_var); }
How do I provide the same string parameters to this function when testing? How do I 'feed' the console the inputs A, B, C, etc ...
I do not want to use Preprocessors as here: How to unit test c functions involving IO?