Ideas for a Test Plan



* For example your plan to test the "Ancestor" operation might
  say something like:

  + Test the following types of trees: empty tree, tree with
    one node, tree with several nodes.

  + Test the tree with one node in two ways:  Ask for the
    ancestors of a node that is in the tree, and ask for the
    ancestors of a node that is not in the tree.

  + Test the tree with several nodes in the following ways:
    - Ask for the ancestors of a leaf node
    - Ask for the ancestors of an internal node that is not the
      root.
    - Ask for the ancestors of the root.
    - Ask for the ancestors of a node that is not in the tree.
    
Your driver program can create binary search tree variables
with statements like:

bstClass tree1 ;

You could then do 

cout << "Now testing \"Ancestor\" in an empty tree..." << endl ;

tree1.Ancestor("Mary") ;

bool success ;

tree1.SearchTreeInsert("Mary", success) ;

if (!success) cout << "Insertion failed." << endl ;

cout << "Now testing \"Ancestor\" in a tree with one node ..." << endl ;
cout << "This is how the tree appears: " << endl ;

tree1.PrintTree()

cout << "Here is the case where the key \"Mary\" is in the tree..." << endl ;

tree1.Ancestor("Mary") ;

cout << "Testing \"Ancestor\" again the tree with one node ..." << endl ;
cout << "Here is the case where the key \"Joe\" is NOT in the tree..." ;
cout << endl ;

tree1.Ancestor("Joe") ;


And so on....

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, and
Quinn, in that order starting with an empty tree then the tree
will look like this:

         Mary
              \
                \
               Thomas
               /
             /
       Quinn

Depending on what you are testing at a given time, you can and
should use printouts of the actual tree to help explain the
reader understand what the test is doing.

The most important things are:

* The driver has to test your new functions and do a good job of
  verifying that the functions do not have any bugs.

* The output of the driver has to be intelligible.  It does no
  good to test a program if the test procedure does not
  communicate the results of the test.  The output has to do a
  good job of explaining what is being tested and what the
  result of the tests are.