Skip to content

Commit

Permalink
refs #5633. Characterise derivs using mocking
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Jul 23, 2012
1 parent 83b754d commit 3d8e525
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/CurveFitting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ target_link_libraries ( CurveFitting ${MANTIDLIBS} ${GSL_LIBRARIES} )
if ( CXXTEST_FOUND )
include_directories ( ../DataHandling/inc ../TestHelpers/inc )
cxxtest_add_test ( CurveFittingTest ${TEST_FILES} )
target_link_libraries( CurveFittingTest CurveFitting DataHandling DataObjects)
target_link_libraries( CurveFittingTest CurveFitting DataHandling DataObjects ${GMOCK_LIBRARIES} ${GTEST_LIBRARIES})
add_dependencies ( FrameworkTests CurveFittingTest )
# Add to the 'FrameworkTests' group in VS
set_property ( TARGET CurveFittingTest PROPERTY FOLDER "UnitTests" )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace Mantid

void ProductLinearExp::functionDeriv1D(API::Jacobian* out, const double* xValues, const size_t nData)
{

throw std::runtime_error("Not Implemented");
}

void ProductLinearExp::function1D(double* out, const double* xValues, const size_t nData) const
Expand Down
25 changes: 25 additions & 0 deletions Code/Mantid/Framework/CurveFitting/test/ProductLinearExpTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,31 @@
#include "MantidCurveFitting/ExpDecay.h"
#include "MantidCurveFitting/LinearBackground.h"
#include "MantidCurveFitting/ProductFunction.h"
#include "MantidAPI/Jacobian.h"
#include "MantidAPI/FunctionDomain1D.h"
#include "MantidAPI/FunctionValues.h"
#include <algorithm>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <gmock/gmock.h>

using namespace Mantid::CurveFitting;
using namespace Mantid::API;

class ProductLinearExpTest : public CxxTest::TestSuite
{
private:

/// Mock helper type.
class MockJacobian : public Mantid::API::Jacobian
{
public:
MOCK_METHOD3(set, void(size_t, size_t, double));
MOCK_METHOD2(get, double(size_t, size_t));
~MockJacobian()
{
}
};

/// Helper type to generate number for a std::generate call.
class LinearIncrementingAssignment
Expand Down Expand Up @@ -168,6 +181,18 @@ class ProductLinearExpTest : public CxxTest::TestSuite
}
}

void test_calculate_derivative_throws()
{
// NOT implemented. Characterise with test.
ProductLinearExp func;

FunctionDomain1DVector domain(0);

MockJacobian jacobian;

TS_ASSERT_THROWS(func.functionDeriv(domain, jacobian), std::runtime_error);
}

void test_with_low_contribution_from_expdecay()
{
// Setup the test to for low contribution from exponential component.
Expand Down

0 comments on commit 3d8e525

Please sign in to comment.