#include <iostream>
#include <vector>
#include <fstream>

using namespace std;

#include <point.h>
#include <pointtest.h>



void pointtest::test01()
{

  double v[12] = 
  { 1.0,2.0,3.0,
    4.0,5.0,6.0,
    7.0,8.0,9.0,
    10.0,11.0,12.5
  };

  vector<point3<double> > w;

  point3<double>::readin(w,v,v+sizeof(v)/sizeof(double));

  for (unsigned int i=0; i<w.size(); ++i)
    cout << w[i] << endl;

  cout << endl;
}

typedef point4<double> pt4;

void pointtest::test02()
{
  vector< pt4 > v;

  v.push_back( pt4(.2,.5,.3,.7) );
  v.push_back( pt4(.7,.5,.8,.9) );
  v.push_back( pt4(.3,.4,.8,.183) );
  v.push_back( pt4(.3,.01,.2,.1) );

  cout << "Writing points to file." << endl;

  {
    ofstream f1("f1.txt");
    f1 << v.size() << endl;
    for (uint i=0; i<v.size(); ++i)
      f1 << v[i] << endl;
  }

  cout << "Reading points in from the file." << endl;
  vector< pt4 > v2;
  {
    ifstream f2("f1.txt");
    int sz;
    f2 >> sz;
    pt4 x;
    for (int i=0; i<sz; ++i)
    {
      f2 >> x;  
      cout << x << endl;
    }
  } 
}

void pointtest::test03()
{
  cout << "Testing string serialization" << endl;

  point2<double> p(.3,.5);
  string s = p;
  cout << "s=" << s << endl;
  cout << "Now the inverse" << endl;
  point2<double> p2;
  p2.serializeInverse(s);
  cout << "p2=" << p2 << endl;

  cout << endl << endl;
  point3<int> p3(3,-5,12);
  s = p3;
  cout << "s=" << s << endl;
  cout << "Now the inverse" << endl;
  point3<int> p4;
  p4.serializeInverse(s);
  cout << "p4=" << p4 << endl << endl;

}




