Skip to content

Commit

Permalink
Refs #1419 - Fix a further system test.
Browse files Browse the repository at this point in the history
Added a further specialised version of IPropertymanager::setProperty to
explicitly handle std::string.
  • Loading branch information
PeterParker committed Feb 15, 2012
1 parent 634a9b8 commit baef962
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Expand Up @@ -135,6 +135,14 @@ class MANTID_KERNEL_DLL IPropertyManager
this->setPropertyValue(name, std::string(value));
return this;
}

/// Further specialised version of setProperty template method. Needed to explicitly handle std::string - const char * is not enough.
IPropertyManager* setProperty(const std::string &name, const std::string & value)
{
this->setPropertyValue(name, value);
return this;
}

/// Return the property manager serialized as a string.
virtual std::string asString(bool withDefaultValues = false) const = 0;

Expand Down
8 changes: 8 additions & 0 deletions Code/Mantid/Framework/Kernel/test/PropertyManagerTest.h
Expand Up @@ -154,6 +154,14 @@ class PropertyManagerTest : public CxxTest::TestSuite
TS_ASSERT_THROWS_NOTHING( manager->setProperty("AProp",1) );
}

void testSetStringProperty()
{
// Make sure we can handle std::strings as well as const char *.
TS_ASSERT_THROWS_NOTHING( manager->setProperty("yetAnotherProp","aValue") );
std::string aValue("aValue");
TS_ASSERT_THROWS_NOTHING( manager->setProperty("yetAnotherProp",aValue) );
}

void testExistsProperty()
{
Property *p = new PropertyWithValue<int>("sjfudh",0);
Expand Down

0 comments on commit baef962

Please sign in to comment.