// BEGIN CUT HERE void main( int argc, char* argv[] ) { { int kindARRAY[] = {1, 2, 2, 1}; vector <int> kind( kindARRAY, kindARRAY+ARRSIZE(kindARRAY) ); int foundARRAY[] = {1}; vector <int> found( foundARRAY, foundARRAY+ARRSIZE(foundARRAY) ); Excavations2 theObject; eq(0, theObject.count(kind, found, 2), 1LL); } { int kindARRAY[] = {1, 2, 2, 1}; vector <int> kind( kindARRAY, kindARRAY+ARRSIZE(kindARRAY) ); int foundARRAY[] = {1, 2}; vector <int> found( foundARRAY, foundARRAY+ARRSIZE(foundARRAY) ); Excavations2 theObject; eq(1, theObject.count(kind, found, 2), 4LL); } { int kindARRAY[] = {1, 2, 1, 1, 2, 3, 4, 3, 2, 2}; vector <int> kind( kindARRAY, kindARRAY+ARRSIZE(kindARRAY) ); int foundARRAY[] = {4, 2}; vector <int> found( foundARRAY, foundARRAY+ARRSIZE(foundARRAY) ); Excavations2 theObject; eq(2, theObject.count(kind, found, 3), 6LL); } { int kindARRAY[] = {13, 6, 1, 13, 2, 6}; vector <int> kind( kindARRAY, kindARRAY+ARRSIZE(kindARRAY) ); int foundARRAY[] = {2, 6, 1, 13}; vector <int> found( foundARRAY, foundARRAY+ARRSIZE(foundARRAY) ); Excavations2 theObject; eq(3, theObject.count(kind, found, 5), 4LL); } }
bool KawigiEdit_RunTest(int testNum, vector <int> p0, vector <int> p1, int p2, bool hasAnswer, long long p3) { 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 << "}" << "," << p2; cout << "]" << endl; Excavations2 *obj; long long answer; obj = new Excavations2(); clock_t startTime = clock(); answer = obj->count(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; }