Exemplo n.º 1
0
double test1() {
	string t0[] = {"NYY",
 "YNY",
 "YYN"};
	vector <string> p0(t0, t0+sizeof(t0)/sizeof(string));
	FriendScore * obj = new FriendScore();
	clock_t start = clock();
	int my_answer = obj->highestScore(p0);
	clock_t end = clock();
	delete obj;
	cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
	int p1 = 2;
	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;
	}
}
Exemplo n.º 2
0
// BEGIN KAWIGIEDIT TESTING
// Generated by KawigiEdit 2.1.4 (beta) modified by pivanof
bool KawigiEdit_RunTest(int testNum, vector <string> p0, bool hasAnswer, int p1) {
	cout << "Test " << testNum << ": [" << "{";
	for (int i = 0; int(p0.size()) > i; ++i) {
		if (i > 0) {
			cout << ",";
		}
		cout << "\"" << p0[i] << "\"";
	}
	cout << "}";
	cout << "]" << endl;
	FriendScore *obj;
	int answer;
	obj = new FriendScore();
	clock_t startTime = clock();
	answer = obj->highestScore(p0);
	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" << p1 << endl;
	}
	cout << "Your answer:" << endl;
	cout << "\t" << answer << endl;
	if (hasAnswer) {
		res = answer == p1;
	}
	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(){
	FriendScore fs;
	vector <string> friends;
	friends.push_back("NYNNN");
	friends.push_back("YNYNN");
	friends.push_back("NYNYN");
	friends.push_back("NNYNY");
	friends.push_back("NNNYN");
	cout << fs.highestScore(friends) << endl;
cout << endl;
cout << endl;
cout << endl;
	FriendScore fs2;
	vector <string> friends2;
	friends2.push_back("NYNN");
	friends2.push_back("YNYY");
	friends2.push_back("NYNY");
	friends2.push_back("NYYN");
	cout << fs2.highestScore(friends2) << endl;
}
Exemplo n.º 4
0
int main( int argc, char* argv[] )
{

	FriendScore objectFriendScore;

	//test case0
	vector <string> param00;
	param00.push_back("NNN");
	param00.push_back("NNN");
	param00.push_back("NNN");
	int ret0 = objectFriendScore.highestScore(param00);
	int need0 = 0;
	assert_eq(0,ret0,need0);

	//test case1
	vector <string> param10;
	param10.push_back("NYY");
	param10.push_back("YNY");
	param10.push_back("YYN");
	int ret1 = objectFriendScore.highestScore(param10);
	int need1 = 2;
	assert_eq(1,ret1,need1);

	//test case2
	vector <string> param20;
	param20.push_back("NYNNN");
	param20.push_back("YNYNN");
	param20.push_back("NYNYN");
	param20.push_back("NNYNY");
	param20.push_back("NNNYN");
	int ret2 = objectFriendScore.highestScore(param20);
	int need2 = 4;
	assert_eq(2,ret2,need2);

	//test case3
	vector <string> param30;
	param30.push_back("NNNNYNNNNN");
	param30.push_back("NNNNYNYYNN");
	param30.push_back("NNNYYYNNNN");
	param30.push_back("NNYNNNNNNN");
	param30.push_back("YYYNNNNNNY");
	param30.push_back("NNYNNNNNYN");
	param30.push_back("NYNNNNNYNN");
	param30.push_back("NYNNNNYNNN");
	param30.push_back("NNNNNYNNNN");
	param30.push_back("NNNNYNNNNN");
	int ret3 = objectFriendScore.highestScore(param30);
	int need3 = 8;
	assert_eq(3,ret3,need3);

	//test case4
	vector <string> param40;
	param40.push_back("NNNNNNNNNNNNNNY");
	param40.push_back("NNNNNNNNNNNNNNN");
	param40.push_back("NNNNNNNYNNNNNNN");
	param40.push_back("NNNNNNNYNNNNNNY");
	param40.push_back("NNNNNNNNNNNNNNY");
	param40.push_back("NNNNNNNNYNNNNNN");
	param40.push_back("NNNNNNNNNNNNNNN");
	param40.push_back("NNYYNNNNNNNNNNN");
	param40.push_back("NNNNNYNNNNNYNNN");
	param40.push_back("NNNNNNNNNNNNNNY");
	param40.push_back("NNNNNNNNNNNNNNN");
	param40.push_back("NNNNNNNNYNNNNNN");
	param40.push_back("NNNNNNNNNNNNNNN");
	param40.push_back("NNNNNNNNNNNNNNN");
	param40.push_back("YNNYYNNNNYNNNNN");
	int ret4 = objectFriendScore.highestScore(param40);
	int need4 = 6;
	assert_eq(4,ret4,need4);

}