bool KawigiEdit_RunTest(int testNum, vector <int> p0, vector <int> p1, vector <int> p2, int p3, bool hasAnswer, double p4) { cout << "Test " << testNum << ": [" << "{"; for (int i = 0; int(p0.size()) > i; ++i) { if (i > 0) { cout << ","; } cout << p0[i]; } cout << "}" << "," << "{"; for (int i = 0; int(p1.size()) > i; ++i) { if (i > 0) { cout << ","; } cout << p1[i]; } cout << "}" << "," << "{"; for (int i = 0; int(p2.size()) > i; ++i) { if (i > 0) { cout << ","; } cout << p2[i]; } cout << "}" << "," << p3; cout << "]" << endl; RadioRange *obj; double answer; obj = new RadioRange(); clock_t startTime = clock(); answer = obj->RadiusProbability(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; }
// BEGIN CUT HERE void main( int argc, char* argv[] ) { { int XARRAY[] = {0}; vector <int> X( XARRAY, XARRAY+ARRSIZE(XARRAY) ); int YARRAY[] = {0}; vector <int> Y( YARRAY, YARRAY+ARRSIZE(YARRAY) ); int RARRAY[] = {5}; vector <int> R( RARRAY, RARRAY+ARRSIZE(RARRAY) ); RadioRange theObject; eq(0, theObject.RadiusProbability(X, Y, R, 10),0.5); } { int XARRAY[] = {0}; vector <int> X( XARRAY, XARRAY+ARRSIZE(XARRAY) ); int YARRAY[] = {0}; vector <int> Y( YARRAY, YARRAY+ARRSIZE(YARRAY) ); int RARRAY[] = {10}; vector <int> R( RARRAY, RARRAY+ARRSIZE(RARRAY) ); RadioRange theObject; eq(1, theObject.RadiusProbability(X, Y, R, 10),0.0); } { int XARRAY[] = {10}; vector <int> X( XARRAY, XARRAY+ARRSIZE(XARRAY) ); int YARRAY[] = {10}; vector <int> Y( YARRAY, YARRAY+ARRSIZE(YARRAY) ); int RARRAY[] = {10}; vector <int> R( RARRAY, RARRAY+ARRSIZE(RARRAY) ); RadioRange theObject; eq(2, theObject.RadiusProbability(X, Y, R, 10),0.4142135623730951); } { int XARRAY[] = {11, -11, 0, 0}; vector <int> X( XARRAY, XARRAY+ARRSIZE(XARRAY) ); int YARRAY[] = {0, 0, 11, -11}; vector <int> Y( YARRAY, YARRAY+ARRSIZE(YARRAY) ); int RARRAY[] = {10, 10, 10, 10}; vector <int> R( RARRAY, RARRAY+ARRSIZE(RARRAY) ); RadioRange theObject; eq(3, theObject.RadiusProbability(X, Y, R, 31),0.3548387096774194); } { int XARRAY[] = {100}; vector <int> X( XARRAY, XARRAY+ARRSIZE(XARRAY) ); int YARRAY[] = {100}; vector <int> Y( YARRAY, YARRAY+ARRSIZE(YARRAY) ); int RARRAY[] = {1}; vector <int> R( RARRAY, RARRAY+ARRSIZE(RARRAY) ); RadioRange theObject; eq(4, theObject.RadiusProbability(X, Y, R, 10),1.0); } { int XARRAY[] = {1000000000}; vector <int> X( XARRAY, XARRAY+ARRSIZE(XARRAY) ); int YARRAY[] = {1000000000}; vector <int> Y( YARRAY, YARRAY+ARRSIZE(YARRAY) ); int RARRAY[] = {1000000000}; vector <int> R( RARRAY, RARRAY+ARRSIZE(RARRAY) ); RadioRange theObject; eq(5, theObject.RadiusProbability(X, Y, R, 1000000000),0.41421356237309503); } { int XARRAY[] = {20, -20, 0, 0}; vector <int> X( XARRAY, XARRAY+ARRSIZE(XARRAY) ); int YARRAY[] = {0, 0, 20, -20}; vector <int> Y( YARRAY, YARRAY+ARRSIZE(YARRAY) ); int RARRAY[] = {50, 50, 50, 50}; vector <int> R( RARRAY, RARRAY+ARRSIZE(RARRAY) ); RadioRange theObject; eq(6, theObject.RadiusProbability(X, Y, R, 100),0.3); } { int XARRAY[] = {0, -60, -62, -60, 63, -97}; vector <int> X( XARRAY, XARRAY+ARRSIZE(XARRAY) ); int YARRAY[] = {-72, 67, 61, -8, -32, 89}; vector <int> Y( YARRAY, YARRAY+ARRSIZE(YARRAY) ); int RARRAY[] = {6, 7, 8, 7, 5, 6}; vector <int> R( RARRAY, RARRAY+ARRSIZE(RARRAY) ); RadioRange theObject; eq(7, theObject.RadiusProbability(X, Y, R, 918),0.9407071068962471); } }