/*

  Copyright (C) 2004  Betti Österholz

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2, June 1991, of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#include <iostream>
#include <sstream>
#include <string>
#include <list>


#include "CCheck.h"
#include "CDoubleOut.h"

#include "Conc.h"
#include "Function.h"
#include "Area.h"
#include "Point.h"

#include "Color.h"
#include "Position.h"
#include "UnderFunction.h"
#include "UnderArea.h"

void testVector()
{

CDoubleOut dout=CDoubleOut();
CCheck ch=CCheck();
//char yesno;
stringstream strstr;
stringstream ostrstr;
double* dp1;

dout.Print("\n\nCase 1 :");
dout.Print("\nrequire: class Color");
dout.Print("\nensure: the Color with 0 values");
dout.Print("\nChecks if the standart construktor initializes the Color with 0 values");
dout.Print("\n\nColor col1=Color();");
Color col1=Color();
ch.Check((string)"col1.classnameOf() ",col1.classnameOf(),"Color");
ch.Check((string)"col1.getNumberOfComponents() ",col1.getNumberOfComponents(),3);
ch.Check((string)"col1.getNumberOfValue() ",col1.getNumberOfValue(),3);
ch.Check((string)"col1.getNumberOfVariable() ",col1.getNumberOfVariable(),0);
ch.Check((string)"(*col1.getComponentPointer(1)) ",(*col1.getComponentPointer(1)),0.0);
ch.Check((string)"(*col1.getComponentPointer(2)) ",(*col1.getComponentPointer(2)),0.0);
ch.Check((string)"(*col1.getComponentPointer(3)) ",(*col1.getComponentPointer(3)),0.0);
ch.Check((string)"col1.isComponentValue(1) ",col1.isComponentValue(1),true);
ch.Check((string)"col1.isComponentValue(2) ",col1.isComponentValue(2),true);
ch.Check((string)"col1.isComponentValue(3) ",col1.isComponentValue(3),true);
ch.Check((string)"col1.classnameOf() ",col1.classnameOf(),"Color");
dout.Print("col1.store(0,ostrstr) \n");
unsigned int i1=0;
col1.store(i1,strstr);
cout<<strstr.str();//rdbuf() str()
dout.Print("\nIs this the right string for the vector? (Y/N) ");
//cin>>yesno;
//dout.Printb((yesno=='y')||(yesno=='Y'));

dout.Print("dp1=getComponentPointer(2); ");//set a component pointer new
dp1=col1.getComponentPointer(2);
dout.Print("dp1=10; ");
(*dp1)=10.0;
ch.Check((string)"col1.getNumberOfComponents() ",col1.getNumberOfComponents(),3);
ch.Check((string)"col1.getNumberOfValue() ",col1.getNumberOfValue(),3);
ch.Check((string)"col1.getNumberOfVariable() ",col1.getNumberOfVariable(),0);
ch.Check((string)"(*col1.getComponentPointer(1)) ",(*col1.getComponentPointer(1)),0.0);
ch.Check((string)"(*col1.getComponentPointer(2)) ",(*col1.getComponentPointer(2)),10.0);
ch.Check((string)"(*col1.getComponentPointer(3)) ",(*col1.getComponentPointer(3)),0.0);
ch.Check((string)"col1.isComponentValue(1) ",col1.isComponentValue(1),true);
ch.Check((string)"col1.isComponentValue(2) ",col1.isComponentValue(2),true);
ch.Check((string)"col1.isComponentValue(3) ",col1.isComponentValue(3),true);
ch.Check((string)"col1.getGreatness() ",col1.getGreatness(),3);
ch.Check((string)"col1.getTimeNeed() ",col1.getTimeNeed(),3);


dout.Print("double dp2=new double(35) ");
double* dp2=new double(35);
ch.Check((string)"col1.setValueToVariable(1, dp2) ",col1.setValueToVariable(1, dp2),true);
ch.Check((string)"col1.getNumberOfComponents() ",col1.getNumberOfComponents(),3);
ch.Check((string)"col1.getNumberOfValue() ",col1.getNumberOfValue(),2);
ch.Check((string)"col1.getNumberOfVariable() ",col1.getNumberOfVariable(),1);
ch.Check((string)"(*col1.getComponentPointer(1)) ",(*col1.getComponentPointer(1)),35.0);
ch.Check((string)"(*col1.getComponentPointer(2)) ",(*col1.getComponentPointer(2)),10.0);
ch.Check((string)"(*col1.getComponentPointer(3)) ",(*col1.getComponentPointer(3)),0.0);
ch.Check((string)"col1.isComponentValue(1) ",col1.isComponentValue(1),false);
ch.Check((string)"col1.isComponentValue(2) ",col1.isComponentValue(2),true);
ch.Check((string)"col1.isComponentValue(3) ",col1.isComponentValue(3),true);
ch.Check((string)"col1.getGreatness() ",col1.getGreatness(),3);
ch.Check((string)"col1.getTimeNeed() ",col1.getTimeNeed(),3);
dout.Print("col1.store(0,ostrstr) \n");
col1.store(i1,ostrstr);
cout<<ostrstr.str();
dout.Print("\nIs this the right string for the vector? (Y/N) ");
//cin>>yesno;
//dout.Printb((yesno=='y')||(yesno=='Y'));
dout.Print("(*dp2)=17 ");
(*dp2)=17;
ch.Check((string)"(*col1.getComponentPointer(1)) ",(*col1.getComponentPointer(1)),17.0);
ch.Check((string)"col1.getValue(1) ",col1.getValue(1),10);
ch.Check((string)"col1.getValue(1) ",col1.getValue(2),0);
ch.Check((string)"col1.getVariable(1)==dp2 ",(col1.getVariable(1)==dp2),true);


dout.Print("\ndouble dp3=new double(25) ");
double* dp3=new double(25);
ch.Check((string)"col1.setValueToVariable(2, dp3) ",col1.setValueToVariable(2, dp3),true);
ch.Check((string)"col1.getNumberOfComponents() ",col1.getNumberOfComponents(),3);
ch.Check((string)"col1.getNumberOfValue() ",col1.getNumberOfValue(),1);
ch.Check((string)"col1.getNumberOfVariable() ",col1.getNumberOfVariable(),2);
ch.Check((string)"(*col1.getComponentPointer(1)) ",(*col1.getComponentPointer(1)),17.0);
ch.Check((string)"(*col1.getComponentPointer(2)) ",(*col1.getComponentPointer(2)),10.0);
ch.Check((string)"(*col1.getComponentPointer(3)) ",(*col1.getComponentPointer(3)),25.0);
ch.Check((string)"col1.isComponentValue(1) ",col1.isComponentValue(1),false);
ch.Check((string)"col1.isComponentValue(2) ",col1.isComponentValue(2),true);
ch.Check((string)"col1.isComponentValue(3) ",col1.isComponentValue(3),false);
ch.Check((string)"col1.getValue(1) ",col1.getValue(1),10);
ch.Check((string)"col1.getVariable(1)==dp2 ",(col1.getVariable(1)==dp2),true);
ch.Check((string)"col1.getVariable(2)==dp3 ",(col1.getVariable(2)==dp3),true);


//test copy constructor
dout.Print("\n\nColor col2=Color(col1);");
Color col2=Color(col1);
ch.Check((string)"col2.getNumberOfComponents() ",col2.getNumberOfComponents(),3);
ch.Check((string)"col2.getNumberOfValue() ",col2.getNumberOfValue(),1);
ch.Check((string)"col2.getNumberOfVariable() ",col2.getNumberOfVariable(),2);
ch.Check((string)"(*col2.getComponentPointer(1)) ",(*col2.getComponentPointer(1)),17.0);
ch.Check((string)"(*col2.getComponentPointer(2)) ",(*col2.getComponentPointer(2)),10.0);
ch.Check((string)"(*col2.getComponentPointer(3)) ",(*col2.getComponentPointer(3)),25.0);
ch.Check((string)"col2.isComponentValue(1) ",col2.isComponentValue(1),false);
ch.Check((string)"col2.isComponentValue(2) ",col2.isComponentValue(2),true);
ch.Check((string)"col2.isComponentValue(3) ",col2.isComponentValue(3),false);

dout.Print("\n(*dp3)=13; Same Variable in col1 and col2?");
(*dp3)=13;
ch.Check((string)"col2.getNumberOfComponents() ",col2.getNumberOfComponents(),3);
ch.Check((string)"col2.getNumberOfValue() ",col2.getNumberOfValue(),1);
ch.Check((string)"col2.getNumberOfVariable() ",col2.getNumberOfVariable(),2);
ch.Check((string)"(*col2.getComponentPointer(1)) ",(*col2.getComponentPointer(1)),17.0);
ch.Check((string)"(*col2.getComponentPointer(2)) ",(*col2.getComponentPointer(2)),10.0);
ch.Check((string)"(*col2.getComponentPointer(3)) ",(*col2.getComponentPointer(3)),13.0);
ch.Check((string)"col2.isComponentValue(1) ",col2.isComponentValue(1),false);
ch.Check((string)"col2.isComponentValue(2) ",col2.isComponentValue(2),true);
ch.Check((string)"col2.isComponentValue(3) ",col2.isComponentValue(3),false);
ch.Check((string)"col1.getNumberOfComponents() ",col1.getNumberOfComponents(),3);
ch.Check((string)"col1.getNumberOfValue() ",col1.getNumberOfValue(),1);
ch.Check((string)"col1.getNumberOfVariable() ",col1.getNumberOfVariable(),2);
ch.Check((string)"(*col1.getComponentPointer(1)) ",(*col1.getComponentPointer(1)),17.0);
ch.Check((string)"(*col1.getComponentPointer(2)) ",(*col1.getComponentPointer(2)),10.0);
ch.Check((string)"(*col1.getComponentPointer(3)) ",(*col1.getComponentPointer(3)),13.0);
ch.Check((string)"col1.isComponentValue(1) ",col1.isComponentValue(1),false);
ch.Check((string)"col1.isComponentValue(2) ",col1.isComponentValue(2),true);
ch.Check((string)"col1.isComponentValue(3) ",col1.isComponentValue(3),false);


dout.Print("\nNot same value pointer in col1 and col2\n?");
ch.Check((string)"col2.setValueToValue(1, 6) ",col2.setValueToValue(1, 6),true);
ch.Check((string)"col2.getNumberOfComponents() ",col2.getNumberOfComponents(),3);
ch.Check((string)"col2.getNumberOfValue() ",col2.getNumberOfValue(),1);
ch.Check((string)"col2.getNumberOfVariable() ",col2.getNumberOfVariable(),2);
ch.Check((string)"(*col2.getComponentPointer(1)) ",(*col2.getComponentPointer(1)),17.0);
ch.Check((string)"(*col2.getComponentPointer(2)) ",(*col2.getComponentPointer(2)),6.0);
ch.Check((string)"(*col2.getComponentPointer(3)) ",(*col2.getComponentPointer(3)),13.0);
ch.Check((string)"col2.isComponentValue(1) ",col2.isComponentValue(1),false);
ch.Check((string)"col2.isComponentValue(2) ",col2.isComponentValue(2),true);
ch.Check((string)"col2.isComponentValue(3) ",col2.isComponentValue(3),false);
ch.Check((string)"col1.getNumberOfComponents() ",col1.getNumberOfComponents(),3);
ch.Check((string)"col1.getNumberOfValue() ",col1.getNumberOfValue(),1);
ch.Check((string)"col1.getNumberOfVariable() ",col1.getNumberOfVariable(),2);
ch.Check((string)"(*col1.getComponentPointer(1)) ",(*col1.getComponentPointer(1)),17.0);
ch.Check((string)"(*col1.getComponentPointer(2)) ",(*col1.getComponentPointer(2)),10.0);
ch.Check((string)"(*col1.getComponentPointer(3)) ",(*col1.getComponentPointer(3)),13.0);
ch.Check((string)"col1.isComponentValue(1) ",col1.isComponentValue(1),false);
ch.Check((string)"col1.isComponentValue(2) ",col1.isComponentValue(2),true);
ch.Check((string)"col1.isComponentValue(3) ",col1.isComponentValue(3),false);
ch.Check((string)"col2.isUsedVariable(dp3) ",col2.isUsedVariable(dp3),true);




dout.Print("\n\nColor col3=Color();");
Color col3=Color();
ch.Check((string)"col3.getNumberOfComponents() ",col3.getNumberOfComponents(),3);
ch.Check((string)"col3.getNumberOfValue() ",col3.getNumberOfValue(),3);
ch.Check((string)"col3.getNumberOfVariable() ",col3.getNumberOfVariable(),0);
ch.Check((string)"(*col3.getComponentPointer(1)) ",(*col3.getComponentPointer(1)),0.0);
ch.Check((string)"(*col3.getComponentPointer(2)) ",(*col3.getComponentPointer(2)),0.0);
ch.Check((string)"(*col3.getComponentPointer(3)) ",(*col3.getComponentPointer(3)),0.0);
ch.Check((string)"col3.isComponentValue(1) ",col3.isComponentValue(1),true);
ch.Check((string)"col3.isComponentValue(2) ",col3.isComponentValue(2),true);
ch.Check((string)"col3.isComponentValue(3) ",col3.isComponentValue(3),true);
ch.Check((string)"col3.changeValueAbout(2, 7) ",col3.changeValueAbout(2, 7),true);
ch.Check((string)"col3.getNumberOfComponents() ",col3.getNumberOfComponents(),3);
ch.Check((string)"col3.getNumberOfValue() ",col3.getNumberOfValue(),3);
ch.Check((string)"col3.getNumberOfVariable() ",col3.getNumberOfVariable(),0);
ch.Check((string)"(*col3.getComponentPointer(1)) ",(*col3.getComponentPointer(1)),0.0);
ch.Check((string)"(*col3.getComponentPointer(2)) ",(*col3.getComponentPointer(2)),7.0);
ch.Check((string)"(*col3.getComponentPointer(3)) ",(*col3.getComponentPointer(3)),0.0);
ch.Check((string)"col3.isComponentValue(1) ",col3.isComponentValue(1),true);
ch.Check((string)"col3.isComponentValue(2) ",col3.isComponentValue(2),true);
ch.Check((string)"col3.isComponentValue(3) ",col3.isComponentValue(3),true);
dout.Print("\ndouble dp4=new double(4) \n");
double* dp4=new double(4);

//col3.setValueToVariable(1, dp4);
ch.Check((string)"col3.setValueToVariable(1, dp4) ",col3.setValueToVariable(1, dp4),true);
ch.Check((string)"col3.changeValueAbout(1, 9) ",col3.changeValueAbout(1, 9),true);
ch.Check((string)"col3.getNumberOfComponents() ",col3.getNumberOfComponents(),3);
ch.Check((string)"col3.getNumberOfValue() ",col3.getNumberOfValue(),2);
ch.Check((string)"col3.getNumberOfVariable() ",col3.getNumberOfVariable(),1);
ch.Check((string)"(*col3.getComponentPointer(1)) ",(*col3.getComponentPointer(1)),4.0);
ch.Check((string)"(*col3.getComponentPointer(2)) ",(*col3.getComponentPointer(2)),16.0);
ch.Check((string)"(*col3.getComponentPointer(3)) ",(*col3.getComponentPointer(3)),0.0);
ch.Check((string)"col3.isComponentValue(1) ",col3.isComponentValue(1),false);
ch.Check((string)"col3.isComponentValue(2) ",col3.isComponentValue(2),true);
ch.Check((string)"col3.isComponentValue(3) ",col3.isComponentValue(3),true);
ch.Check((string)"col3.isUsedVariable(dp3) ",col3.isUsedVariable(dp3),false);
ch.Check((string)"col3.isUsedVariable(dp4) ",col3.isUsedVariable(dp4),true);



cout<<endl<<endl<<endl<<endl;
dout.Print("\n\nColor col4=Color();");
Color col4=Color();
ch.Check((string)"col4.setValueToValue(1,10) ",col4.setValueToValue(1,10),true);
ch.Check((string)"col4.setValueToValue(2,20) ",col4.setValueToValue(2,20),true);
ch.Check((string)"col4.setValueToValue(3,87) ",col4.setValueToValue(3,87),true);

stringstream strstr2;
dout.Print("col4.store(0,ostrstr2) \n");
i1=0;
col4.store(i1,strstr2);
dout.Print("\ncout<<strstr2.str() \n");
cout<<(strstr2.str())<<endl;
dout.Print("\nColor col5; \n");
Color col5;
list<double*> list1;
dout.Print("\ncol5.restore(strstr2,list1); \n");
col5.restore(strstr2,list1);
ch.Check((string)"\ncol5.equalValue(&col4) ",col5.equalValue(&col4),true);

ch.Check((string)"col5.getValue(1) ",col5.getValue(1),10);
ch.Check((string)"col5.getValue(2) ",col5.getValue(2),20);
ch.Check((string)"col5.getValue(3) ",col5.getValue(3),87);


stringstream strstr3;
dout.Print("\ncol5.store(i1,strstr3); \n");
col5.store(i1,strstr3);
dout.Print("\ncout<<strstr3.str(); \n");
cout<<strstr3.str();


//equalValue; oper=

};





