Skip to content

Commit

Permalink
refs #5633 #5634. Test via FunctionFactory
Browse files Browse the repository at this point in the history
Quite a simple but important test, because these functions would not work via NormaliseByDetector unless they were factory registered. Also provides checking that they are types of IFunction, since the test downcasts the boost shared_ptr.
  • Loading branch information
OwenArnold committed Jul 25, 2012
1 parent 713f964 commit 76e97bb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion Code/Mantid/Framework/CurveFitting/test/ProductLinearExpTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "MantidCurveFitting/Jacobian.h"
#include "MantidAPI/FunctionDomain1D.h"
#include "MantidAPI/FunctionValues.h"
#include "MantidAPI/FunctionFactory.h"
#include <algorithm>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
Expand Down Expand Up @@ -114,12 +115,20 @@ class ProductLinearExpTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS("ProductLinearExp", func.name());
}

void test_catagory()
void test_category()
{
ProductLinearExp func;
TS_ASSERT_EQUALS("Calibrate", func.category());
}

void test_registered_with_factory()
{
IFunction_sptr func = FunctionFactory::Instance().createFunction("ProductLinearExp");
TS_ASSERT(func != NULL);
TS_ASSERT_EQUALS(func->name(), "ProductLinearExp");
TS_ASSERT(boost::dynamic_pointer_cast<ProductLinearExp>(func) != NULL);
}

void test_set_parameters()
{
const double A0 = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "MantidCurveFitting/Jacobian.h"
#include "MantidAPI/FunctionDomain1D.h"
#include "MantidAPI/FunctionValues.h"
#include "MantidAPI/FunctionFactory.h"
#include <algorithm>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
Expand Down Expand Up @@ -109,12 +110,20 @@ class ProductQuadraticExpTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS("ProductQuadraticExp", func.name());
}

void test_catagory()
void test_category()
{
ProductQuadraticExp func;
TS_ASSERT_EQUALS("Calibrate", func.category());
}

void test_registered_with_factory()
{
IFunction_sptr func = FunctionFactory::Instance().createFunction("ProductQuadraticExp");
TS_ASSERT(func != NULL);
TS_ASSERT_EQUALS(func->name(), "ProductQuadraticExp");
TS_ASSERT(boost::dynamic_pointer_cast<ProductQuadraticExp>(func) != NULL);
}

void test_set_parameters()
{
const double A0 = 1;
Expand Down

0 comments on commit 76e97bb

Please sign in to comment.