double test5() { int p0 = 990630; int t1[] = {833196,524568,361663,108056,28026,824639,269315,440977,440977,765458, 988451,242440,948414,130873,773990,765458,130873,28026,853121,553636, 581069,82254,735536,833196,898562,898562,940783,988451,540613,317306, 623194,940783,571384,988451,108056,514374,97664}; vector <int> p1(t1, t1+sizeof(t1)/sizeof(int)); string p2 = "--+---+-+++-+-+---++-++-+---+-+--+-++"; RouteIntersection * obj = new RouteIntersection(); clock_t start = clock(); string my_answer = obj->isValid(p0, p1, p2); clock_t end = clock(); delete obj; cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl; string p3 = "NOT VALID"; cout <<"Desired answer: " <<endl; cout <<"\t\"" << p3 <<"\"" <<endl; cout <<"Your answer: " <<endl; cout <<"\t\"" << my_answer<<"\"" <<endl; if (p3 != my_answer) { cout <<"DOESN'T MATCH!!!!" <<endl <<endl; return -1; } else { cout <<"Match :-)" <<endl <<endl; return (double)(end-start)/CLOCKS_PER_SEC; } }
double test1() { int p0 = 2; int t1[] = {1,2,1,2}; vector <int> p1(t1, t1+sizeof(t1)/sizeof(int)); string p2 = "++--"; RouteIntersection * obj = new RouteIntersection(); clock_t start = clock(); string my_answer = obj->isValid(p0, p1, p2); clock_t end = clock(); delete obj; cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl; string p3 = "NOT VALID"; cout <<"Desired answer: " <<endl; cout <<"\t\"" << p3 <<"\"" <<endl; cout <<"Your answer: " <<endl; cout <<"\t\"" << my_answer<<"\"" <<endl; if (p3 != my_answer) { 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 N=2; vector<int> v1; v1.push_back(1); v1.push_back(2); v1.push_back(1); v1.push_back(2); string s="++--"; RouteIntersection obj; cout<<obj.isValid(N,v1,s)<<endl; }
bool KawigiEdit_RunTest(int testNum, int p0, vector <int> p1, string p2, bool hasAnswer, string p3) { cout << "Test " << testNum << ": [" << p0 << "," << "{"; for (int i = 0; int(p1.size()) > i; ++i) { if (i > 0) { cout << ","; } cout << p1[i]; } cout << "}" << "," << "\"" << p2 << "\""; cout << "]" << endl; RouteIntersection *obj; string answer; obj = new RouteIntersection(); clock_t startTime = clock(); answer = obj->isValid(p0, p1, p2); clock_t endTime = clock(); delete obj; bool res; res = true; cout << "Time: " << double(endTime - startTime) / CLOCKS_PER_SEC << " seconds" << endl; if (hasAnswer) { cout << "Desired answer:" << endl; cout << "\t" << "\"" << p3 << "\"" << endl; } cout << "Your answer:" << endl; cout << "\t" << "\"" << answer << "\"" << endl; if (hasAnswer) { res = answer == p3; } if (!res) { cout << "DOESN'T MATCH!!!!" << endl; } else if (double(endTime - startTime) / CLOCKS_PER_SEC >= 2) { cout << "FAIL the timeout" << endl; res = false; } else if (hasAnswer) { cout << "Match :-)" << endl; } else { cout << "OK, but is it right?" << endl; } cout << "" << endl; return res; }