source: src/unittests/BoxUnittest.cpp@ 13e3c3

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 13e3c3 was bf3817, checked in by Frederik Heber <heber@…>, 14 years ago

Added ifdef HAVE_CONFIG and config.h include to each and every cpp file.

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