/*
* Project: MoleCuilder
* Description: creates and alters molecular systems
* Copyright (C) 2013 Frederik Heber. All rights reserved.
*
*
* This file is part of MoleCuilder.
*
* MoleCuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* MoleCuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MoleCuilder. If not, see .
*/
/*
* ConstantPotentialUnitTest.cpp
*
* Created on: May 09, 2013
* Author: heber
*/
// include config.h
#ifdef HAVE_CONFIG_H
#include
#endif
using namespace std;
#include
#include
#include
#include "ConstantPotentialUnitTest.hpp"
#include
#include "CodePatterns/Assert.hpp"
#include "FunctionApproximation/FunctionArgument.hpp"
#include "Potentials/Specifics/ConstantPotential.hpp"
#include "Potentials/helpers.hpp"
using namespace boost::assign;
#ifdef HAVE_TESTRUNNER
#include "UnitTestMain.hpp"
#endif /*HAVE_TESTRUNNER*/
/********************************************** Test classes **************************************/
// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION( ConstantPotentialTest );
const double offset = 0.1;
void ConstantPotentialTest::setUp()
{
// failing asserts should be thrown
ASSERT_DO(Assert::Throw);
}
void ConstantPotentialTest::tearDown()
{
}
/** UnitTest for operator()
*/
void ConstantPotentialTest::operatorTest()
{
ConstantPotential::ParticleTypes_t types;
ConstantPotential constant(types, offset);
CPPUNIT_ASSERT(
Helpers::isEqual(
offset,
constant( FunctionModel::arguments_t() )[0]
)
);
}
/** UnitTest for derivative()
*/
void ConstantPotentialTest::derivativeTest()
{
ConstantPotential::ParticleTypes_t types;
ConstantPotential constant(types, offset);
CPPUNIT_ASSERT(
Helpers::isEqual(
0.,
constant.derivative(
FunctionModel::arguments_t()
)[0]
)
);
}
/** UnitTest for parameter_derivative()
*/
void ConstantPotentialTest::parameter_derivativeTest()
{
ConstantPotential::ParticleTypes_t types;
ConstantPotential constant(types, offset);
CPPUNIT_ASSERT(
Helpers::isEqual(
1.,
constant.parameter_derivative(
FunctionModel::arguments_t(),
0
)[0]
)
);
}