source: src/Filling/unittests/IsVoidNode_FillPredicateUnitTest.cpp

Candidate_v1.6.1
Last change on this file was 94d5ac6, checked in by Frederik Heber <heber@…>, 12 years ago

FIX: As we use GSL internally, we are as of now required to use GPL v2 license.

  • GNU Scientific Library is used at every place in the code, especially the sub-package LinearAlgebra is based on it which in turn is used really everywhere in the remainder of MoleCuilder. Hence, we have to use the GPL license for the whole of MoleCuilder. In effect, GPL's COPYING was present all along and stated the terms of the GPL v2 license.
  • Hence, I added the default GPL v2 disclaimer to every source file and removed the note about a (actually missing) LICENSE file.
  • also, I added a help-redistribute action which again gives the disclaimer of the GPL v2.
  • also, I changed in the disclaimer that is printed at every program start in builder_init.cpp.
  • TEST: Added check on GPL statement present in every module to test CodeChecks project-disclaimer.
  • Property mode set to 100644
File size: 4.5 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
5 *
6 *
7 * This file is part of MoleCuilder.
8 *
9 * MoleCuilder is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * MoleCuilder is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/*
24 * IsVoidNode_FillPredicateUnitTest.cpp
25 *
26 * Created on: Jan 18, 2012
27 * Author: heber
28 */
29
30// include config.h
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35#include <cppunit/CompilerOutputter.h>
36#include <cppunit/extensions/TestFactoryRegistry.h>
37#include <cppunit/ui/text/TestRunner.h>
38
39#include <algorithm>
40#include <boost/bind.hpp>
41#include <iostream>
42
43#include "CodePatterns/Assert.hpp"
44
45#include "Atom/atom.hpp"
46#include "Box.hpp"
47#include "Filling/Predicates/IsVoidNode_FillPredicate.hpp"
48#include "LinearAlgebra/RealSpaceMatrix.hpp"
49#include "Filling/NodeTypes.hpp"
50#include "Shapes/BaseShapes.hpp"
51#include "Shapes/Shape.hpp"
52#include "World.hpp"
53
54#include "IsVoidNode_FillPredicateUnitTest.hpp"
55
56#ifdef HAVE_TESTRUNNER
57#include "UnitTestMain.hpp"
58#endif /*HAVE_TESTRUNNER*/
59
60/********************************************** Test classes **************************************/
61
62// Registers the fixture into the 'registry'
63CPPUNIT_TEST_SUITE_REGISTRATION( IsVoidNode_FillPredicateTest );
64
65void DoSomething(atom * const _atom)
66{
67 _atom->setPosition( Vector((double)_atom->getId(), 0., 0.) );
68}
69
70void IsVoidNode_FillPredicateTest::setUp()
71{
72 // failing asserts should be thrown
73 ASSERT_DO(Assert::Throw);
74
75 // set default BCs to ignore
76 World::getInstance().getDomain().setConditions(
77 BoundaryConditions::Conditions_t(3, BoundaryConditions::Ignore)
78 );
79
80 // create some atoms as "neighbours"
81 atoms.resize((size_t)5, NULL);
82 std::generate_n(atoms.begin(), (size_t)5, boost::bind(&World::createAtom, World::getPointer()) );
83
84 // position them
85 std::for_each(atoms.begin(), atoms.end(), &DoSomething);
86
87 predicate = new FillPredicate(IsVoidNode_FillPredicate(Sphere()));
88}
89
90
91void IsVoidNode_FillPredicateTest::tearDown()
92{
93 delete predicate;
94
95 World::purgeInstance();
96}
97
98/** Test whether operator() returns as desired
99 *
100 */
101void IsVoidNode_FillPredicateTest::operatorTest()
102{
103#ifndef NDEBUG
104 std::cout << "The following Assertion is intended and does not represent a failure of the test." << std::endl;
105 CPPUNIT_ASSERT_THROW( (*predicate)( Vector(-2.,0.,0.)), Assert::AssertionFailure );
106#else
107 CPPUNIT_ASSERT( (*predicate)( Vector(-2.,0.,0.)) );
108#endif
109 for (double i = 0; i < 5.; ++i) {
110 CPPUNIT_ASSERT( !(*predicate)( Vector(i, 0., 0.)) );
111 CPPUNIT_ASSERT( !(*predicate)( Vector(i, 1., 0.)) );
112#ifndef NDEBUG
113 std::cout << "The following Assertion is intended and does not represent a failure of the test." << std::endl;
114 CPPUNIT_ASSERT_THROW( (*predicate)( Vector(i, -1., 0.)), Assert::AssertionFailure );
115#else
116 CPPUNIT_ASSERT( !(*predicate)( Vector(i, -1., 0.)) );
117#endif
118 CPPUNIT_ASSERT( !(*predicate)( Vector(i, 0., 1.)) );
119#ifndef NDEBUG
120 std::cout << "The following Assertion is intended and does not represent a failure of the test." << std::endl;
121 CPPUNIT_ASSERT_THROW( (*predicate)( Vector(i, 0., -1.)), Assert::AssertionFailure );
122#else
123 CPPUNIT_ASSERT( !(*predicate)( Vector(i, 0., -1.)) );
124#endif
125 }
126 CPPUNIT_ASSERT( (*predicate)( Vector(5.,1.,0.)) );
127#ifndef NDEBUG
128 std::cout << "The following Assertion is intended and does not represent a failure of the test." << std::endl;
129 CPPUNIT_ASSERT_THROW( (*predicate)( Vector(5.,-1.,0.)), Assert::AssertionFailure );
130#else
131 CPPUNIT_ASSERT( (*predicate)( Vector(5.,-1.,0.)) );
132#endif
133 CPPUNIT_ASSERT( (*predicate)( Vector(5.,0.,1.)) );
134#ifndef NDEBUG
135 std::cout << "The following Assertion is intended and does not represent a failure of the test." << std::endl;
136 CPPUNIT_ASSERT_THROW( (*predicate)( Vector(5.,0.,-1.)), Assert::AssertionFailure );
137#else
138 CPPUNIT_ASSERT( (*predicate)( Vector(5.,0.,-1.)) );
139#endif
140 CPPUNIT_ASSERT( (*predicate)( Vector(6.,0.,0.)) );
141}
Note: See TracBrowser for help on using the repository browser.