Example #1
0
TEST(Property, StringProp) {
#if __cplusplus > 201100L || (defined(_MSC_VER) && _MSC_VER >= 1800)
    using namespace std;
#else
    using namespace std::tr1;
#endif

    PropertyDefMap propertyDefs;
    Foo foo;
    PropertySet props;

    PropertyDefMap::iterator defi = propertyDefs.insert(PropertyDefMap::value_type("name", 
            PropertyDef("name", 
            "The name of the object.", PROP_STRING))).first;

    props.addProperty(
        OGRE_NEW Property<String>(&(defi->second),
        bind(&Foo::getName, &foo),
        bind(&Foo::setName, &foo, placeholders::_1)));

    Ogre::String strName, strTest;
    strTest = "A simple name";
    props.setValue("name", strTest);
    props.getValue("name", strName);

    ASSERT_EQ(strTest, strName);
}
void PropertyTests::testStringProp()
{
	PropertyDefMap propertyDefs;
	Foo foo;
	PropertySet props;

	PropertyDefMap::iterator defi = propertyDefs.insert(PropertyDefMap::value_type("name", 
			PropertyDef("name", 
			"The name of the object.", PROP_STRING))).first;

	props.addProperty(
		OGRE_NEW Property<String>(&(defi->second),
		boost::bind(&Foo::getName, &foo), 
		boost::bind(&Foo::setName, &foo, _1)));

	Ogre::String strName, strTest;
	strTest = "A simple name";
	props.setValue("name", strTest);
	props.getValue("name", strName);

	CPPUNIT_ASSERT_EQUAL(strTest, strName);

}