/*----
  signature: main: void -> int
  purpose: testing program for the class Node

  compile using:
      g++ Node-test.cpp Node.cpp -o Node-test
  run using:
      ./Node-test

  by: Sharon Tuttle
  last modified: 2022-10-27
----*/

#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include "Node.h"
using namespace std;

int main()
{
    cout << boolalpha;

    cout << endl;
    cout << "*** Testing class Node ***" << endl << endl;

    // call each of its constructors, and make
    //    sure each initializes the new object's
    //    data fields correctly

    cout << "constructors' tests: " << endl;

    Node nigel;
    Node tony(73);
    Node nancy(12, &nigel);

    // use accessors to test both constructors
    //    and the accessors also

    cout << "   (and also accessors' tests):"
         << endl;

    // these can be "bunched" or spread out...

    cout << ( (nigel.get_data() == 0)
              && (nigel.get_next() == NULL) ) << endl;

    cout << ( (tony.get_data() == 73)
              && (tony.get_next() == NULL) ) << endl;

    cout << ( (nancy.get_data() == 12)
              && (nancy.get_next() == &nigel) ) << endl;

    // test the mutators

    cout << "\nmutators' tests: " << endl;

    nigel.set_data(12);

    cout << (nigel.get_data() == 12) << endl;

    nigel.set_next(&tony);

    cout << (nigel.get_next() == &tony) << endl;

    // test Node's "other" methods

    cout << "\ntesting \"other\" methods:" << endl;

    cout << "\ntesting display:" << endl;

    // reset nigel to default

    nigel = Node();

    cout << "\ntest succeeds if see: Node: with data: 0 and next: NULL:"
         << endl;

    nigel.display();

    cout << "test succeeds if see: Node: with data: 12 and \n"
         << "    next: " << (&nigel) 
         << endl;

    nancy.display();

    return EXIT_SUCCESS;
}