bool KawigiEdit_RunTest(int testNum, int p0, int p1, vector <int> p2, vector <int> p3, bool hasAnswer, double p4) { cout << "Test " << testNum << ": [" << p0 << "," << p1 << "," << "{"; for (int i = 0; int(p2.size()) > i; ++i) { if (i > 0) { cout << ","; } cout << p2[i]; } cout << "}" << "," << "{"; for (int i = 0; int(p3.size()) > i; ++i) { if (i > 0) { cout << ","; } cout << p3[i]; } cout << "}"; cout << "]" << endl; EllysRivers *obj; double answer; obj = new EllysRivers(); clock_t startTime = clock(); answer = obj->getMin(p0, p1, p2, p3); 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" << p4 << endl; } cout << "Your answer:" << endl; cout << "\t" << answer << endl; if (hasAnswer) { res = answer == answer && fabs(p4 - answer) <= 1e-9 * max(1.0, fabs(p4)); } 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; }
int main(int argc, char *argv[]) { EllysRivers test; if(argc == 1) { test.run_test(-1); }else { std::string arg(argv[1]); if(arg[0] != '-') { test.run_test(arg[0] - '0'); }else { test.debug(); } } return 0; }
// BEGIN CUT HERE int main(){ EllysRivers test; test.run_test(-1); return 0; }