double test0() { string p0 = "1+1=2"; BaseMystery * obj = new BaseMystery(); clock_t start = clock(); vector <int> my_answer = obj->getBase(p0); clock_t end = clock(); delete obj; cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl; int t1[] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; vector <int> p1(t1, t1+sizeof(t1)/sizeof(int)); cout <<"Desired answer: " <<endl; cout <<"\t{ "; if (p1.size() > 0) { cout <<p1[0]; for (int i=1; i<p1.size(); i++) cout <<", " <<p1[i]; cout <<" }" <<endl; } else cout <<"}" <<endl; cout <<endl <<"Your answer: " <<endl; cout <<"\t{ "; if (my_answer.size() > 0) { cout <<my_answer[0]; for (int i=1; i<my_answer.size(); i++) cout <<", " <<my_answer[i]; cout <<" }" <<endl; } else cout <<"}" <<endl; if (my_answer != p1) { cout <<"DOESN'T MATCH!!!!" <<endl <<endl; return -1; } else { cout <<"Match :-)" <<endl <<endl; return (double)(end-start)/CLOCKS_PER_SEC; } }
double test2() { string p0 = "1+1=3"; BaseMystery * obj = new BaseMystery(); clock_t start = clock(); vector <int> my_answer = obj->getBase(p0); clock_t end = clock(); delete obj; cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl; vector <int> p1; cout <<"Desired answer: " <<endl; cout <<"\t{ "; if (p1.size() > 0) { cout <<p1[0]; for (int i=1; i<p1.size(); i++) cout <<", " <<p1[i]; cout <<" }" <<endl; } else cout <<"}" <<endl; cout <<endl <<"Your answer: " <<endl; cout <<"\t{ "; if (my_answer.size() > 0) { cout <<my_answer[0]; for (int i=1; i<my_answer.size(); i++) cout <<", " <<my_answer[i]; cout <<" }" <<endl; } else cout <<"}" <<endl; if (my_answer != p1) { cout <<"DOESN'T MATCH!!!!" <<endl <<endl; return -1; } else { cout <<"Match :-)" <<endl <<endl; return (double)(end-start)/CLOCKS_PER_SEC; } }
int main(int argc, char* argv[]) { { int retrunValueARRAY[] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; vector <int> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) ); BaseMystery theObject; eq(0, theObject.getBase("1+1=2"),retrunValue); } { int retrunValueARRAY[] = { 2 }; vector <int> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) ); BaseMystery theObject; eq(1, theObject.getBase("1+1=10"),retrunValue); } { BaseMystery theObject; eq(2, theObject.getBase("1+1=3"),vector <int>()); } { int retrunValueARRAY[] = { 14 }; vector <int> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) ); BaseMystery theObject; eq(3, theObject.getBase("ABCD+211=B000"),retrunValue); } { int retrunValueARRAY[] = { 15 }; vector <int> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) ); BaseMystery theObject; eq(4, theObject.getBase("ABCD+322=B000"),retrunValue); } { int retrunValueARRAY[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; vector <int> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) ); BaseMystery theObject; eq(5, theObject.getBase("1+0=1"),retrunValue); } { int retrunValueARRAY[] = { 20 }; vector <int> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) ); BaseMystery theObject; eq(6, theObject.getBase("GHIJ+1111=HJ00"),retrunValue); } { int retrunValueARRAY[] = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; vector <int> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) ); BaseMystery theObject; eq(7, theObject.getBase("1234+8765=9999"),retrunValue); } }