IDEAS FOR THE DRIVER
FIRST PRINCIPLES:
The most important characteristics of the driver are are:
- The driver must test each new function thoroughly and show
convincingly that it works correctly on a set of inputs that
provides good data coverage and code coverage.
- The driver must have intelligible output: it has to make
very clear exactly what is tested and exactly what are the
results of each test.
MAKING TREES FOR TESTING:
You can create any shape tree you like by using SearchTreeInsert
and your knowledge of how the insertion algorithm works. For
example, if you insert Mary, Thomas, Quinn, Vincent, and Alice in
that order starting with an empty tree then the tree will look
like this:
Mary
/ \
/ \
/ \
/ \
/ \
Alice Thomas
/ \
/ \
Quinn Vincent
Your driver must use printouts of the trees it is testing to help
explain to the reader what each test is doing.
SAMPLE OF THE KIND OF CODE THAT CAN GO INTO A TEST
DRIVER PROGRAM:
#include "BST2.h"
int main ()
{
treeItemType Item ;
bstClass tree, tree2 ;
bool success ;
/* Build tree */
Item.setKey("Mary") ;
tree.SearchTreeInsert(Item, success);
Item.setKey("Gerry") ;
tree.SearchTreeInsert(Item, success);
Item.setKey("Terry") ;
tree.SearchTreeInsert(Item, success);
Item.setKey("Larry") ;
tree.SearchTreeInsert(Item, success);
/* Build tree2 */
Item.setKey("Gerry") ;
tree2.SearchTreeInsert(Item, success);
Item.setKey("Larry") ;
tree2.SearchTreeInsert(Item, success);
Item.setKey("Mary") ;
tree2.SearchTreeInsert(Item, success);
Item.setKey("Terry") ;
tree2.SearchTreeInsert(Item, success);
cout << "Printing tree: " << endl << endl ;
tree.PrintTree() ;
cout << endl ;
cout << "Printing tree2: " << endl << endl ;
tree2.PrintTree() ;
cout << endl ;
cout << "Printing the number of internal nodes in tree: " << endl << endl ;
cout << tree.IntNodeCount() << endl ;
cout << endl ;
cout << "Printing the number of internal nodes in tree2: " << endl << endl ;
cout << tree2.IntNodeCount() << endl ;
cout << endl ;
cout << "Printing levels of tree: " << endl << endl ;
tree.PrintLevels() ;
cout << endl << endl ;
cout << "Printing height of tree2: " << endl << endl ;
cout << tree2.Height() << endl ;
cout << endl ;
return 0 ;
}