Example #1
0
void Actor::printActions(std::ostringstream& buff, bool full)
{
	buff.clear();
	buff<<"Actor state: "<<m_state->getName()<<std::endl;
	buff<<"Actor actions on effectors: "<<std::endl;
	for(EffectorMap::iterator it = m_effectors.begin(),end = m_effectors.end();
			it!=end;it++)
	{
		Effector* effector = it->second;
		buff<<Effector::convertToString(effector->getId())<<std::endl;
		std::string tabs;

		print(effector,m_rootAction,buff,tabs,full);
	}
}
/* normal construction test */
void EffectorTest::normalConstruction() {

    int id = 1;
    std::string name = "test";
    float mass = 2;
    float length = 3;

    using namespace RoboticArm;

    Effector createdPart = Effector(id, name, mass, length);

    if (createdPart.getId() == id && createdPart.getName() == name &&
            createdPart.getLength() == length && createdPart.getMass() == mass) {
        CPPUNIT_ASSERT(true);
    } else {
        CPPUNIT_ASSERT(false);
    }

}
void EffectorTest::validParReadBack(){
    
    bool success = true;

    int id = 111;
    std::string name = "test";
    float mass = 123.54566;
    float length = 14676.54;

    using namespace RoboticArm;

    try {
        Effector createdPart = Effector(id, name, mass, length);

        if (id != createdPart.getId()) {
            std::cout << "ID is wrong." << std::endl;
            success = false;
        }

        if (name != createdPart.getName()) {
            std::cout << "Name is wrong." << std::endl;
            success = false;
        }

        if (mass != createdPart.getMass()) {
            std::cout << "Mass is wrong." << std::endl;
            success = false;
        }

        if (length != createdPart.getLength()) {
            std::cout << "Length is wrong." << std::endl;
            success = false;
        }


    } catch (const std::invalid_argument& ia) {
        success = false;
    }

    CPPUNIT_ASSERT(success);

}