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

  compile using:
      g++ Path-test.cpp Path.cpp Point.cpp -o Path-test

  run using:
      ./Path-test

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

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

int main()
{
    cout << boolalpha;

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

    // testing (regular) constructors and accessors

    cout << "regular constructors' and accessors' tests:" << endl;

    Path ex_path1;
    Path ex_path2("Example2", 2);

    cout << ( (ex_path1.get_name() == "")
              && (ex_path1.get_size() == 5)
              && (ex_path1.get_point(0).get_x() == 0)
              && (ex_path1.get_point(0).get_y() == 0)
              && (ex_path1.get_point(1).get_x() == 0)
              && (ex_path1.get_point(1).get_y() == 0)
              && (ex_path1.get_point(2).get_x() == 0)
              && (ex_path1.get_point(2).get_y() == 0)
              && (ex_path1.get_point(3).get_x() == 0)
              && (ex_path1.get_point(3).get_y() == 0)
              && (ex_path1.get_point(4).get_x() == 0)
              && (ex_path1.get_point(4).get_y() == 0) )
         << endl;

    cout << ( (ex_path2.get_name() == "Example2")
              && (ex_path2.get_size() == 2)
              && (ex_path2.get_point(0).get_x() == 0)
              && (ex_path2.get_point(0).get_y() == 0)
              && (ex_path2.get_point(1).get_x() == 0)
              && (ex_path2.get_point(1).get_y() == 0) )
         << endl;

    // test mutators

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

    ex_path2.set_name("Example2New");

    cout << (ex_path2.get_name() == "Example2New") << endl;

    Point p1(12.3, 45);
    Point p2(0.7, 10);
    
    ex_path2.set_point(p1, 0);
    ex_path2.set_point(p2, 1);
   
    cout << ( (ex_path2.get_point(0).get_x() == p1.get_x())
              && (ex_path2.get_point(0).get_y() == p1.get_y())
              && (ex_path2.get_point(1).get_x() == p2.get_x())
              && (ex_path2.get_point(1).get_y() == p2.get_y()) ) << endl;

    // then, test your "other" methods

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

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

    cout << "\ntest succeeds if you see path name that's empty, size of 5,"
         << "\n    and five points each with x of 0 and y of 0: " << endl;

    Path a_path;

    a_path.display();

    cout << "test succeeds if you see name of Example2New, "
         << "\n    size of 2, and two points,"
         << "\n    *   one with x of 12.3 and y of 45"
         << "\n    *   one with x of 0.7 and y of 10:" << endl;

    ex_path2.display();

    cout << "testing copy constructor:" << endl;

    ex_path2.set_name("Journey");

    Path ex_path3 = ex_path2;

    Point new_end(25, 35);
    ex_path3.set_point(new_end, 1);

    cout << (ex_path2.get_name() == ex_path3.get_name()) << endl;
    cout << (ex_path2.get_size() == ex_path3.get_size()) << endl;    
    
    cout << endl << "ex_path3 had 2nd point changed to (25, 35)"
         << endl; 

    cout << "\nnext part of test succeeds if you see name of Journey, "
         << "\n    size of 2, and 2 points,"
         << "\n    *   x of 12.3, y of 45"
         << "\n    *   x of 25, y of 35:" << endl;

    cout << "ex_path3: ";
    ex_path3.display();

    cout << "next part of test succeeds if you see name of Journey, "
         << "\n    size of 2, and 2 points,"
         << "\n    *   x of 12.3, y of 45"
         << "\n    *   x of 0.7, y of 10:" << endl;

    cout << "ex_path2: ";
    ex_path2.display();
    
    cout << "testing overloaded assignment operator:" << endl;    

    ex_path3.set_name("Shopping Route");
    
    ex_path1 = ex_path3;

    cout << (ex_path1.get_size() == ex_path3.get_size()) << endl;
    cout << (ex_path1.get_name() == ex_path3.get_name()) << endl;

    Point first_stop(5.5, 6.6);
    ex_path3.set_point(first_stop, 0);

    cout << "\nnext part of test succeeds if you see name of Shopping Route, "
         << "\n    size of 2, and 2 points,"
         << "\n    *   x of 5.5, y of 6.6"
         << "\n    *   x of 25,  y of 35" << endl;

    cout << "ex_path3:";
    ex_path3.display();

    cout << "next part of test succeeds if you see name of Shopping Route, "
         << "\n    size of 2, and 2 players,"
         << "\n    *   x of 12.3, y of 45"
         << "\n    *   x of 25,  y of 35" << endl;

    cout << "ex_path1:";
    ex_path1.display();
    
    return EXIT_SUCCESS;
}