From 76e97bb7f0c883f83d6a97f19d0ac2b1f91ab3fe Mon Sep 17 00:00:00 2001 From: Owen Arnold <owen.arnold@stfc.ac.uk> Date: Wed, 25 Jul 2012 09:40:44 +0100 Subject: [PATCH] refs #5633 #5634. Test via FunctionFactory 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. --- .../CurveFitting/test/ProductLinearExpTest.h | 11 ++++++++++- .../CurveFitting/test/ProductQuadraticExpTest.h | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Code/Mantid/Framework/CurveFitting/test/ProductLinearExpTest.h b/Code/Mantid/Framework/CurveFitting/test/ProductLinearExpTest.h index 98e5e602977..5ba6f602e31 100644 --- a/Code/Mantid/Framework/CurveFitting/test/ProductLinearExpTest.h +++ b/Code/Mantid/Framework/CurveFitting/test/ProductLinearExpTest.h @@ -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> @@ -114,12 +115,20 @@ public: 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; diff --git a/Code/Mantid/Framework/CurveFitting/test/ProductQuadraticExpTest.h b/Code/Mantid/Framework/CurveFitting/test/ProductQuadraticExpTest.h index eba31d5f666..55aebbabda3 100644 --- a/Code/Mantid/Framework/CurveFitting/test/ProductQuadraticExpTest.h +++ b/Code/Mantid/Framework/CurveFitting/test/ProductQuadraticExpTest.h @@ -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> @@ -109,12 +110,20 @@ public: 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; -- GitLab