// BEGIN KAWIGIEDIT TESTING // Generated by KawigiEdit 2.1.4 (beta) modified by pivanof bool KawigiEdit_RunTest(int testNum, string p0, string p1, bool hasAnswer, int p2) { cout << "Test " << testNum << ": [" << "\"" << p0 << "\"" << "," << "\"" << p1 << "\""; cout << "]" << endl; TypingDistance *obj; int answer; obj = new TypingDistance(); clock_t startTime = clock(); answer = obj->minDistance(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; }
int test25() { string keyboard = "zdpvagwsouileyjnfqrcm"; string word = "alqnueweyiqsnszzczagdoiuquivpugrvenszjccicvqzrlnaa"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 352; if(result == expected) { cout << "Test Case 25: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 25: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test51() { string keyboard = "qwertyuiopasdfghjklzxcvbnm"; string word = "qmqmqmqmqmqmqmqmqmqmqmqmqmqmqmqmqmqmqmqmqmqmqmqmqm"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 1225; if(result == expected) { cout << "Test Case 51: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 51: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test49() { string keyboard = "eucbakgtsrpxhqvflwomniydjz"; string word = "vagcvydmdjnzkwzziasqporzqemqwdsvvzgrxtsnfktzwic"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 360; if(result == expected) { cout << "Test Case 49: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 49: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test47() { string keyboard = "jzkyoavrswfnqdlpbxeucimtgh"; string word = "oqnfywrsuvqwumjmaffgvynpevkzmog"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 264; if(result == expected) { cout << "Test Case 47: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 47: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test45() { string keyboard = "gnyrlobmixsvcutejhdpkfzawq"; string word = "wvasjmytqikqkmpqbshqutbbhjlgvuiqeskxhmpqivfzczxobi"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 416; if(result == expected) { cout << "Test Case 45: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 45: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test43() { string keyboard = "jgkmapryeobtxihnvcfulsdwqz"; string word = "ybizsclklgaommexhetojxjbcnsdzpxcqwapzaigcpbfdqxrjb"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 385; if(result == expected) { cout << "Test Case 43: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 43: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test41() { string keyboard = "pfxrlngakdjzcheyobmwsuivtq"; string word = "rcdgbgkwet"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 65; if(result == expected) { cout << "Test Case 41: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 41: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test32() { string keyboard = "tfvpkgomeuyriqhjzwnaxscbdl"; string word = "hkzdbfsouxxhkmxdfydgwqqyalosqxvykafgldxxgogejayqln"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 442; if(result == expected) { cout << "Test Case 32: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 32: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test31() { string keyboard = "flcmhuzedpkatjwoigbxsvqnyr"; string word = "ktvnnhiaasmqxfddocosnoshwn"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 213; if(result == expected) { cout << "Test Case 31: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 31: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test30() { string keyboard = "ljkhuogfrqwycvabszxptiendm"; string word = "feiusvgkvwdocbciqktviclbsgvzdonuzmlktyybolrjxynilc"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 481; if(result == expected) { cout << "Test Case 30: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 30: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test29() { string keyboard = "ijzqafksuobcmlypgthrdwnex"; string word = "obyhorcajwymhsfotmhyqodtm"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 157; if(result == expected) { cout << "Test Case 29: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 29: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test28() { string keyboard = "tfqvbawsdeuypcgxmirlokjz"; string word = "zayapdleckjikgoflvwykzktkdpwsmrc"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 254; if(result == expected) { cout << "Test Case 28: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 28: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test27() { string keyboard = "pnmjsqldkwfhoyxrzibvtug"; string word = "mnkqjwbqbptdzinxzjrytrfuqvsvdqpskglxqbyrtixgqdkvfz"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 420; if(result == expected) { cout << "Test Case 27: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 27: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test26() { string keyboard = "damgreuvtjiqswkfxzopbc"; string word = "tticddvdizidsfqjgmicwwqojjisofsrpvwggmzrazsfofpffs"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 294; if(result == expected) { cout << "Test Case 26: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 26: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test39() { string keyboard = "isyrwvdnlbqjzcthumaxgpkfeo"; string word = "ukjokxadbbzhaoqxopvlhrsztgqeytezrg"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 268; if(result == expected) { cout << "Test Case 39: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 39: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test40() { string keyboard = "xeplifckyhaodrmqzbuvwsjngt"; string word = "yvvwzxkypuabekenotjttubcfjofciunddidotsaegnpzziyto"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 407; if(result == expected) { cout << "Test Case 40: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 40: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test33() { string keyboard = "kdliovyxcuajrnpsmthbfqgezw"; string word = "vlkbyzrjbuwslnoshdmxoumbngatishhqthviysyihxwjztnil"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 421; if(result == expected) { cout << "Test Case 33: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 33: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test42() { string keyboard = "uswzhvxckleagipbydtjornfmq"; string word = "wzmyntnsjynqpzehrccgljxtegwcqtkoctsp"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 330; if(result == expected) { cout << "Test Case 42: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 42: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test34() { string keyboard = "mxcqsfkpbawgzlrtdynheojiuv"; string word = "ffpaceimfkarzthgjtevemdenvkuyvmkexzwcktluustvkersq"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 422; if(result == expected) { cout << "Test Case 34: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 34: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test44() { string keyboard = "anbqfskrldzgjotyvwemxhcipu"; string word = "vmpjscntltpaifjdgvlfqxfxaduhqrmhzbekymhpevrpgjaqhp"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 480; if(result == expected) { cout << "Test Case 44: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 44: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test35() { string keyboard = "xabuvlzychokmnpsdirqewftgj"; string word = "imwrqmzipxtlvvmeqjovhwpeslpjbtwyoxrurxaahspdukeaei"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 438; if(result == expected) { cout << "Test Case 35: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 35: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test46() { string keyboard = "tdxayljmpungcrzhvqsoiebwfk"; string word = "jlwqqpndnbbdggonfocrvxbmlnycjduvuxwlyenlntquaadbwu"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 411; if(result == expected) { cout << "Test Case 46: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 46: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test36() { string keyboard = "mwnruqchglsofaybitdvxejzkp"; string word = "wwwfoirbrycfkvpstvtswsctykkqjotylrwrusfrpwxtulpuqz"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 412; if(result == expected) { cout << "Test Case 36: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 36: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test48() { string keyboard = "poeayickhxzfbdqlnrmstjwuvg"; string word = "hmwjcvzwwujhzzingowbooukvvgpicfeafuixolqipyinruyui"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 443; if(result == expected) { cout << "Test Case 48: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 48: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test37() { string keyboard = "uwjseliorkqdtngfbamyvhzpxc"; string word = "jnhtcg"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 52; if(result == expected) { cout << "Test Case 37: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 37: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test50() { string keyboard = "wocnthkgupysamdjxvqizbferl"; string word = "glvovglzznskvwzxarqrpqhodoaciqbcpafdwmlsnvhekkmcot"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 501; if(result == expected) { cout << "Test Case 50: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 50: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test2() { string keyboard = "qwertyuiopasdfghjklzxcvbnm"; string word = "topcodersingleroundmatchgoodluckhavefun"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 322; if(result == expected) { cout << "Test Case 2: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 2: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test53() { string keyboard = "abcdefg"; string word = "cb"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 1; if(result == expected) { cout << "Test Case 53: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 53: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }
int test38() { string keyboard = "qdawxopznfimuvlsehrjytckbg"; string word = "itgfggtzjopoqzyxfeamkyeqhiqmxbxpcrhxgcptcytnnxqcou"; TypingDistance* pObj = new TypingDistance(); clock_t start = clock(); int result = pObj->minDistance(keyboard, word); clock_t end = clock(); delete pObj; int expected = 458; if(result == expected) { cout << "Test Case 38: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 38: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } }