Exemplo n.º 1
0
double test1() {
	int p0 = 3;
	int p1 = 4;
	int t2[] = {4};
	vector <int> p2(t2, t2+sizeof(t2)/sizeof(int));
	Jumping * obj = new Jumping();
	clock_t start = clock();
	string my_answer = obj->ableToGet(p0, p1, p2);
	clock_t end = clock();
	delete obj;
	cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
	string p3 = "Not able";
	cout <<"Desired answer: " <<endl;
	cout <<"\t\"" << p3 <<"\"" <<endl;
	cout <<"Your answer: " <<endl;
	cout <<"\t\"" << my_answer<<"\"" <<endl;
	if (p3 != my_answer) {
		cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
		return -1;
	}
	else {
		cout <<"Match :-)" <<endl <<endl;
		return (double)(end-start)/CLOCKS_PER_SEC;
	}
}
Exemplo n.º 2
0
bool KawigiEdit_RunTest(int testNum, int p0, int p1, vector <int> p2, bool hasAnswer, string p3) {
	cout << "Test " << testNum << ": [" << p0 << "," << p1 << "," << "{";
	for (int i = 0; int(p2.size()) > i; ++i) {
		if (i > 0) {
			cout << ",";
		}
		cout << p2[i];
	}
	cout << "}";
	cout << "]" << endl;
	Jumping *obj;
	string answer;
	obj = new Jumping();
	clock_t startTime = clock();
	answer = obj->ableToGet(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;
}
Exemplo n.º 3
0
int main( int argc, char* argv[] ) {
	{
		int jumpLengthsARRAY[] = {2, 5};
		vector <int> jumpLengths( jumpLengthsARRAY, jumpLengthsARRAY+ARRSIZE(jumpLengthsARRAY) );
		Jumping theObject;
		eq(0, theObject.ableToGet(5, 4, jumpLengths),"Able");
	}
	{
		int jumpLengthsARRAY[] = {4};
		vector <int> jumpLengths( jumpLengthsARRAY, jumpLengthsARRAY+ARRSIZE(jumpLengthsARRAY) );
		Jumping theObject;
		eq(1, theObject.ableToGet(3, 4, jumpLengths),"Not able");
	}
	{
		int jumpLengthsARRAY[] = {6};
		vector <int> jumpLengths( jumpLengthsARRAY, jumpLengthsARRAY+ARRSIZE(jumpLengthsARRAY) );
		Jumping theObject;
		eq(2, theObject.ableToGet(3, 4, jumpLengths),"Not able");
	}
	{
		int jumpLengthsARRAY[] = {100, 100};
		vector <int> jumpLengths( jumpLengthsARRAY, jumpLengthsARRAY+ARRSIZE(jumpLengthsARRAY) );
		Jumping theObject;
		eq(3, theObject.ableToGet(0, 1, jumpLengths),"Able");
	}
	{
		int jumpLengthsARRAY[] = {500};
		vector <int> jumpLengths( jumpLengthsARRAY, jumpLengthsARRAY+ARRSIZE(jumpLengthsARRAY) );
		Jumping theObject;
		eq(4, theObject.ableToGet(300, 400, jumpLengths),"Able");
	}
	{
		int jumpLengthsARRAY[] = {1,2,3,4,5,6,7,8,9,10};
		vector <int> jumpLengths( jumpLengthsARRAY, jumpLengthsARRAY+ARRSIZE(jumpLengthsARRAY) );
		Jumping theObject;
		eq(5, theObject.ableToGet(11, 12, jumpLengths),"Able");
	}
	{
		int jumpLengthsARRAY[] = {1,2,3,4,5,6,7,8,9,100};
		vector <int> jumpLengths( jumpLengthsARRAY, jumpLengthsARRAY+ARRSIZE(jumpLengthsARRAY) );
		Jumping theObject;
		eq(6, theObject.ableToGet(11, 12, jumpLengths),"Not able");
	}
	return 0;
}