|
|
|
|
|
|
|
Testing: To test this program, we begin by preparing an input file that contains time card information for, say, five employees. The data should be in random order of employee ID to make sure that the sorting routine works properly. Using this input file, we run the program and supply the following interactive input: the ID numbers of all five employees in the data file (the program should print their punch-in times), a few ID numbers that are not in the data file (the program should print the message that these employees have not checked in yet), and a negative ID number (the program should quit). If the program tells us that one of the five employees in the data file has not checked in yet or prints a punch-in time for one of the employees not in the data file, the fault clearly lies with the punchInList objectthe object responsible for reading the file, sorting, and searching. Using a hand trace, debug output statements, or the system debugger, we should check the TimeCardList member functions in the following order: ReadAll (to verify that the file data was read into the list correctly), SelSort (to confirm that the time card information ends up in ascending order of ID number), then BinSearch (to ensure that items in the list are indeed found and that items not in the list are reported as not there). |
|
|
|
|
|
|
|
|
One more thing needs to be tested. If the data file contains more than MAX_LENGTH time cards, the ReadAll function should print a warning message and ignore the excess time cards. To test this feature, we obviously don't want to create an input file with over 500 time cards. Instead, we go into tclist.h and change the const definition of MAX_LENGTH from 500 to a more manageable value3, for example. We then recompile only tclist.cpp and relink all four object code files. When we run the program, it should read only the first three time cards from the file, print a warning message, and work with a list of only three time cards. Here is a sample run of the program using 3 as the value of MAX_LENGTH: |
|
|
|
|
|
|
|
|
398405 7 45 04
290387 7 48 10
193847 7 53 20
938473 7 55 14
837485 8 00 00
385473 8 05 45
573920 8 12 13
483948 8 14 45 |
|
|
|
|
|
|
|
|
Copy of the Screen During the Run |
|
|
|
|
|
|
|
|
Input file name: punchin.dat
More than 3 time cards in input file. Remainder are ignored.
|
|
|
|
|
|