// BEGIN KAWIGIEDIT TESTING // Generated by KawigiEdit 2.1.4 (beta) modified by pivanof bool KawigiEdit_RunTest(int testNum, vector <string> p0, vector <int> p1, bool hasAnswer, int p2) { 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 << "}"; cout << "]" << endl; PalindromeGame *obj; int answer; obj = new PalindromeGame(); clock_t startTime = clock(); answer = obj->getMaximum(p0, p1); 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" << p2 << endl; } cout << "Your answer:" << endl; cout << "\t" << answer << endl; if (hasAnswer) { res = answer == p2; } 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; }
void testCase1() { string front_[] = {"xyx", "xyx", "xyx", "zzz", "zzz", "zzz"}; vector<string> front(front_, front_ + (sizeof(front_) / sizeof(front_[0]))); int back_[] = {5, 7, 2, 1, 6, 4}; vector<int> back(back_, back_ + (sizeof(back_) / sizeof(back_[0]))); int expected_ = 24; assertEquals(1, expected_, solution.getMaximum(front, back)); }
void testCase2() { string front_[] = {"abc", "abc", "def", "cba", "fed"}; vector<string> front(front_, front_ + (sizeof(front_) / sizeof(front_[0]))); int back_[] = {24, 7, 63, 222, 190}; vector<int> back(back_, back_ + (sizeof(back_) / sizeof(back_[0]))); int expected_ = 499; assertEquals(2, expected_, solution.getMaximum(front, back)); }
void testCase0() { string front_[] = {"topcoder", "aaraa", "redocpot"}; vector<string> front(front_, front_ + (sizeof(front_) / sizeof(front_[0]))); int back_[] = {7, 5, 3}; vector<int> back(back_, back_ + (sizeof(back_) / sizeof(back_[0]))); int expected_ = 15; assertEquals(0, expected_, solution.getMaximum(front, back)); }