Ejemplo n.º 1
0
// BEGIN KAWIGIEDIT TESTING
// Generated by KawigiEdit 2.1.4 (beta) modified by pivanof
bool KawigiEdit_RunTest(int testNum, vector <int> p0, int p1, bool hasAnswer, int p2) {
	cout << "Test " << testNum << ": [" << "{";
	for (int i = 0; int(p0.size()) > i; ++i) {
		if (i > 0) {
			cout << ",";
		}
		cout << p0[i];
	}
	cout << "}" << "," << p1;
	cout << "]" << endl;
	Suminator *obj;
	int answer;
	obj = new Suminator();
	clock_t startTime = clock();
	answer = obj->findMissing(p0, p1);
	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" << p2 << endl;
	}
	cout << "Your answer:" << endl;
	cout << "\t" << answer << endl;
	if (hasAnswer) {
		res = answer == p2;
	}
	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
//Powered by [KawigiEdit] 2.0!
double test0() {
	int t0[] = {7,-1,0};
	vector <int> p0(t0, t0+sizeof(t0)/sizeof(int));
	int p1 = 10;
	Suminator * obj = new Suminator();
	clock_t start = clock();
	int my_answer = obj->findMissing(p0, p1);
	clock_t end = clock();
	delete obj;
	cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
	int p2 = 3;
	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;
	}
}
Ejemplo n.º 3
0
int main(int argc, char* argv[]) {
  Suminator test;
  {
    test.runTest({7,-1,0}, 10, 3);
  }
  {
    test.runTest({100, 200, 300, 0, 100, -1}, 600, 0);
  }
  {
    test.runTest({-1, 7, 3, 0, 1, 2, 0, 0}, 13, 0);
  }
  {
    test.runTest({-1, 8, 4, 0, 1, 2, 0, 0}, 16, -1);
  }
  {
    test.runTest({1000000000, 1000000000, 1000000000,  1000000000, -1, 0, 0, 0, 0}, 1000000000, -1);
  }
}
Ejemplo n.º 4
0
// BEGIN CUT HERE
int main(int argc, char* argv[] ) {
    {
        int programARRAY[] = {7,-1,0};
        vector <int> program( programARRAY, programARRAY+ARRSIZE(programARRAY) );
        Suminator theObject;
        eq(0, theObject.findMissing(program, 10),3);
    }
    {
        int programARRAY[] = {100, 200, 300, 0, 100, -1};
        vector <int> program( programARRAY, programARRAY+ARRSIZE(programARRAY) );
        Suminator theObject;
        eq(1, theObject.findMissing(program, 600),0);
    }
    {
        int programARRAY[] = {-1, 7, 3, 0, 1, 2, 0, 0};
        vector <int> program( programARRAY, programARRAY+ARRSIZE(programARRAY) );
        Suminator theObject;
        eq(2, theObject.findMissing(program, 13),0);
    }
    {
        int programARRAY[] = {-1, 8, 4, 0, 1, 2, 0, 0};
        vector <int> program( programARRAY, programARRAY+ARRSIZE(programARRAY) );
        Suminator theObject;
        eq(3, theObject.findMissing(program, 16),-1);
    }
    {
        int programARRAY[] = {1000000000, 1000000000, 1000000000,  1000000000, -1, 0, 0, 0, 0};
        vector <int> program( programARRAY, programARRAY+ARRSIZE(programARRAY) );
        Suminator theObject;
        eq(4, theObject.findMissing(program, 1000000000),-1);
    }
    {
        int programARRAY[] = {7, -1, 3, 0};
        vector <int> program( programARRAY, programARRAY+ARRSIZE(programARRAY) );
        Suminator theObject;
        eq(5, theObject.findMissing(program, 3),-1);
    }
}