Ejemplo n.º 1
0
// BEGIN KAWIGIEDIT TESTING
// Generated by KawigiEdit 2.1.4 (beta) modified by pivanof
bool KawigiEdit_RunTest(int testNum, int p0, int p1, int p2, int p3, bool hasAnswer, double p4) {
	cout << "Test " << testNum << ": [" << p0 << "," << p1 << "," << p2 << "," << p3;
	cout << "]" << endl;
	FixedDiceGameDiv1 *obj;
	double answer;
	obj = new FixedDiceGameDiv1();
	clock_t startTime = clock();
	answer = obj->getExpectation(p0, p1, p2, p3);
	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" << p4 << endl;
	}
	cout << "Your answer:" << endl;
	cout << "\t" << answer << endl;
	if (hasAnswer) {
		res = fabs(p4 - answer) <= 1e-9 * max(1.0, fabs(p4));
	}
	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;
}
Ejemplo n.º 2
0
// BEGIN CUT HERE
void main( int argc, char* argv[] ) {
    {
        FixedDiceGameDiv1 theObject;
        eq(0, theObject.getExpectation(1, 2, 1, 5),2.0);
    }
    {
        FixedDiceGameDiv1 theObject;
        eq(1, theObject.getExpectation(3, 1, 1, 3),3.0);
    }
    {
        FixedDiceGameDiv1 theObject;
        eq(2, theObject.getExpectation(1, 5, 1, 1),3.4999999999999996);
    }
    {
        FixedDiceGameDiv1 theObject;
        eq(3, theObject.getExpectation(2, 6, 50, 30),-1.0);
    }
    {
        FixedDiceGameDiv1 theObject;
        eq(4, theObject.getExpectation(50, 11, 50, 50),369.8865999182022);
    }
}