Skip to content

Commit

Permalink
Refs #11219. Changing implementation of nParams and nAttributes
Browse files Browse the repository at this point in the history
These methods now return 0 instead of throwing when no function is decorated.
  • Loading branch information
Michael Wedel committed Mar 4, 2015
1 parent fc19c38 commit 8826549
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Code/Mantid/Framework/API/src/FunctionParameterDecorator.cpp
Expand Up @@ -79,7 +79,9 @@ double FunctionParameterDecorator::getParameter(const std::string &name) const {
}

size_t FunctionParameterDecorator::nParams() const {
throwIfNoFunctionSet();
if(!m_wrappedFunction) {
return 0;
}

return m_wrappedFunction->nParams();
}
Expand Down Expand Up @@ -147,7 +149,9 @@ size_t FunctionParameterDecorator::getParameterIndex(
}

size_t FunctionParameterDecorator::nAttributes() const {
throwIfNoFunctionSet();
if(!m_wrappedFunction) {
return 0;
}

return m_wrappedFunction->nAttributes();
}
Expand Down
Expand Up @@ -127,7 +127,7 @@ class FunctionParameterDecoratorTest : public CxxTest::TestSuite {

void testNParams() {
TestableFunctionParameterDecorator invalidFn;
TS_ASSERT_THROWS(invalidFn.nParams(), std::runtime_error);
TS_ASSERT_EQUALS(invalidFn.nParams(), 0);

FunctionParameterDecorator_sptr fn =
getFunctionParameterDecoratorGaussian();
Expand Down Expand Up @@ -215,7 +215,7 @@ class FunctionParameterDecoratorTest : public CxxTest::TestSuite {

void testAttributes() {
TestableFunctionParameterDecorator invalidFn;
TS_ASSERT_THROWS(invalidFn.nAttributes(), std::runtime_error);
TS_ASSERT_EQUALS(invalidFn.nAttributes(), 0);

FunctionParameterDecorator_sptr fn =
getFunctionParameterDecoratorGaussian();
Expand Down

0 comments on commit 8826549

Please sign in to comment.