source: src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp@ 8d38e6

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 8d38e6 was 8d38e6, checked in by Frederik Heber <heber@…>, 9 years ago

Added more unit test functions up to N=8 to SphericalPointDistributionUnitTest.

  • marked unit test as XFAIL.
  • Property mode set to 100644
File size: 11.3 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2014 Frederik Heber. 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 * SphericalPointDistributionUnitTest.cpp
25 *
26 * Created on: May 29, 2014
27 * Author: heber
28 */
29
30// include config.h
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35using namespace std;
36
37#include <cppunit/CompilerOutputter.h>
38#include <cppunit/extensions/TestFactoryRegistry.h>
39#include <cppunit/ui/text/TestRunner.h>
40
41// include headers that implement a archive in simple text format
42#include <boost/archive/text_oarchive.hpp>
43#include <boost/archive/text_iarchive.hpp>
44
45#include "SphericalPointDistributionUnitTest.hpp"
46
47#include <boost/assign.hpp>
48
49#include "CodePatterns/Assert.hpp"
50#include "CodePatterns/Log.hpp"
51
52#include "Fragmentation/Exporters/SphericalPointDistribution.hpp"
53
54#ifdef HAVE_TESTRUNNER
55#include "UnitTestMain.hpp"
56#endif /*HAVE_TESTRUNNER*/
57
58using namespace boost::assign;
59
60/********************************************** Test classes **************************************/
61
62// Registers the fixture into the 'registry'
63CPPUNIT_TEST_SUITE_REGISTRATION( SphericalPointDistributionTest );
64
65
66void SphericalPointDistributionTest::setUp()
67{
68 // failing asserts should be thrown
69 ASSERT_DO(Assert::Throw);
70
71 setVerbosity(5);
72}
73
74
75void SphericalPointDistributionTest::tearDown()
76{
77}
78
79/** UnitTest for matchSphericalPointDistributions() with two points
80 */
81void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_2()
82{
83 SphericalPointDistribution SPD(1.);
84 // test with one point, matching trivially
85 {
86 SphericalPointDistribution::Polygon_t polygon;
87 polygon += Vector(1.,0.,0.);
88 SphericalPointDistribution::Polygon_t newpolygon =
89 SPD.get<2>();
90 SphericalPointDistribution::Polygon_t expected;
91 expected += Vector(-1.,0.,0.);
92 SphericalPointDistribution::Polygon_t remaining =
93 SphericalPointDistribution::matchSphericalPointDistributions(
94 polygon,
95 newpolygon);
96 CPPUNIT_ASSERT_EQUAL( expected, remaining );
97 }
98
99 // test with one point, just a flip of axis
100 {
101 SphericalPointDistribution::Polygon_t polygon;
102 polygon += Vector(0.,1.,0.);
103 SphericalPointDistribution::Polygon_t newpolygon =
104 SPD.get<2>();
105 SphericalPointDistribution::Polygon_t expected;
106 expected += Vector(0.,-1.,0.);
107 SphericalPointDistribution::Polygon_t remaining =
108 SphericalPointDistribution::matchSphericalPointDistributions(
109 polygon,
110 newpolygon);
111 CPPUNIT_ASSERT_EQUAL( expected, remaining );
112 }
113
114 // test with one point, just a flip to another axis
115 {
116 SphericalPointDistribution::Polygon_t polygon;
117 polygon += Vector(0.,0.,-1.);
118 SphericalPointDistribution::Polygon_t newpolygon =
119 SPD.get<2>();
120 SphericalPointDistribution::Polygon_t expected;
121 expected += Vector(0.,0.,1.);
122 SphericalPointDistribution::Polygon_t remaining =
123 SphericalPointDistribution::matchSphericalPointDistributions(
124 polygon,
125 newpolygon);
126 CPPUNIT_ASSERT_EQUAL( expected, remaining );
127 }
128}
129
130/** UnitTest for matchSphericalPointDistributions() with three points
131 */
132void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_3()
133{
134 SphericalPointDistribution SPD(1.);
135
136 // test with one point, matching trivially
137 {
138 SphericalPointDistribution::Polygon_t polygon;
139 polygon += Vector(1.,0.,0.);
140 SphericalPointDistribution::Polygon_t newpolygon =
141 SPD.get<3>();
142 SphericalPointDistribution::Polygon_t expected = newpolygon;
143 expected.pop_front(); // remove first point
144 SphericalPointDistribution::Polygon_t remaining =
145 SphericalPointDistribution::matchSphericalPointDistributions(
146 polygon,
147 newpolygon);
148 CPPUNIT_ASSERT_EQUAL( expected, remaining );
149 }
150
151 // test with one point, just a flip of axis
152 {
153 SphericalPointDistribution::Polygon_t polygon;
154 polygon += Vector(0.,1.,0.);
155 SphericalPointDistribution::Polygon_t newpolygon =
156 SPD.get<3>();
157 SphericalPointDistribution::Polygon_t expected = newpolygon;
158 expected.pop_front(); // remove first point
159 SphericalPointDistribution::Polygon_t remaining =
160 SphericalPointDistribution::matchSphericalPointDistributions(
161 polygon,
162 newpolygon);
163 CPPUNIT_ASSERT_EQUAL( expected, remaining );
164 }
165}
166
167/** UnitTest for matchSphericalPointDistributions() with four points
168 */
169void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_4()
170{
171 SphericalPointDistribution SPD(1.);
172
173 // test with one point, matching trivially
174 {
175 SphericalPointDistribution::Polygon_t polygon;
176 polygon += Vector(1.,0.,0.);
177 SphericalPointDistribution::Polygon_t newpolygon =
178 SPD.get<4>();
179 SphericalPointDistribution::Polygon_t expected = newpolygon;
180 expected.pop_front(); // remove first point
181 SphericalPointDistribution::Polygon_t remaining =
182 SphericalPointDistribution::matchSphericalPointDistributions(
183 polygon,
184 newpolygon);
185 CPPUNIT_ASSERT_EQUAL( expected, remaining );
186 }
187
188 // test with one point, just a flip of axis
189 {
190 SphericalPointDistribution::Polygon_t polygon;
191 polygon += Vector(0.,1.,0.);
192 SphericalPointDistribution::Polygon_t newpolygon =
193 SPD.get<4>();
194 SphericalPointDistribution::Polygon_t expected = newpolygon;
195 expected.pop_front(); // remove first point
196 SphericalPointDistribution::Polygon_t remaining =
197 SphericalPointDistribution::matchSphericalPointDistributions(
198 polygon,
199 newpolygon);
200 CPPUNIT_ASSERT_EQUAL( expected, remaining );
201 }
202}
203
204/** UnitTest for matchSphericalPointDistributions() with five points
205 */
206void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_5()
207{
208 SphericalPointDistribution SPD(1.);
209
210 // test with one point, matching trivially
211 {
212 SphericalPointDistribution::Polygon_t polygon;
213 polygon += Vector(1.,0.,0.);
214 SphericalPointDistribution::Polygon_t newpolygon =
215 SPD.get<5>();
216 SphericalPointDistribution::Polygon_t expected = newpolygon;
217 expected.pop_front(); // remove first point
218 SphericalPointDistribution::Polygon_t remaining =
219 SphericalPointDistribution::matchSphericalPointDistributions(
220 polygon,
221 newpolygon);
222 CPPUNIT_ASSERT_EQUAL( expected, remaining );
223 }
224
225 // test with one point, just a flip of axis
226 {
227 SphericalPointDistribution::Polygon_t polygon;
228 polygon += Vector(0.,1.,0.);
229 SphericalPointDistribution::Polygon_t newpolygon =
230 SPD.get<5>();
231 SphericalPointDistribution::Polygon_t expected = newpolygon;
232 expected.pop_front(); // remove first point
233 SphericalPointDistribution::Polygon_t remaining =
234 SphericalPointDistribution::matchSphericalPointDistributions(
235 polygon,
236 newpolygon);
237 CPPUNIT_ASSERT_EQUAL( expected, remaining );
238 }
239}
240
241/** UnitTest for matchSphericalPointDistributions() with six points
242 */
243void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_6()
244{
245 SphericalPointDistribution SPD(1.);
246
247 // test with one point, matching trivially
248 {
249 SphericalPointDistribution::Polygon_t polygon;
250 polygon += Vector(1.,0.,0.);
251 SphericalPointDistribution::Polygon_t newpolygon =
252 SPD.get<6>();
253 SphericalPointDistribution::Polygon_t expected = newpolygon;
254 expected.pop_front(); // remove first point
255 SphericalPointDistribution::Polygon_t remaining =
256 SphericalPointDistribution::matchSphericalPointDistributions(
257 polygon,
258 newpolygon);
259 CPPUNIT_ASSERT_EQUAL( expected, remaining );
260 }
261
262 // test with one point, just a flip of axis
263 {
264 SphericalPointDistribution::Polygon_t polygon;
265 polygon += Vector(0.,1.,0.);
266 SphericalPointDistribution::Polygon_t newpolygon =
267 SPD.get<6>();
268 SphericalPointDistribution::Polygon_t expected = newpolygon;
269 expected.pop_front(); // remove first point
270 SphericalPointDistribution::Polygon_t remaining =
271 SphericalPointDistribution::matchSphericalPointDistributions(
272 polygon,
273 newpolygon);
274 CPPUNIT_ASSERT_EQUAL( expected, remaining );
275 }
276}
277
278/** UnitTest for matchSphericalPointDistributions() with seven points
279 */
280void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_7()
281{
282 SphericalPointDistribution SPD(1.);
283
284 // test with one point, matching trivially
285 {
286 SphericalPointDistribution::Polygon_t polygon;
287 polygon += Vector(1.,0.,0.);
288 SphericalPointDistribution::Polygon_t newpolygon =
289 SPD.get<7>();
290 SphericalPointDistribution::Polygon_t expected = newpolygon;
291 expected.pop_front(); // remove first point
292 SphericalPointDistribution::Polygon_t remaining =
293 SphericalPointDistribution::matchSphericalPointDistributions(
294 polygon,
295 newpolygon);
296 CPPUNIT_ASSERT_EQUAL( expected, remaining );
297 }
298
299 // test with one point, just a flip of axis
300 {
301 SphericalPointDistribution::Polygon_t polygon;
302 polygon += Vector(0.,1.,0.);
303 SphericalPointDistribution::Polygon_t newpolygon =
304 SPD.get<7>();
305 SphericalPointDistribution::Polygon_t expected = newpolygon;
306 expected.pop_front(); // remove first point
307 SphericalPointDistribution::Polygon_t remaining =
308 SphericalPointDistribution::matchSphericalPointDistributions(
309 polygon,
310 newpolygon);
311 CPPUNIT_ASSERT_EQUAL( expected, remaining );
312 }
313}
314
315/** UnitTest for matchSphericalPointDistributions() with eight points
316 */
317void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_8()
318{
319 SphericalPointDistribution SPD(1.);
320
321 // test with one point, matching trivially
322 {
323 SphericalPointDistribution::Polygon_t polygon;
324 polygon += Vector(1.,0.,0.);
325 SphericalPointDistribution::Polygon_t newpolygon =
326 SPD.get<8>();
327 SphericalPointDistribution::Polygon_t expected = newpolygon;
328 expected.pop_front(); // remove first point
329 SphericalPointDistribution::Polygon_t remaining =
330 SphericalPointDistribution::matchSphericalPointDistributions(
331 polygon,
332 newpolygon);
333 CPPUNIT_ASSERT_EQUAL( expected, remaining );
334 }
335
336 // test with one point, just a flip of axis
337 {
338 SphericalPointDistribution::Polygon_t polygon;
339 polygon += Vector(0.,1.,0.);
340 SphericalPointDistribution::Polygon_t newpolygon =
341 SPD.get<8>();
342 SphericalPointDistribution::Polygon_t expected = newpolygon;
343 expected.pop_front(); // remove first point
344 SphericalPointDistribution::Polygon_t remaining =
345 SphericalPointDistribution::matchSphericalPointDistributions(
346 polygon,
347 newpolygon);
348 CPPUNIT_ASSERT_EQUAL( expected, remaining );
349 }
350}
Note: See TracBrowser for help on using the repository browser.