source: src/unittests/BoxUnitTest.cpp@ 30c753

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing 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_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 30c753 was d103d3, checked in by Frederik Heber <heber@…>, 13 years ago

Added additional check in CodeCheck's project disclaimer for current year in copyright.

  • had to modify all .cpp files to update to 2011.
  • Property mode set to 100644
File size: 76.1 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2011 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * BoxUnitTest.cpp
10 *
11 * Created on: Jul 30, 2010
12 * Author: crueger
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include <cppunit/CompilerOutputter.h>
21#include <cppunit/extensions/TestFactoryRegistry.h>
22#include <cppunit/ui/text/TestRunner.h>
23
24#include "LinearAlgebra/Vector.hpp"
25#include "LinearAlgebra/RealSpaceMatrix.hpp"
26#include "Box.hpp"
27#include "CodePatterns/Assert.hpp"
28
29#include "BoxUnitTest.hpp"
30
31#ifdef HAVE_TESTRUNNER
32#include "UnitTestMain.hpp"
33#endif /*HAVE_TESTRUNNER*/
34
35/********************************************** Test classes **************************************/
36
37// Registers the fixture into the 'registry'
38CPPUNIT_TEST_SUITE_REGISTRATION( BoxUnittest );
39
40void BoxUnittest::setUp(){
41 // failing asserts should be thrown
42 ASSERT_DO(Assert::Throw);
43
44 unit = new RealSpaceMatrix;
45 unit->setIdentity();
46 zero = new RealSpaceMatrix;
47 invertible = new RealSpaceMatrix;
48 invertible->diagonal() = Vector(1,2,3);
49 uninvertible = new RealSpaceMatrix;
50 uninvertible->column(0) = Vector(1,0,1);
51 uninvertible->column(2) = Vector(1,0,1);
52
53 RealSpaceMatrix boxMat;
54 unitBox = new Box;
55 stretchedBox1 = new Box;
56 boxMat.setIdentity();
57 boxMat.diagonal() = Vector(1,2,3);
58 stretchedBox1->setM(boxMat);
59
60 stretchedBox2 = new Box;
61 boxMat.setIdentity();
62 boxMat.diagonal() = Vector(2,3,1);
63 stretchedBox2->setM(boxMat);
64
65 stretchedBox3 = new Box;
66 boxMat.setIdentity();
67 boxMat.diagonal() = Vector(3,1,2);
68 stretchedBox3->setM(boxMat);
69
70 stretchedBox4 = new Box;
71 boxMat.setIdentity();
72 boxMat.diagonal() = Vector(2,2,2);
73 stretchedBox4->setM(boxMat);
74
75 tiltedBox1 = new Box;
76 boxMat.setIdentity();
77 boxMat.column(0) = Vector(1,0,1);
78 tiltedBox1->setM(boxMat);
79
80 tiltedBox2 = new Box;
81 boxMat.setIdentity();
82 boxMat.column(0) = Vector(1,1,1);
83 tiltedBox2->setM(boxMat);
84
85 tiltedBox3 = new Box;
86 boxMat.setIdentity();
87 boxMat.column(1) = Vector(0,1,1);
88 tiltedBox3->setM(boxMat);
89
90 tiltedBox4 = new Box;
91 boxMat.setIdentity();
92 boxMat.column(0) = Vector(1,1,1);
93 boxMat.column(1) = Vector(0,1,1);
94 tiltedBox4->setM(boxMat);
95
96}
97
98void BoxUnittest::tearDown(){
99 delete unit;
100 delete zero;
101 delete invertible;
102 delete uninvertible;
103
104 delete unitBox;
105 delete stretchedBox1;
106 delete stretchedBox2;
107 delete stretchedBox3;
108 delete stretchedBox4;
109 delete tiltedBox1;
110 delete tiltedBox2;
111 delete tiltedBox3;
112 delete tiltedBox4;
113
114}
115
116void BoxUnittest::setBoxTest(){
117 Box testBox;
118 CPPUNIT_ASSERT_NO_THROW(testBox.setM(*unit));
119 CPPUNIT_ASSERT_NO_THROW(testBox = *unit);
120 CPPUNIT_ASSERT_NO_THROW(testBox.setM(*invertible));
121 CPPUNIT_ASSERT_NO_THROW(testBox = *invertible);
122#ifndef NDEBUG
123 CPPUNIT_ASSERT_THROW(testBox.setM(*zero),Assert::AssertionFailure);
124 CPPUNIT_ASSERT_THROW(testBox = *zero,Assert::AssertionFailure);
125 CPPUNIT_ASSERT_THROW(testBox.setM(*uninvertible),Assert::AssertionFailure);
126 CPPUNIT_ASSERT_THROW(testBox = *uninvertible,Assert::AssertionFailure);
127#endif
128}
129
130void BoxUnittest::translateInOutTest(){
131 Vector testVector;
132 {
133 testVector=Vector(0,0,0);
134 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
135 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
136 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
137 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
138 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
139 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
140 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
141 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
142 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
143 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
144 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
145 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
146 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
147 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
148 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
149 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
150 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
151 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
152 }
153
154 {
155 testVector=Vector(0.5,0.5,0.5);
156 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
157 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
158 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
159 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
160 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
161 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
162 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
163 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
164 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
165 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
166 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
167 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
168 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
169 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
170 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
171 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
172 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
173 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
174 }
175
176 {
177 testVector=Vector(1,1,1);
178 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
179 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
180 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
181 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
182 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
183 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
184 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
185 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
186 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
187 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
188 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
189 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
190 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
191 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
192 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
193 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
194 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
195 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
196 }
197
198 {
199 testVector=Vector(2,1,1);
200 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
201 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
202 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
203 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
204 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
205 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
206 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
207 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
208 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
209 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
210 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
211 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
212 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
213 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
214 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
215 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
216 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
217 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
218 }
219
220 {
221 testVector=Vector(1,2,1);
222 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
223 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
224 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
225 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
226 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
227 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
228 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
229 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
230 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
231 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
232 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
233 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
234 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
235 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
236 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
237 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
238 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
239 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
240 }
241
242 {
243 testVector=Vector(1,1,2);
244 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
245 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
246 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
247 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
248 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
249 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
250 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
251 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
252 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
253 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
254 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
255 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
256 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
257 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
258 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
259 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
260 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
261 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
262 }
263
264 {
265 testVector=Vector(3,1,1);
266 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
267 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
268 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
269 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
270 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
271 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
272 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
273 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
274 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
275 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
276 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
277 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
278 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
279 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
280 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
281 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
282 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
283 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
284 }
285
286 {
287 testVector=Vector(1,3,1);
288 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
289 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
290 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
291 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
292 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
293 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
294 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
295 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
296 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
297 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
298 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
299 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
300 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
301 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
302 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
303 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
304 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
305 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
306 }
307
308 {
309 testVector=Vector(1,1,3);
310 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
311 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
312 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
313 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
314 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
315 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
316 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
317 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
318 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
319 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
320 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
321 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
322 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
323 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
324 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
325 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
326 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
327 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
328 }
329
330 {
331 testVector=Vector(2,2,2);
332 CPPUNIT_ASSERT_EQUAL(unitBox->translateOut(unitBox->translateIn(testVector)),testVector);
333 CPPUNIT_ASSERT_EQUAL(unitBox->translateIn(unitBox->translateOut(testVector)),testVector);
334 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateOut(stretchedBox1->translateIn(testVector)),testVector);
335 CPPUNIT_ASSERT_EQUAL(stretchedBox1->translateIn(stretchedBox1->translateOut(testVector)),testVector);
336 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateOut(stretchedBox2->translateIn(testVector)),testVector);
337 CPPUNIT_ASSERT_EQUAL(stretchedBox2->translateIn(stretchedBox2->translateOut(testVector)),testVector);
338 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateOut(stretchedBox3->translateIn(testVector)),testVector);
339 CPPUNIT_ASSERT_EQUAL(stretchedBox3->translateIn(stretchedBox3->translateOut(testVector)),testVector);
340 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateOut(stretchedBox4->translateIn(testVector)),testVector);
341 CPPUNIT_ASSERT_EQUAL(stretchedBox4->translateIn(stretchedBox4->translateOut(testVector)),testVector);
342 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateOut(tiltedBox1->translateIn(testVector)),testVector);
343 CPPUNIT_ASSERT_EQUAL(tiltedBox1->translateIn(tiltedBox1->translateOut(testVector)),testVector);
344 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateOut(tiltedBox2->translateIn(testVector)),testVector);
345 CPPUNIT_ASSERT_EQUAL(tiltedBox2->translateIn(tiltedBox2->translateOut(testVector)),testVector);
346 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateOut(tiltedBox3->translateIn(testVector)),testVector);
347 CPPUNIT_ASSERT_EQUAL(tiltedBox3->translateIn(tiltedBox3->translateOut(testVector)),testVector);
348 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateOut(tiltedBox4->translateIn(testVector)),testVector);
349 CPPUNIT_ASSERT_EQUAL(tiltedBox4->translateIn(tiltedBox4->translateOut(testVector)),testVector);
350 }
351
352}
353
354void BoxUnittest::isInsideTest(){
355 Vector testVector(0,0,0);
356 CPPUNIT_ASSERT( unitBox->isInside(testVector));
357 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
358 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
359 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
360 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
361 CPPUNIT_ASSERT( tiltedBox1->isInside(testVector));
362 CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
363 CPPUNIT_ASSERT( tiltedBox3->isInside(testVector));
364 CPPUNIT_ASSERT( tiltedBox4->isInside(testVector));
365
366
367 testVector = Vector(0.5,0.5,0.5);
368 CPPUNIT_ASSERT( unitBox->isInside(testVector));
369 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
370 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
371 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
372 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
373 CPPUNIT_ASSERT( tiltedBox1->isInside(testVector));
374 CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
375 CPPUNIT_ASSERT( tiltedBox3->isInside(testVector));
376 CPPUNIT_ASSERT( tiltedBox4->isInside(testVector));
377
378 testVector = Vector(1,1,1);
379 CPPUNIT_ASSERT( unitBox->isInside(testVector));
380 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
381 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
382 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
383 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
384 CPPUNIT_ASSERT( tiltedBox1->isInside(testVector));
385 CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
386 CPPUNIT_ASSERT( tiltedBox3->isInside(testVector));
387 CPPUNIT_ASSERT( tiltedBox4->isInside(testVector));
388
389 testVector = Vector(2,1,1);
390 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
391 CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
392 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
393 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
394 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
395 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
396 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
397 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
398 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
399
400 testVector = Vector(1,2,1);
401 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
402 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
403 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
404 CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
405 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
406 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
407 CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
408 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
409 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
410
411 testVector = Vector(1,1,2);
412 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
413 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
414 CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
415 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
416 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
417 CPPUNIT_ASSERT( tiltedBox1->isInside(testVector));
418 CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
419 CPPUNIT_ASSERT( tiltedBox3->isInside(testVector));
420 CPPUNIT_ASSERT( tiltedBox4->isInside(testVector));
421
422 testVector = Vector(3,1,1);
423 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
424 CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
425 CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
426 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
427 CPPUNIT_ASSERT(!stretchedBox4->isInside(testVector));
428 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
429 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
430 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
431 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
432
433 testVector = Vector(1,3,1);
434 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
435 CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
436 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
437 CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
438 CPPUNIT_ASSERT(!stretchedBox4->isInside(testVector));
439 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
440 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
441 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
442 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
443
444 testVector = Vector(1,1,3);
445 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
446 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
447 CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
448 CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
449 CPPUNIT_ASSERT(!stretchedBox4->isInside(testVector));
450 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
451 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
452 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
453 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
454
455 testVector = Vector(2,2,2);
456 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
457 CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
458 CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
459 CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
460 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
461 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
462 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
463 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
464 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
465
466 testVector = Vector(3,3,3);
467 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
468 CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
469 CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
470 CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
471 CPPUNIT_ASSERT(!stretchedBox4->isInside(testVector));
472 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
473 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
474 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
475 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
476}
477
478bool testWrapExplode(VECTORSET(std::vector) &set,Vector &point, Box* box){
479 bool res = true;
480 Vector wrappedPoint = box->WrapPeriodically(point);
481 for(std::vector<Vector>::iterator iter = set.begin(); iter!=set.end();++iter){
482 Vector wrapped = box->WrapPeriodically(*iter);
483 bool equals = (wrapped == wrappedPoint);
484 res = res && equals;
485 if(!equals){
486 cout << "Wrapped vector " << wrapped << " produced from vector " << (*iter) << " does not match target " << wrappedPoint << endl;
487 }
488 }
489 return res;
490}
491
492void BoxUnittest::WrapExplodeTest(){
493 Vector testVector(0,0,0);
494 VECTORSET(std::vector) res;
495
496 // we only can explode those vectors that are actually inside the box
497 {
498 testVector = Vector(0,0,0);
499 res = unitBox->explode(testVector,1);
500 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
501 res = stretchedBox1->explode(testVector,1);
502 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
503 res = stretchedBox2->explode(testVector,1);
504 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
505 res = stretchedBox3->explode(testVector,1);
506 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
507 res = stretchedBox4->explode(testVector,1);
508 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
509 res = tiltedBox1->explode(testVector,1);
510 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
511 res = tiltedBox2->explode(testVector,1);
512 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
513 res = tiltedBox3->explode(testVector,1);
514 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
515 res = tiltedBox4->explode(testVector,1);
516 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
517 }
518
519 {
520 testVector = Vector(0.5,0.5,0.5);
521 res = unitBox->explode(testVector,1);
522 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
523 res = stretchedBox1->explode(testVector,1);
524 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
525 res = stretchedBox2->explode(testVector,1);
526 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
527 res = stretchedBox3->explode(testVector,1);
528 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
529 res = stretchedBox4->explode(testVector,1);
530 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
531 res = tiltedBox1->explode(testVector,1);
532 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
533 res = tiltedBox2->explode(testVector,1);
534 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
535 res = tiltedBox3->explode(testVector,1);
536 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
537 res = tiltedBox4->explode(testVector,1);
538 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
539 }
540
541 {
542 testVector = Vector(1,1,1);
543 res = unitBox->explode(testVector,1);
544 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
545 res = stretchedBox1->explode(testVector,1);
546 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
547 res = stretchedBox2->explode(testVector,1);
548 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
549 res = stretchedBox3->explode(testVector,1);
550 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
551 res = stretchedBox4->explode(testVector,1);
552 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
553 res = tiltedBox1->explode(testVector,1);
554 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
555 res = tiltedBox2->explode(testVector,1);
556 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
557 res = tiltedBox3->explode(testVector,1);
558 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
559 res = tiltedBox4->explode(testVector,1);
560 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
561 }
562
563 {
564 testVector = Vector(2,1,1);
565 res = stretchedBox2->explode(testVector,1);
566 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
567 res = stretchedBox3->explode(testVector,1);
568 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
569 res = stretchedBox4->explode(testVector,1);
570 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
571 }
572
573 {
574 testVector = Vector(1,2,1);
575 res = stretchedBox1->explode(testVector,1);
576 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
577 res = stretchedBox2->explode(testVector,1);
578 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
579 res = stretchedBox4->explode(testVector,1);
580 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
581 res = tiltedBox2->explode(testVector,1);
582 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
583 }
584
585 {
586 testVector = Vector(1,1,2);
587 res = stretchedBox1->explode(testVector,1);
588 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
589 res = stretchedBox3->explode(testVector,1);
590 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
591 res = stretchedBox4->explode(testVector,1);
592 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
593 res = tiltedBox1->explode(testVector,1);
594 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
595 res = tiltedBox2->explode(testVector,1);
596 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
597 res = tiltedBox3->explode(testVector,1);
598 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
599 res = tiltedBox4->explode(testVector,1);
600 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
601 }
602
603 {
604 testVector = Vector(3,1,1);
605 res = stretchedBox3->explode(testVector,1);
606 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
607 }
608
609 {
610 testVector = Vector(1,3,1);
611 res = stretchedBox2->explode(testVector,1);
612 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
613 }
614
615 {
616 testVector = Vector(1,1,3);
617 res = stretchedBox1->explode(testVector,1);
618 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
619 }
620
621 {
622 testVector = Vector(2,2,2);
623 res = stretchedBox4->explode(testVector,1);
624 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
625 }
626
627 // Higher level explosions
628
629 {
630 testVector = Vector(0,0,0);
631 res = unitBox->explode(testVector,2);
632 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
633 res = stretchedBox1->explode(testVector,2);
634 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
635 res = stretchedBox2->explode(testVector,2);
636 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
637 res = stretchedBox3->explode(testVector,2);
638 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
639 res = stretchedBox4->explode(testVector,2);
640 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
641 res = tiltedBox1->explode(testVector,2);
642 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
643 res = tiltedBox2->explode(testVector,2);
644 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
645 res = tiltedBox3->explode(testVector,2);
646 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
647 res = tiltedBox4->explode(testVector,2);
648 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
649 }
650
651 {
652 testVector = Vector(0.5,0.5,0.5);
653 res = unitBox->explode(testVector,2);
654 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
655 res = stretchedBox1->explode(testVector,2);
656 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
657 res = stretchedBox2->explode(testVector,2);
658 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
659 res = stretchedBox3->explode(testVector,2);
660 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
661 res = stretchedBox4->explode(testVector,2);
662 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
663 res = tiltedBox1->explode(testVector,2);
664 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
665 res = tiltedBox2->explode(testVector,2);
666 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
667 res = tiltedBox3->explode(testVector,2);
668 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
669 res = tiltedBox4->explode(testVector,2);
670 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
671 }
672
673 {
674 testVector = Vector(1,1,1);
675 res = unitBox->explode(testVector,2);
676 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
677 res = stretchedBox1->explode(testVector,2);
678 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
679 res = stretchedBox2->explode(testVector,2);
680 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
681 res = stretchedBox3->explode(testVector,2);
682 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
683 res = stretchedBox4->explode(testVector,2);
684 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
685 res = tiltedBox1->explode(testVector,2);
686 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
687 res = tiltedBox2->explode(testVector,2);
688 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
689 res = tiltedBox3->explode(testVector,2);
690 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
691 res = tiltedBox4->explode(testVector,2);
692 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
693 }
694
695 {
696 testVector = Vector(2,1,1);
697 res = stretchedBox2->explode(testVector,2);
698 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
699 res = stretchedBox3->explode(testVector,2);
700 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
701 res = stretchedBox4->explode(testVector,2);
702 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
703 }
704
705 {
706 testVector = Vector(1,2,1);
707 res = stretchedBox1->explode(testVector,2);
708 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
709 res = stretchedBox2->explode(testVector,2);
710 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
711 res = stretchedBox4->explode(testVector,2);
712 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
713 res = tiltedBox2->explode(testVector,2);
714 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
715 }
716
717 {
718 testVector = Vector(1,1,2);
719 res = stretchedBox1->explode(testVector,2);
720 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
721 res = stretchedBox3->explode(testVector,2);
722 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
723 res = stretchedBox4->explode(testVector,2);
724 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
725 res = tiltedBox1->explode(testVector,2);
726 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
727 res = tiltedBox2->explode(testVector,2);
728 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
729 res = tiltedBox3->explode(testVector,2);
730 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
731 res = tiltedBox4->explode(testVector,2);
732 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
733 }
734
735 {
736 testVector = Vector(3,1,1);
737 res = stretchedBox3->explode(testVector,2);
738 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
739 }
740
741 {
742 testVector = Vector(1,3,1);
743 res = stretchedBox2->explode(testVector,2);
744 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
745 }
746
747 {
748 testVector = Vector(1,1,3);
749 res = stretchedBox1->explode(testVector,2);
750 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
751 }
752
753 {
754 testVector = Vector(2,2,2);
755 res = stretchedBox4->explode(testVector,2);
756 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
757 }
758
759 // one more set of higher level explosions
760
761 {
762 testVector = Vector(0,0,0);
763 res = unitBox->explode(testVector,3);
764 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
765 res = stretchedBox1->explode(testVector,3);
766 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
767 res = stretchedBox2->explode(testVector,3);
768 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
769 res = stretchedBox3->explode(testVector,3);
770 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
771 res = stretchedBox4->explode(testVector,3);
772 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
773 res = tiltedBox1->explode(testVector,3);
774 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
775 res = tiltedBox2->explode(testVector,3);
776 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
777 res = tiltedBox3->explode(testVector,3);
778 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
779 res = tiltedBox4->explode(testVector,3);
780 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
781 }
782
783 {
784 testVector = Vector(0.5,0.5,0.5);
785 res = unitBox->explode(testVector,3);
786 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
787 res = stretchedBox1->explode(testVector,3);
788 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
789 res = stretchedBox2->explode(testVector,3);
790 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
791 res = stretchedBox3->explode(testVector,3);
792 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
793 res = stretchedBox4->explode(testVector,3);
794 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
795 res = tiltedBox1->explode(testVector,3);
796 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
797 res = tiltedBox2->explode(testVector,3);
798 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
799 res = tiltedBox3->explode(testVector,3);
800 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
801 res = tiltedBox4->explode(testVector,3);
802 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
803 }
804
805 {
806 testVector = Vector(1,1,1);
807 res = unitBox->explode(testVector,3);
808 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
809 res = stretchedBox1->explode(testVector,3);
810 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
811 res = stretchedBox2->explode(testVector,3);
812 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
813 res = stretchedBox3->explode(testVector,3);
814 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
815 res = stretchedBox4->explode(testVector,3);
816 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
817 res = tiltedBox1->explode(testVector,3);
818 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
819 res = tiltedBox2->explode(testVector,3);
820 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
821 res = tiltedBox3->explode(testVector,3);
822 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
823 res = tiltedBox4->explode(testVector,3);
824 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
825 }
826
827 {
828 testVector = Vector(2,1,1);
829 res = stretchedBox2->explode(testVector,3);
830 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
831 res = stretchedBox3->explode(testVector,3);
832 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
833 res = stretchedBox4->explode(testVector,3);
834 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
835 }
836
837 {
838 testVector = Vector(1,2,1);
839 res = stretchedBox1->explode(testVector,3);
840 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
841 res = stretchedBox2->explode(testVector,3);
842 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
843 res = stretchedBox4->explode(testVector,3);
844 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
845 res = tiltedBox2->explode(testVector,3);
846 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
847 }
848
849 {
850 testVector = Vector(1,1,2);
851 res = stretchedBox1->explode(testVector,3);
852 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
853 res = stretchedBox3->explode(testVector,3);
854 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
855 res = stretchedBox4->explode(testVector,3);
856 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
857 res = tiltedBox1->explode(testVector,3);
858 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
859 res = tiltedBox2->explode(testVector,3);
860 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
861 res = tiltedBox3->explode(testVector,3);
862 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
863 res = tiltedBox4->explode(testVector,3);
864 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
865 }
866
867 {
868 testVector = Vector(3,1,1);
869 res = stretchedBox3->explode(testVector,3);
870 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
871 }
872
873 {
874 testVector = Vector(1,3,1);
875 res = stretchedBox2->explode(testVector,3);
876 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
877 }
878
879 {
880 testVector = Vector(1,1,3);
881 res = stretchedBox1->explode(testVector,3);
882 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
883 }
884
885 {
886 testVector = Vector(2,2,2);
887 res = stretchedBox4->explode(testVector,3);
888 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
889 }
890}
891
892void BoxUnittest::BoundaryBounceTest(){
893 Vector testVector(0,0,0);
894 VECTORSET(std::vector) res;
895
896 unitBox->setCondition(0,Box::Bounce);
897 stretchedBox1->setCondition(0,Box::Bounce);
898 stretchedBox2->setCondition(0,Box::Bounce);
899 stretchedBox3->setCondition(0,Box::Bounce);
900 stretchedBox4->setCondition(0,Box::Bounce);
901 tiltedBox1->setCondition(0,Box::Bounce);
902 tiltedBox2->setCondition(0,Box::Bounce);
903 tiltedBox3->setCondition(0,Box::Bounce);
904 tiltedBox4->setCondition(0,Box::Bounce);
905
906 {
907 testVector = Vector(0,0,0);
908 res = unitBox->explode(testVector,1);
909 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
910 res = stretchedBox1->explode(testVector,1);
911 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
912 res = stretchedBox2->explode(testVector,1);
913 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
914 res = stretchedBox3->explode(testVector,1);
915 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
916 res = stretchedBox4->explode(testVector,1);
917 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
918 res = tiltedBox1->explode(testVector,1);
919 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
920 res = tiltedBox2->explode(testVector,1);
921 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
922 res = tiltedBox3->explode(testVector,1);
923 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
924 res = tiltedBox4->explode(testVector,1);
925 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
926 }
927
928 {
929 testVector = Vector(0.5,0.5,0.5);
930 res = unitBox->explode(testVector,1);
931 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
932 res = stretchedBox1->explode(testVector,1);
933 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
934 res = stretchedBox2->explode(testVector,1);
935 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
936 res = stretchedBox3->explode(testVector,1);
937 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
938 res = stretchedBox4->explode(testVector,1);
939 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
940 res = tiltedBox1->explode(testVector,1);
941 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
942 res = tiltedBox2->explode(testVector,1);
943 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
944 res = tiltedBox3->explode(testVector,1);
945 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
946 res = tiltedBox4->explode(testVector,1);
947 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
948 }
949
950 {
951 testVector = Vector(0,0,0);
952 res = unitBox->explode(testVector,2);
953 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
954 res = stretchedBox1->explode(testVector,2);
955 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
956 res = stretchedBox2->explode(testVector,2);
957 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
958 res = stretchedBox3->explode(testVector,2);
959 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
960 res = stretchedBox4->explode(testVector,2);
961 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
962 res = tiltedBox1->explode(testVector,2);
963 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
964 res = tiltedBox2->explode(testVector,2);
965 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
966 res = tiltedBox3->explode(testVector,2);
967 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
968 res = tiltedBox4->explode(testVector,2);
969 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
970 }
971
972 {
973 testVector = Vector(0.5,0.5,0.5);
974 res = unitBox->explode(testVector,2);
975 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
976 res = stretchedBox1->explode(testVector,2);
977 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
978 res = stretchedBox2->explode(testVector,2);
979 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
980 res = stretchedBox3->explode(testVector,2);
981 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
982 res = stretchedBox4->explode(testVector,2);
983 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
984 res = tiltedBox1->explode(testVector,2);
985 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
986 res = tiltedBox2->explode(testVector,2);
987 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
988 res = tiltedBox3->explode(testVector,2);
989 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
990 res = tiltedBox4->explode(testVector,2);
991 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
992 }
993
994 unitBox->setCondition(1,Box::Bounce);
995 stretchedBox1->setCondition(1,Box::Bounce);
996 stretchedBox2->setCondition(1,Box::Bounce);
997 stretchedBox3->setCondition(1,Box::Bounce);
998 stretchedBox4->setCondition(1,Box::Bounce);
999 tiltedBox1->setCondition(1,Box::Bounce);
1000 tiltedBox2->setCondition(1,Box::Bounce);
1001 tiltedBox3->setCondition(1,Box::Bounce);
1002 tiltedBox4->setCondition(1,Box::Bounce);
1003
1004 {
1005 testVector = Vector(0,0,0);
1006 res = unitBox->explode(testVector,1);
1007 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1008 res = stretchedBox1->explode(testVector,1);
1009 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1010 res = stretchedBox2->explode(testVector,1);
1011 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1012 res = stretchedBox3->explode(testVector,1);
1013 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1014 res = stretchedBox4->explode(testVector,1);
1015 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1016 res = tiltedBox1->explode(testVector,1);
1017 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1018 res = tiltedBox2->explode(testVector,1);
1019 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1020 res = tiltedBox3->explode(testVector,1);
1021 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1022 res = tiltedBox4->explode(testVector,1);
1023 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1024 }
1025
1026 {
1027 testVector = Vector(0.5,0.5,0.5);
1028 res = unitBox->explode(testVector,1);
1029 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1030 res = stretchedBox1->explode(testVector,1);
1031 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1032 res = stretchedBox2->explode(testVector,1);
1033 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1034 res = stretchedBox3->explode(testVector,1);
1035 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1036 res = stretchedBox4->explode(testVector,1);
1037 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1038 res = tiltedBox1->explode(testVector,1);
1039 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1040 res = tiltedBox2->explode(testVector,1);
1041 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1042 res = tiltedBox3->explode(testVector,1);
1043 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1044 res = tiltedBox4->explode(testVector,1);
1045 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1046 }
1047
1048 {
1049 testVector = Vector(0,0,0);
1050 res = unitBox->explode(testVector,2);
1051 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1052 res = stretchedBox1->explode(testVector,2);
1053 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1054 res = stretchedBox2->explode(testVector,2);
1055 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1056 res = stretchedBox3->explode(testVector,2);
1057 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1058 res = stretchedBox4->explode(testVector,2);
1059 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1060 res = tiltedBox1->explode(testVector,2);
1061 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1062 res = tiltedBox2->explode(testVector,2);
1063 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1064 res = tiltedBox3->explode(testVector,2);
1065 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1066 res = tiltedBox4->explode(testVector,2);
1067 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1068 }
1069
1070 {
1071 testVector = Vector(0.5,0.5,0.5);
1072 res = unitBox->explode(testVector,2);
1073 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1074 res = stretchedBox1->explode(testVector,2);
1075 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1076 res = stretchedBox2->explode(testVector,2);
1077 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1078 res = stretchedBox3->explode(testVector,2);
1079 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1080 res = stretchedBox4->explode(testVector,2);
1081 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1082 res = tiltedBox1->explode(testVector,2);
1083 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1084 res = tiltedBox2->explode(testVector,2);
1085 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1086 res = tiltedBox3->explode(testVector,2);
1087 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1088 res = tiltedBox4->explode(testVector,2);
1089 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1090 }
1091
1092 unitBox->setCondition(2,Box::Bounce);
1093 stretchedBox1->setCondition(2,Box::Bounce);
1094 stretchedBox2->setCondition(2,Box::Bounce);
1095 stretchedBox3->setCondition(2,Box::Bounce);
1096 stretchedBox4->setCondition(2,Box::Bounce);
1097 tiltedBox1->setCondition(2,Box::Bounce);
1098 tiltedBox2->setCondition(2,Box::Bounce);
1099 tiltedBox3->setCondition(2,Box::Bounce);
1100 tiltedBox4->setCondition(2,Box::Bounce);
1101
1102 {
1103 testVector = Vector(0,0,0);
1104 res = unitBox->explode(testVector,1);
1105 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1106 res = stretchedBox1->explode(testVector,1);
1107 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1108 res = stretchedBox2->explode(testVector,1);
1109 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1110 res = stretchedBox3->explode(testVector,1);
1111 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1112 res = stretchedBox4->explode(testVector,1);
1113 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1114 res = tiltedBox1->explode(testVector,1);
1115 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1116 res = tiltedBox2->explode(testVector,1);
1117 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1118 res = tiltedBox3->explode(testVector,1);
1119 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1120 res = tiltedBox4->explode(testVector,1);
1121 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1122 }
1123
1124 {
1125 testVector = Vector(0.5,0.5,0.5);
1126 res = unitBox->explode(testVector,1);
1127 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1128 res = stretchedBox1->explode(testVector,1);
1129 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1130 res = stretchedBox2->explode(testVector,1);
1131 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1132 res = stretchedBox3->explode(testVector,1);
1133 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1134 res = stretchedBox4->explode(testVector,1);
1135 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1136 res = tiltedBox1->explode(testVector,1);
1137 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1138 res = tiltedBox2->explode(testVector,1);
1139 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1140 res = tiltedBox3->explode(testVector,1);
1141 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1142 res = tiltedBox4->explode(testVector,1);
1143 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1144 }
1145
1146 {
1147 testVector = Vector(0,0,0);
1148 res = unitBox->explode(testVector,2);
1149 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1150 res = stretchedBox1->explode(testVector,2);
1151 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1152 res = stretchedBox2->explode(testVector,2);
1153 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1154 res = stretchedBox3->explode(testVector,2);
1155 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1156 res = stretchedBox4->explode(testVector,2);
1157 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1158 res = tiltedBox1->explode(testVector,2);
1159 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1160 res = tiltedBox2->explode(testVector,2);
1161 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1162 res = tiltedBox3->explode(testVector,2);
1163 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1164 res = tiltedBox4->explode(testVector,2);
1165 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1166 }
1167
1168 {
1169 testVector = Vector(0.5,0.5,0.5);
1170 res = unitBox->explode(testVector,2);
1171 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1172 res = stretchedBox1->explode(testVector,2);
1173 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1174 res = stretchedBox2->explode(testVector,2);
1175 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1176 res = stretchedBox3->explode(testVector,2);
1177 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1178 res = stretchedBox4->explode(testVector,2);
1179 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1180 res = tiltedBox1->explode(testVector,2);
1181 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1182 res = tiltedBox2->explode(testVector,2);
1183 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1184 res = tiltedBox3->explode(testVector,2);
1185 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1186 res = tiltedBox4->explode(testVector,2);
1187 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1188 }
1189}
1190
1191void BoxUnittest::BoundaryIgnoreTest(){
1192 Vector testVector(0,0,0);
1193 VECTORSET(std::vector) res;
1194
1195 unitBox->setCondition(0,Box::Ignore);
1196 stretchedBox1->setCondition(0,Box::Ignore);
1197 stretchedBox2->setCondition(0,Box::Ignore);
1198 stretchedBox3->setCondition(0,Box::Ignore);
1199 stretchedBox4->setCondition(0,Box::Ignore);
1200 tiltedBox1->setCondition(0,Box::Ignore);
1201 tiltedBox2->setCondition(0,Box::Ignore);
1202 tiltedBox3->setCondition(0,Box::Ignore);
1203 tiltedBox4->setCondition(0,Box::Ignore);
1204
1205 {
1206 testVector = Vector(0,0,0);
1207 res = unitBox->explode(testVector,1);
1208 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1209 res = stretchedBox1->explode(testVector,1);
1210 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1211 res = stretchedBox2->explode(testVector,1);
1212 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1213 res = stretchedBox3->explode(testVector,1);
1214 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1215 res = stretchedBox4->explode(testVector,1);
1216 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1217 res = tiltedBox1->explode(testVector,1);
1218 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1219 res = tiltedBox2->explode(testVector,1);
1220 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1221 res = tiltedBox3->explode(testVector,1);
1222 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1223 res = tiltedBox4->explode(testVector,1);
1224 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1225 }
1226
1227 {
1228 testVector = Vector(0.5,0.5,0.5);
1229 res = unitBox->explode(testVector,1);
1230 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1231 res = stretchedBox1->explode(testVector,1);
1232 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1233 res = stretchedBox2->explode(testVector,1);
1234 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1235 res = stretchedBox3->explode(testVector,1);
1236 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1237 res = stretchedBox4->explode(testVector,1);
1238 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1239 res = tiltedBox1->explode(testVector,1);
1240 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1241 res = tiltedBox2->explode(testVector,1);
1242 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1243 res = tiltedBox3->explode(testVector,1);
1244 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1245 res = tiltedBox4->explode(testVector,1);
1246 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1247 }
1248
1249 {
1250 testVector = Vector(0,0,0);
1251 res = unitBox->explode(testVector,2);
1252 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1253 res = stretchedBox1->explode(testVector,2);
1254 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1255 res = stretchedBox2->explode(testVector,2);
1256 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1257 res = stretchedBox3->explode(testVector,2);
1258 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1259 res = stretchedBox4->explode(testVector,2);
1260 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1261 res = tiltedBox1->explode(testVector,2);
1262 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1263 res = tiltedBox2->explode(testVector,2);
1264 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1265 res = tiltedBox3->explode(testVector,2);
1266 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1267 res = tiltedBox4->explode(testVector,2);
1268 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1269 }
1270
1271 {
1272 testVector = Vector(0.5,0.5,0.5);
1273 res = unitBox->explode(testVector,2);
1274 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1275 res = stretchedBox1->explode(testVector,2);
1276 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1277 res = stretchedBox2->explode(testVector,2);
1278 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1279 res = stretchedBox3->explode(testVector,2);
1280 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1281 res = stretchedBox4->explode(testVector,2);
1282 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1283 res = tiltedBox1->explode(testVector,2);
1284 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1285 res = tiltedBox2->explode(testVector,2);
1286 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1287 res = tiltedBox3->explode(testVector,2);
1288 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1289 res = tiltedBox4->explode(testVector,2);
1290 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1291 }
1292
1293 unitBox->setCondition(1,Box::Ignore);
1294 stretchedBox1->setCondition(1,Box::Ignore);
1295 stretchedBox2->setCondition(1,Box::Ignore);
1296 stretchedBox3->setCondition(1,Box::Ignore);
1297 stretchedBox4->setCondition(1,Box::Ignore);
1298 tiltedBox1->setCondition(1,Box::Ignore);
1299 tiltedBox2->setCondition(1,Box::Ignore);
1300 tiltedBox3->setCondition(1,Box::Ignore);
1301 tiltedBox4->setCondition(1,Box::Ignore);
1302
1303 {
1304 testVector = Vector(0,0,0);
1305 res = unitBox->explode(testVector,1);
1306 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1307 res = stretchedBox1->explode(testVector,1);
1308 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1309 res = stretchedBox2->explode(testVector,1);
1310 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1311 res = stretchedBox3->explode(testVector,1);
1312 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1313 res = stretchedBox4->explode(testVector,1);
1314 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1315 res = tiltedBox1->explode(testVector,1);
1316 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1317 res = tiltedBox2->explode(testVector,1);
1318 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1319 res = tiltedBox3->explode(testVector,1);
1320 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1321 res = tiltedBox4->explode(testVector,1);
1322 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1323 }
1324
1325 {
1326 testVector = Vector(0.5,0.5,0.5);
1327 res = unitBox->explode(testVector,1);
1328 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1329 res = stretchedBox1->explode(testVector,1);
1330 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1331 res = stretchedBox2->explode(testVector,1);
1332 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1333 res = stretchedBox3->explode(testVector,1);
1334 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1335 res = stretchedBox4->explode(testVector,1);
1336 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1337 res = tiltedBox1->explode(testVector,1);
1338 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1339 res = tiltedBox2->explode(testVector,1);
1340 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1341 res = tiltedBox3->explode(testVector,1);
1342 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1343 res = tiltedBox4->explode(testVector,1);
1344 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1345 }
1346
1347 {
1348 testVector = Vector(0,0,0);
1349 res = unitBox->explode(testVector,2);
1350 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1351 res = stretchedBox1->explode(testVector,2);
1352 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1353 res = stretchedBox2->explode(testVector,2);
1354 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1355 res = stretchedBox3->explode(testVector,2);
1356 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1357 res = stretchedBox4->explode(testVector,2);
1358 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1359 res = tiltedBox1->explode(testVector,2);
1360 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1361 res = tiltedBox2->explode(testVector,2);
1362 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1363 res = tiltedBox3->explode(testVector,2);
1364 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1365 res = tiltedBox4->explode(testVector,2);
1366 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1367 }
1368
1369 {
1370 testVector = Vector(0.5,0.5,0.5);
1371 res = unitBox->explode(testVector,2);
1372 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1373 res = stretchedBox1->explode(testVector,2);
1374 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1375 res = stretchedBox2->explode(testVector,2);
1376 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1377 res = stretchedBox3->explode(testVector,2);
1378 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1379 res = stretchedBox4->explode(testVector,2);
1380 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1381 res = tiltedBox1->explode(testVector,2);
1382 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1383 res = tiltedBox2->explode(testVector,2);
1384 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1385 res = tiltedBox3->explode(testVector,2);
1386 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1387 res = tiltedBox4->explode(testVector,2);
1388 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1389 }
1390
1391 unitBox->setCondition(2,Box::Ignore);
1392 stretchedBox1->setCondition(2,Box::Ignore);
1393 stretchedBox2->setCondition(2,Box::Ignore);
1394 stretchedBox3->setCondition(2,Box::Ignore);
1395 stretchedBox4->setCondition(2,Box::Ignore);
1396 tiltedBox1->setCondition(2,Box::Ignore);
1397 tiltedBox2->setCondition(2,Box::Ignore);
1398 tiltedBox3->setCondition(2,Box::Ignore);
1399 tiltedBox4->setCondition(2,Box::Ignore);
1400
1401 {
1402 testVector = Vector(0,0,0);
1403 res = unitBox->explode(testVector,1);
1404 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1405 res = stretchedBox1->explode(testVector,1);
1406 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1407 res = stretchedBox2->explode(testVector,1);
1408 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1409 res = stretchedBox3->explode(testVector,1);
1410 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1411 res = stretchedBox4->explode(testVector,1);
1412 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1413 res = tiltedBox1->explode(testVector,1);
1414 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1415 res = tiltedBox2->explode(testVector,1);
1416 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1417 res = tiltedBox3->explode(testVector,1);
1418 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1419 res = tiltedBox4->explode(testVector,1);
1420 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1421 }
1422
1423 {
1424 testVector = Vector(0.5,0.5,0.5);
1425 res = unitBox->explode(testVector,1);
1426 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1427 res = stretchedBox1->explode(testVector,1);
1428 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1429 res = stretchedBox2->explode(testVector,1);
1430 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1431 res = stretchedBox3->explode(testVector,1);
1432 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1433 res = stretchedBox4->explode(testVector,1);
1434 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1435 res = tiltedBox1->explode(testVector,1);
1436 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1437 res = tiltedBox2->explode(testVector,1);
1438 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1439 res = tiltedBox3->explode(testVector,1);
1440 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1441 res = tiltedBox4->explode(testVector,1);
1442 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1443 }
1444
1445 {
1446 testVector = Vector(0,0,0);
1447 res = unitBox->explode(testVector,2);
1448 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1449 res = stretchedBox1->explode(testVector,2);
1450 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1451 res = stretchedBox2->explode(testVector,2);
1452 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1453 res = stretchedBox3->explode(testVector,2);
1454 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1455 res = stretchedBox4->explode(testVector,2);
1456 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1457 res = tiltedBox1->explode(testVector,2);
1458 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1459 res = tiltedBox2->explode(testVector,2);
1460 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1461 res = tiltedBox3->explode(testVector,2);
1462 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1463 res = tiltedBox4->explode(testVector,2);
1464 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1465 }
1466
1467 {
1468 testVector = Vector(0.5,0.5,0.5);
1469 res = unitBox->explode(testVector,2);
1470 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1471 res = stretchedBox1->explode(testVector,2);
1472 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1473 res = stretchedBox2->explode(testVector,2);
1474 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1475 res = stretchedBox3->explode(testVector,2);
1476 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1477 res = stretchedBox4->explode(testVector,2);
1478 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1479 res = tiltedBox1->explode(testVector,2);
1480 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1481 res = tiltedBox2->explode(testVector,2);
1482 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1483 res = tiltedBox3->explode(testVector,2);
1484 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1485 res = tiltedBox4->explode(testVector,2);
1486 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1487 }
1488}
1489
1490void BoxUnittest::BoundaryMixedTest(){
1491 Vector testVector(0,0,0);
1492 VECTORSET(std::vector) res;
1493
1494 unitBox->setCondition(0,Box::Bounce);
1495 unitBox->setCondition(1,Box::Ignore);
1496 unitBox->setCondition(2,Box::Wrap);
1497
1498 stretchedBox1->setCondition(0,Box::Bounce);
1499 stretchedBox1->setCondition(1,Box::Ignore);
1500 stretchedBox1->setCondition(2,Box::Wrap);
1501
1502 stretchedBox2->setCondition(0,Box::Bounce);
1503 stretchedBox2->setCondition(1,Box::Ignore);
1504 stretchedBox2->setCondition(2,Box::Wrap);
1505
1506 stretchedBox3->setCondition(0,Box::Bounce);
1507 stretchedBox3->setCondition(1,Box::Ignore);
1508 stretchedBox3->setCondition(2,Box::Wrap);
1509
1510 stretchedBox4->setCondition(0,Box::Bounce);
1511 stretchedBox4->setCondition(1,Box::Ignore);
1512 stretchedBox4->setCondition(2,Box::Wrap);
1513
1514 tiltedBox1->setCondition(0,Box::Bounce);
1515 tiltedBox1->setCondition(1,Box::Ignore);
1516 tiltedBox1->setCondition(2,Box::Wrap);
1517
1518 tiltedBox2->setCondition(0,Box::Bounce);
1519 tiltedBox2->setCondition(1,Box::Ignore);
1520 tiltedBox2->setCondition(2,Box::Wrap);
1521
1522 tiltedBox3->setCondition(0,Box::Bounce);
1523 tiltedBox3->setCondition(1,Box::Ignore);
1524 tiltedBox3->setCondition(2,Box::Wrap);
1525
1526 tiltedBox4->setCondition(0,Box::Bounce);
1527 tiltedBox4->setCondition(1,Box::Ignore);
1528 tiltedBox4->setCondition(2,Box::Wrap);
1529
1530 {
1531 testVector = Vector(0,0,0);
1532 res = unitBox->explode(testVector,1);
1533 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1534 res = stretchedBox1->explode(testVector,1);
1535 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1536 res = stretchedBox2->explode(testVector,1);
1537 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1538 res = stretchedBox3->explode(testVector,1);
1539 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1540 res = stretchedBox4->explode(testVector,1);
1541 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1542 res = tiltedBox1->explode(testVector,1);
1543 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1544 res = tiltedBox2->explode(testVector,1);
1545 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1546 res = tiltedBox3->explode(testVector,1);
1547 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1548 res = tiltedBox4->explode(testVector,1);
1549 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1550 }
1551
1552 {
1553 testVector = Vector(0.5,0.5,0.5);
1554 res = unitBox->explode(testVector,1);
1555 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1556 res = stretchedBox1->explode(testVector,1);
1557 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1558 res = stretchedBox2->explode(testVector,1);
1559 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1560 res = stretchedBox3->explode(testVector,1);
1561 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1562 res = stretchedBox4->explode(testVector,1);
1563 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1564 res = tiltedBox1->explode(testVector,1);
1565 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1566 res = tiltedBox2->explode(testVector,1);
1567 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1568 res = tiltedBox3->explode(testVector,1);
1569 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1570 res = tiltedBox4->explode(testVector,1);
1571 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1572 }
1573
1574 {
1575 testVector = Vector(0,0,0);
1576 res = unitBox->explode(testVector,2);
1577 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1578 res = stretchedBox1->explode(testVector,2);
1579 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1580 res = stretchedBox2->explode(testVector,2);
1581 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1582 res = stretchedBox3->explode(testVector,2);
1583 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1584 res = stretchedBox4->explode(testVector,2);
1585 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1586 res = tiltedBox1->explode(testVector,2);
1587 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1588 res = tiltedBox2->explode(testVector,2);
1589 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1590 res = tiltedBox3->explode(testVector,2);
1591 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1592 res = tiltedBox4->explode(testVector,2);
1593 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1594 }
1595
1596 {
1597 testVector = Vector(0.5,0.5,0.5);
1598 res = unitBox->explode(testVector,2);
1599 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1600 res = stretchedBox1->explode(testVector,2);
1601 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1602 res = stretchedBox2->explode(testVector,2);
1603 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1604 res = stretchedBox3->explode(testVector,2);
1605 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1606 res = stretchedBox4->explode(testVector,2);
1607 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1608 res = tiltedBox1->explode(testVector,2);
1609 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1610 res = tiltedBox2->explode(testVector,2);
1611 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1612 res = tiltedBox3->explode(testVector,2);
1613 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1614 res = tiltedBox4->explode(testVector,2);
1615 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1616 }
1617
1618}
Note: See TracBrowser for help on using the repository browser.