Beispiel #1
0
int test3() {
    int n = 7;
    int k = 100;
    TheLockDivTwo* pObj = new TheLockDivTwo();
    clock_t start = clock();
    string result = pObj->password(n, k);
    clock_t end = clock();
    delete pObj;
    string expected = "1100001";
    if(result == expected) {
        cout << "Test Case 3: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 3: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
Beispiel #2
0
double test2() {
	int p0 = 10;
	int p1 = 1;
	TheLockDivTwo * obj = new TheLockDivTwo();
	clock_t start = clock();
	string my_answer = obj->password(p0, p1);
	clock_t end = clock();
	delete obj;
	cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
	string p2 = "0000000000";
	cout <<"Desired answer: " <<endl;
	cout <<"\t\"" << p2 <<"\"" <<endl;
	cout <<"Your answer: " <<endl;
	cout <<"\t\"" << my_answer<<"\"" <<endl;
	if (p2 != my_answer) {
		cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
		return -1;
	}
	else {
		cout <<"Match :-)" <<endl <<endl;
		return (double)(end-start)/CLOCKS_PER_SEC;
	}
}