/*static*/ bool StructureParser::test_matchCppType () {
	// Test 1 (regression)
	{
		StringVec v = createStringVec ("static std :: pair < string , int > var");
		bool result;
		CppType type;
		StringVec::const_iterator i = matchCppType (v.begin(), v.end(), &result, &type);
		if (!result || i != v.begin() + 9){
			fprintf (stderr, "test_matchCppType1 failed\n");
			markPosition (v.begin(), v.end(), i);
			return false;
		}
	}
	// Test2
	{
		StringVec v = createStringVec ("void");
		bool result;
		CppType type;
		StringVec::const_iterator i = matchCppType (v.begin(), v.end(), &result, &type);
		if (!result || i != v.end()){
			fprintf (stderr, "test_matchCppType2 failed\n");
			markPosition (v.begin(), v.end(), i);
			return false;
		}
	}
	// Test 3 with reference
	{
		StringVec v = createStringVec ("std :: string &");
		bool result;
		CppType type;
		StringVec::const_iterator i = matchCppType (v.begin(), v.end(), &result, &type);
		if (!result || i != v.end()){
			fprintf (stderr, "test_matchCppType3 failed: %d %s\n", result, sf::toJSON (type).c_str());
			markPosition (v.begin(), v.end(), i);
			return false;
		}
	}
	// Test 4 const reference
	{
		StringVec v = createStringVec ("const std :: string & bla");
		bool result;
		CppType type;
		StringVec::const_iterator i = matchCppType (v.begin(), v.end(), &result, &type);
		if (!result || i != v.begin() + 5){
			fprintf (stderr, "test_matchCppType4 failed: %d %s\n", result, sf::toJSON (type).c_str());
			markPosition (v.begin(), v.end(), i);
			return false;
		}
	}

	return true;
}
/*static*/ bool StructureParser::test_matchTypeName () {
	// Test 1
	{
		StringVec v = createStringVec ("int");
		bool result;
		StringVec::const_iterator i = matchTypeName (v.begin(), v.end(), &result);
		if (!result || i != v.end()){
			fprintf (stderr, "test_matchTypeName1 failed\n");
			return false;
		}
	}
	// Test 2 (more complex)
	{
		StringVec v = createStringVec ("std :: vector < std :: string > notInType");
		bool result;
		StringVec::const_iterator i = matchTypeName (v.begin(), v.end(), &result);
		if (!result || i != v.begin() + 8){
			fprintf (stderr, "test_matchTypeName2 failed\n");
			markPosition (v.begin(),v.end(), i);
			return false;
		}
	}
	{
		StringVec v = createStringVec ("std :: string x");
		bool result;
		StringVec::const_iterator i = matchTypeName (v.begin(), v.end(), &result);
		if (!result || i != v.begin() + 3){
			fprintf (stderr, "test_matchTypeName3 failed\n");
			markPosition (v.begin(), v.end(), i);
			return false;
		}
	}
	// Test 4 failing parsing
	{
		StringVec v = createStringVec ("std :: vector < < std :: astring > notInType");
		// missing '>'
		bool result;
		/*StringVec::const_iterator i = */ matchTypeName (v.begin(), v.end(), &result);
		if (result){
			fprintf (stderr, "test_matchTypeName4 failed\n");
			return false;
		}
	}
	return true;
}
Exemple #3
0
void Piece::incrementDiagonal(int diagId, int id, int diagonal,
		map<int,int>* values, vector<Object*> board){
	diagId = id + diagonal;
	markPosition(diagId,diagonal,values,board);
}
/**
 * Convenient way to "save" the current location in the world frame.
 */
void Odometer::markPosition() {
	markPosition(X, Y);
}