[5a8d61] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
| 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
[94d5ac6] | 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/>.
|
---|
[5a8d61] | 21 | */
|
---|
| 22 |
|
---|
| 23 | /*
|
---|
| 24 | * Shape_HomogeneousPointsUnitTest.cpp
|
---|
| 25 | *
|
---|
| 26 | * Created on: Jun 19, 2010
|
---|
| 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 <cmath>
|
---|
| 40 | #include <limits>
|
---|
[c48641] | 41 | #include <vector>
|
---|
[5a8d61] | 42 |
|
---|
| 43 | #ifdef HAVE_TESTRUNNER
|
---|
| 44 | #include "UnitTestMain.hpp"
|
---|
| 45 | #endif /*HAVE_TESTRUNNER*/
|
---|
| 46 |
|
---|
| 47 | #include "CodePatterns/Assert.hpp"
|
---|
| 48 |
|
---|
[c48641] | 49 | #include "LinearAlgebra/Vector.hpp"
|
---|
[5a8d61] | 50 | #include "Shapes/BaseShapes.hpp"
|
---|
| 51 | #include "Shapes/Shape.hpp"
|
---|
| 52 |
|
---|
| 53 | #include "Shape_HomogeneousPointsUnitTest.hpp"
|
---|
| 54 |
|
---|
| 55 | // Registers the fixture into the 'registry'
|
---|
| 56 | CPPUNIT_TEST_SUITE_REGISTRATION( Shape_HomogeneousPointsTest );
|
---|
| 57 |
|
---|
| 58 | void Shape_HomogeneousPointsTest::setUp()
|
---|
| 59 | {
|
---|
| 60 | // failing asserts should be thrown
|
---|
| 61 | ASSERT_DO(Assert::Throw);
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | void Shape_HomogeneousPointsTest::tearDown()
|
---|
| 65 | {}
|
---|
| 66 |
|
---|
| 67 | /** Unit test for points on Shape's surface.
|
---|
| 68 | *
|
---|
| 69 | */
|
---|
| 70 | void Shape_HomogeneousPointsTest::surfaceTest()
|
---|
| 71 | {
|
---|
[c48641] | 72 | {
|
---|
| 73 | Shape s = Sphere();
|
---|
| 74 | std::vector<Vector> nodes = s.getHomogeneousPointsOnSurface(12);
|
---|
| 75 | CPPUNIT_ASSERT_EQUAL( (size_t)12, nodes.size());
|
---|
| 76 | for (size_t i=0;i<12;++i)
|
---|
| 77 | CPPUNIT_ASSERT( s.isOnSurface(nodes[i]) );
|
---|
| 78 | }
|
---|
| 79 | {
|
---|
| 80 | Shape s = Sphere(zeroVec, 2.);
|
---|
| 81 | std::vector<Vector> nodes = s.getHomogeneousPointsOnSurface(12);
|
---|
| 82 | CPPUNIT_ASSERT_EQUAL( (size_t)12, nodes.size());
|
---|
| 83 | for (size_t i=0;i<12;++i)
|
---|
| 84 | CPPUNIT_ASSERT( s.isOnSurface(nodes[i]) );
|
---|
| 85 | }
|
---|
[5a8d61] | 86 | }
|
---|
| 87 |
|
---|
| 88 | /** Unit test for points in Shape's volume.
|
---|
| 89 | *
|
---|
| 90 | */
|
---|
| 91 | void Shape_HomogeneousPointsTest::volumeTest()
|
---|
| 92 | {
|
---|
[c48641] | 93 | // is not implemented
|
---|
| 94 | // Shape s = Sphere();
|
---|
| 95 | // std::vector<Vector> nodes = s.getHomogeneousPointsInVolume(12);
|
---|
| 96 | // CPPUNIT_ASSERT_EQUAL( (size_t)12, nodes.size());
|
---|
| 97 | // for (size_t i=0;i<12;++i)
|
---|
| 98 | // CPPUNIT_ASSERT( s.isInside(nodes[i]) );
|
---|
[5a8d61] | 99 | }
|
---|