|
|
Even though testcase has compiled without errors,
we cannot be sure that the program logic is correct.
The only way to ensure that the logic is correct
and the program does what is intended,
is to test it thoroughly. Any errors revealed by testing
must, of course, be corrected.
Because testcase is a small, simple program,
we can test it by simply running it on selected input
and verifying that the output is what we expect.
Larger, more complex programs
benefit from a more rigorous testing procedure.
Test testcase with the following command line and input (bold typeface indicates user input):
testcase this is a test of the testcase program this is a test of the testcase programWith no character argument specified, testcase responds with one word per line, as expected. Test the option to testcase with the following command line and input:
testcase -t this is a test of the testcase programIn this example, with the -t as an argument, testcase should have printed out only words with the character t in it; it did not. This deserves further exploration. Run testcase with the following input:
testcase -t this is a ttest of the testcase program ttesttestcase seems to be printing out words that have double occurrences of the specified character, t. Try it with the following input just to make sure:
testcase -t attention, the ttime is at hand attention, ttimeThat seems to be the problem with our program. Now that we have identified the problem, we have to find out where in the source code the problem occurs. Fortunately, the Development System provides the tools to debug source code.