Please send questions to st10@humboldt.edu .
//---------------------------------------------------------------
// File: test_mergesort.cpp
// Name: Sharon M. Tuttle
// last modified: 3-24-05
//
// Purpose: tester for function mergesort
//--------------------------------------------------------------

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

int main()
{
    // set-up declarations
    node *h1, *h2, *h3;
    int value_array[6] = {3, 6, 2, 9, 1, 5};
    node *temp, *myTail, *result;

    // tests and associated cout's

    cout << endl;
    cout << "Testing function mergesort..." << endl;
    cout << endl;

    cout << "1's mean test passed, 0's mean test failed:" << endl;
    cout << "-------------------------------------------" << endl;
    
    h1 = NULL;
    cout << (mergesort(h1) == NULL) << endl;

    h2 = new node(3);
    cout << (mergesort(h2) == h2) << endl;

    temp = h2;
    cout << endl;
    cout << "should see: 3" << endl;
    while (temp != NULL)
    {
        cout << temp->get_data() << " ";
        temp = temp->get_next();
    }
    cout << endl;
    cout << endl;

    // set up longest list (3 6 2 9 1 5)
    h3 = h2;
    myTail = h3;

    for (int i = 1; i < 6; i++)
    {
        myTail->set_next(new node(value_array[i]));
        myTail = myTail->get_next();
    }
         
    temp = h3;

    cout << "BEFORE mergesort call #3: " << endl;
    cout << "should see: 3 6 2 9 1 5" << endl;
    cout << "do see    : ";
    while (temp != NULL)
    {
        cout << temp->get_data() << " ";
        temp = temp->get_next();
    }
    cout << endl;
    cout << endl;

    result = mergesort(h3);

    cout << "AFTER mergesort call #3: " << endl;
    cout << "should see: 1 2 3 5 6 9" << endl;
    cout << "do see    : ";
    temp = result;
    while (temp != NULL)
    {
        cout << temp->get_data() << " ";
        temp = temp->get_next();
    }
    cout << endl;
    cout << endl;

    return EXIT_SUCCESS;
}