Please send questions to st10@humboldt.edu .
//---------------------------------------------------------------
// File: test_heap.cpp
// Name: Sharon M. Tuttle
// last modified: 4-13-05 
//
// Purpose: tester for template class heap<Item>
//--------------------------------------------------------------

#include <iostream>
#include "heap.h"
using namespace std;

int main()
{
    // set-up declarations
    heap<int>    numHeap;
    heap<string> nameHeap;

    // tests and associated cout's

    cout << endl;
    cout << "Testing template class heap..." << endl;
    cout << endl;

    nameHeap.add("Sharon");

    cout << endl;
    cout << "heap should contain Sharon only: " << endl;
    nameHeap.print_heap(1);

    nameHeap.add("Katherine");

    cout << endl;
    cout << "heap should contain Sharon, Katherine: " << endl; 
    nameHeap.print_heap(1);

    nameHeap.add("Thomas");

    cout << endl;
    cout << "heap should contain Sharon, Katherine, Thomas: "  << endl; 
    nameHeap.print_heap(1);

    cout << "1's mean test passed, 0's mean test failed:" << endl;
    cout << "-------------------------------------------" << endl;
    cout << (numHeap.get_size( ) == 0) << endl;
    cout << (nameHeap.get_size( ) == 3) << endl;

    cout << (nameHeap.get_max( ) == "Thomas") << endl;
    
    cout << endl;
    cout << (numHeap.is_empty( ) == true) << endl;
    cout << (nameHeap.is_empty( ) == false) << endl;

    numHeap.add(5);

    cout << endl;
    cout << (numHeap.get_size( ) == 1) << endl;
    cout << (numHeap.is_empty( ) == false) << endl;
    cout << (numHeap.get_max( ) == 5) << endl;

    char dummy;
    cout << "TEST SET 1 COMPLETE; root added " << endl
         << "   type any character to continue: " << endl;
    cin >> dummy;

    numHeap.add(13);

    cout << endl;
    cout << (numHeap.get_size( ) == 2) << endl;
    cout << (numHeap.is_empty( ) == false) << endl;
    cout << (numHeap.get_max( ) == 13) << endl;

    cout << endl;
    cout << "heap should contain 13, 5: " << endl; 
    numHeap.print_heap(1);

    cout << (numHeap.get_max( ) == 13) << endl;

    cout << "TEST SET 2 COMPLETE; left child added" << endl
         << "   type any character to continue: " << endl;
    cin >> dummy;

    numHeap.add(20);

    cout << endl;
    cout << (numHeap.get_size( ) == 3) << endl;
    cout << (numHeap.is_empty( ) == false) << endl;
    cout << (numHeap.get_max( ) == 20) << endl;

    cout << endl;
    cout << "heap should contain 13, 5, 20: " << endl; 
    numHeap.print_heap(1);

    cout << "TEST SET 3 COMPLETE; right child added" << endl
         << "   type any character to continue: " << endl;
    cin >> dummy;

    numHeap.add(17);
    numHeap.add(25);
    
    cout << endl;
    cout << (numHeap.get_size( ) == 5) << endl;
    cout << (numHeap.is_empty( ) == false) << endl;
    cout << (numHeap.get_max( ) == 25) << endl;

    cout << endl;
    cout << "heap should contain 13, 5, 20, 17, 25: " << endl; 
    numHeap.print_heap(2);

    cout << "TEST SET 4 COMPLETE; added 2 more nodes" << endl
         << "   type any character to continue: " << endl;
    cin >> dummy;

    cout << (numHeap.remove_max( ) == 25) << endl;

    cout << endl;
    cout << (numHeap.get_size( ) == 4) << endl;
    cout << (numHeap.is_empty( ) == false) << endl;
    cout << (numHeap.get_max( ) == 20) << endl;

    cout << endl;
    cout << "heap should contain 13, 5, 20, 17: " << endl; 
    numHeap.print_heap(2);

    cout << "TEST SET 5 COMPLETE; tried to remove node" << endl
         << "   type any character to continue: " << endl;
    cin >> dummy;

    cout << (numHeap.remove_max( ) == 20) << endl;

    cout << endl;
    cout << (numHeap.get_size( ) == 3) << endl;
    cout << (numHeap.is_empty( ) == false) << endl;
    cout << (numHeap.get_max( ) == 17) << endl;

    cout << "TEST SET 6 COMPLETE; tried to rm another node" << endl
         << "   type any character to continue: " << endl;
    cin >> dummy;

    numHeap.add(3);
    numHeap.add(1);
    numHeap.add(4);
    numHeap.add(7);
    numHeap.add(6);
    numHeap.add(9);

    cout << endl;
    cout << (numHeap.get_size( ) == 9) << endl;
    cout << (numHeap.is_empty( ) == false) << endl;
    cout << (numHeap.get_max( ) == 17) << endl;

    cout << endl;
    cout << "heap should contain 13, 5, 17, 3, 1, 4, 7, 6, 9: " << endl; 
    numHeap.print_heap(3);

    cout << "TEST SET 11 COMPLETE; tried to add many nodes" << endl
         << "   type any character to continue: " << endl;
    cin >> dummy;

    return EXIT_SUCCESS;
}