Exemple #1
0
int test3() {
    string answer = "YYYY";
    NumberMagicEasy* pObj = new NumberMagicEasy();
    clock_t start = clock();
    int result = pObj->theNumber(answer);
    clock_t end = clock();
    delete pObj;
    int expected = 1;
    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;
    }
}
Exemple #2
0
double test2() {
	string p0 = "NNNN";
	NumberMagicEasy * obj = new NumberMagicEasy();
	clock_t start = clock();
	int my_answer = obj->theNumber(p0);
	clock_t end = clock();
	delete obj;
	cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
	int p1 = 16;
	cout <<"Desired answer: " <<endl;
	cout <<"\t" << p1 <<endl;
	cout <<"Your answer: " <<endl;
	cout <<"\t" << my_answer <<endl;
	if (p1 != my_answer) {
		cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
		return -1;
	}
	else {
		cout <<"Match :-)" <<endl <<endl;
		return (double)(end-start)/CLOCKS_PER_SEC;
	}
}
    void testCase4() {
		string answer = "NNNN";
		int expected_ = 16;
        assertEquals(4, expected_, solution.theNumber(answer));
    }
    void testCase3() {
		string answer = "YYYY";
		int expected_ = 1;
        assertEquals(3, expected_, solution.theNumber(answer));
    }
    void testCase1() {
		string answer = "YNNN";
		int expected_ = 8;
        assertEquals(1, expected_, solution.theNumber(answer));
    }
    void testCase0() {
		string answer = "YNYY";
		int expected_ = 5;
        assertEquals(0, expected_, solution.theNumber(answer));
    }