I'm supposed to create a test driver for this program but I have no idea what exactly that entails. I've looked at the test driver tutorial that pops up on google but I don't understand what it's telling me. I'm fairly certain that this code works and would assume that drivers are for larger and more complex programs but I don't know what I need to do to make a driver. I'm supposed to loop the data so that I enter test data for the below. Would I create constant values that simply loop through the functions every time I build this or what? Any help is appreciated.
low income, < 20 minutes
low income, > 20 minutes
high income, < 20 minutes
high income, > 20 minutes.
The first step is normally to take paper and pen or maybe a spreadsheet and create some test data. That means the input and the expected output. Then you run the code and check that the actual output is == expected output.
For example:
1 2 3 4 5 6 7 8 9 10 11 12
void TestLowIncomeAndShortTime()
{
double minutes = 12;
double income = 1899;
double expected; // set to correct value
double result; // get the result from the function
if (expected == result)
// handle success
else
// handle failure
}
Create functions like this for all cases and run them in main.
If you need to make any changes in your calculation it's easy to run the test with the same test data again.