Exemplo n.º 1
0
int test3() {
    vector<string> queries = {"1,2,31", "1,3,9", "1,4,31", "2,4,32", "3,4,9", "3,2,9"};
    int numberOfBoxes = 4;
    int ithBox = 3;
    VolumeGuess* pObj = new VolumeGuess();
    clock_t start = clock();
    int result = pObj->correctVolume(queries, numberOfBoxes, ithBox);
    clock_t end = clock();
    delete pObj;
    int expected = 9;
    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;
    }
}
Exemplo n.º 2
0
int test13() {
    vector<string> queries = {"1,7,12", "2,1,12", "5,9,123", "7,6,100", "8,6,100", "6,9,100", "7,8,200", "1,5,12", "1,6,12", "1,8,12", "1,9,12", "2,3,34", "2,4,42", "3,7,34", "8,3,34", "9,3,34", "4,5,42", "4,6,42", "1,3,12", "1,4,12", "5,7,200", "5,8,300", "9,4,42", "5,6,100", "7,9,123", "8,9,123", "2,5,234", "2,6,100", "4,7,42", "4,8,42", "2,7,200", "8,2,234", "2,9,123", "3,4,34", "3,5,34", "3,6,34"};
    int numberOfBoxes = 9;
    int ithBox = 9;
    VolumeGuess* pObj = new VolumeGuess();
    clock_t start = clock();
    int result = pObj->correctVolume(queries, numberOfBoxes, ithBox);
    clock_t end = clock();
    delete pObj;
    int expected = 123;
    if(result == expected) {
        cout << "Test Case 13: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 13: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
Exemplo n.º 3
0
int test35() {
    vector<string> queries = {"1,2,8", "1,3,7", "1,4,6", "1,5,5", "1,6,4", "1,7,3", "1,8,2", "1,9,1", "2,3,7", "2,4,6", "2,5,5", "2,6,4", "2,7,3", "2,8,2", "2,9,1", "3,4,6", "3,5,5", "3,6,4", "3,7,3", "3,8,2", "3,9,1", "4,5,5", "4,6,4", "4,7,3", "4,8,2", "4,9,1", "5,6,4", "5,7,3", "5,8,2", "5,9,1", "6,7,3", "6,8,2", "6,9,1", "7,8,2", "7,9,1", "8,9,1"};
    int numberOfBoxes = 9;
    int ithBox = 3;
    VolumeGuess* pObj = new VolumeGuess();
    clock_t start = clock();
    int result = pObj->correctVolume(queries, numberOfBoxes, ithBox);
    clock_t end = clock();
    delete pObj;
    int expected = 7;
    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;
    }
}
Exemplo n.º 4
0
int test6() {
    vector<string> queries = {"3,2,80", "5,2,15", "1,2,193", "3,1,80", "5,1,15", "5,3,15", "3,4,3", "4,5,3", "2,4,3", "4,1,3"};
    int numberOfBoxes = 5;
    int ithBox = 5;
    VolumeGuess* pObj = new VolumeGuess();
    clock_t start = clock();
    int result = pObj->correctVolume(queries, numberOfBoxes, ithBox);
    clock_t end = clock();
    delete pObj;
    int expected = 15;
    if(result == expected) {
        cout << "Test Case 6: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 6: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
Exemplo n.º 5
0
// BEGIN KAWIGIEDIT TESTING
// Generated by KawigiEdit 2.1.4 (beta) modified by pivanof
bool KawigiEdit_RunTest(int testNum, vector <string> p0, int p1, int p2, bool hasAnswer, int p3) {
	cout << "Test " << testNum << ": [" << "{";
	for (int i = 0; int(p0.size()) > i; ++i) {
		if (i > 0) {
			cout << ",";
		}
		cout << "\"" << p0[i] << "\"";
	}
	cout << "}" << "," << p1 << "," << p2;
	cout << "]" << endl;
	VolumeGuess *obj;
	int answer;
	obj = new VolumeGuess();
	clock_t startTime = clock();
	answer = obj->correctVolume(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;
}