source: src/unittests/BoxUnittest.cpp@ 88b400

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 88b400 was 57f243, checked in by Frederik Heber <heber@…>, 14 years ago

Created libMolecuilderLinearAlgebra.

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