DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Using programming tools

Testing the code

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
    program
With 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 program
In 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
   ttest
testcase 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,
   ttime
That 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.

Next topic: Debugging the code
Previous topic: Using make

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003