/*
* Project: MoleCuilder
* Description: creates and alters molecular systems
* Copyright (C) 2012 University of Bonn. 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 .
*/
/*
* SamplingGridPropertiesUnitTest.cpp
*
* Created on: Jul 29, 2012
* Author: heber
*/
// include config.h
#ifdef HAVE_CONFIG_H
#include
#endif
using namespace std;
#include
#include
#include
#include "SamplingGridPropertiesUnitTest.hpp"
#include "CodePatterns/Assert.hpp"
#ifdef HAVE_TESTRUNNER
#include "UnitTestMain.hpp"
#endif /*HAVE_TESTRUNNER*/
/********************************************** Test classes **************************************/
// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION( SamplingGridPropertiesTest );
void SamplingGridPropertiesTest::setUp()
{
// failing asserts should be thrown
ASSERT_DO(Assert::Throw);
// create the grid
const double begin[3] = { 0., 0., 0. };
props = new SamplingGridProperties(begin, 1., 2);
}
void SamplingGridPropertiesTest::tearDown()
{
delete props;
}
/** UnitTest for isCompatible()
*/
void SamplingGridPropertiesTest::isCompatible_Test()
{
const double begin[3] = { 0., 0., 0. };
const double otherbegin[3] = { 1., 0.1, -0.5 };
// create other props
SamplingGridProperties sameprops(begin, 1., 2);
SamplingGridProperties otherprops(otherbegin, 1., 2);
SamplingGridProperties anotherprops(begin, 2., 2);
SamplingGridProperties moreotherprops(begin, 1., 4);
CPPUNIT_ASSERT( props->isCompatible(*props) );
CPPUNIT_ASSERT( props->isCompatible(sameprops) );
CPPUNIT_ASSERT( sameprops.isCompatible(*props) );
CPPUNIT_ASSERT( !props->isCompatible(otherprops) );
CPPUNIT_ASSERT( !otherprops.isCompatible(*props) );
CPPUNIT_ASSERT( !props->isCompatible(anotherprops) );
CPPUNIT_ASSERT( !anotherprops.isCompatible(*props) );
CPPUNIT_ASSERT( !props->isCompatible(moreotherprops) );
CPPUNIT_ASSERT( !moreotherprops.isCompatible(*props) );
}
/** UnitTest for operator==()
*/
void SamplingGridPropertiesTest::equality_Test()
{
const double begin[3] = { 0., 0., 0. };
const double otherbegin[3] = { 1., 0.1, -0.5 };
// create other props
SamplingGridProperties sameprops(begin, 1., 2);
SamplingGridProperties otherprops(otherbegin, 1., 2);
SamplingGridProperties anotherprops(begin, 2., 2);
SamplingGridProperties moreotherprops(begin, 1., 4);
CPPUNIT_ASSERT( *props == *props );
CPPUNIT_ASSERT( *props == sameprops );
CPPUNIT_ASSERT( *props != otherprops );
CPPUNIT_ASSERT( *props != anotherprops );
CPPUNIT_ASSERT( *props != moreotherprops );
}