source: src/unittests/BoxUnittest.cpp@ 77bc4f

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 77bc4f was 77bc4f, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Added Unittest for Box class

  • Property mode set to 100644
File size: 57.3 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 "vector.hpp"
19#include "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::isInsideTest(){
117 Vector testVector(0,0,0);
118 CPPUNIT_ASSERT( unitBox->isInside(testVector));
119 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
120 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
121 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
122 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
123 CPPUNIT_ASSERT( tiltedBox1->isInside(testVector));
124 CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
125 CPPUNIT_ASSERT( tiltedBox3->isInside(testVector));
126 CPPUNIT_ASSERT( tiltedBox4->isInside(testVector));
127
128
129 testVector = Vector(0.5,0.5,0.5);
130 CPPUNIT_ASSERT( unitBox->isInside(testVector));
131 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
132 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
133 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
134 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
135 CPPUNIT_ASSERT( tiltedBox1->isInside(testVector));
136 CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
137 CPPUNIT_ASSERT( tiltedBox3->isInside(testVector));
138 CPPUNIT_ASSERT( tiltedBox4->isInside(testVector));
139
140 testVector = Vector(1,1,1);
141 CPPUNIT_ASSERT( unitBox->isInside(testVector));
142 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
143 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
144 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
145 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
146 CPPUNIT_ASSERT( tiltedBox1->isInside(testVector));
147 CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
148 CPPUNIT_ASSERT( tiltedBox3->isInside(testVector));
149 CPPUNIT_ASSERT( tiltedBox4->isInside(testVector));
150
151 testVector = Vector(2,1,1);
152 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
153 CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
154 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
155 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
156 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
157 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
158 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
159 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
160 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
161
162 testVector = Vector(1,2,1);
163 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
164 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
165 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
166 CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
167 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
168 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
169 CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
170 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
171 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
172
173 testVector = Vector(1,1,2);
174 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
175 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
176 CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
177 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
178 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
179 CPPUNIT_ASSERT( tiltedBox1->isInside(testVector));
180 CPPUNIT_ASSERT( tiltedBox2->isInside(testVector));
181 CPPUNIT_ASSERT( tiltedBox3->isInside(testVector));
182 CPPUNIT_ASSERT( tiltedBox4->isInside(testVector));
183
184 testVector = Vector(3,1,1);
185 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
186 CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
187 CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
188 CPPUNIT_ASSERT( stretchedBox3->isInside(testVector));
189 CPPUNIT_ASSERT(!stretchedBox4->isInside(testVector));
190 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
191 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
192 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
193 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
194
195 testVector = Vector(1,3,1);
196 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
197 CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
198 CPPUNIT_ASSERT( stretchedBox2->isInside(testVector));
199 CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
200 CPPUNIT_ASSERT(!stretchedBox4->isInside(testVector));
201 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
202 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
203 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
204 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
205
206 testVector = Vector(1,1,3);
207 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
208 CPPUNIT_ASSERT( stretchedBox1->isInside(testVector));
209 CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
210 CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
211 CPPUNIT_ASSERT(!stretchedBox4->isInside(testVector));
212 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
213 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
214 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
215 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
216
217 testVector = Vector(2,2,2);
218 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
219 CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
220 CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
221 CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
222 CPPUNIT_ASSERT( stretchedBox4->isInside(testVector));
223 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
224 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
225 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
226 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
227
228 testVector = Vector(3,3,3);
229 CPPUNIT_ASSERT(!unitBox->isInside(testVector));
230 CPPUNIT_ASSERT(!stretchedBox1->isInside(testVector));
231 CPPUNIT_ASSERT(!stretchedBox2->isInside(testVector));
232 CPPUNIT_ASSERT(!stretchedBox3->isInside(testVector));
233 CPPUNIT_ASSERT(!stretchedBox4->isInside(testVector));
234 CPPUNIT_ASSERT(!tiltedBox1->isInside(testVector));
235 CPPUNIT_ASSERT(!tiltedBox2->isInside(testVector));
236 CPPUNIT_ASSERT(!tiltedBox3->isInside(testVector));
237 CPPUNIT_ASSERT(!tiltedBox4->isInside(testVector));
238}
239
240bool testWrapExplode(VECTORSET(std::list) &set,Vector &point, Box* box){
241 bool res = true;
242 Vector wrappedPoint = box->WrapPeriodically(point);
243 for(std::list<Vector>::iterator iter = set.begin(); iter!=set.end();++iter){
244 Vector wrapped = box->WrapPeriodically(*iter);
245 bool equals = (wrapped == wrappedPoint);
246 res = res && equals;
247 if(!equals){
248 cout << "Wrapped vector " << wrapped << " produced from vector " << (*iter) << " does not match target " << wrappedPoint << endl;
249 }
250 }
251 return res;
252}
253
254void BoxUnittest::WrapExplodeTest(){
255 Vector testVector(0,0,0);
256 VECTORSET(std::list) res;
257
258 // we only can explode those vectors that are actually inside the box
259 {
260 testVector = Vector(0,0,0);
261 res = unitBox->explode(testVector,1);
262 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
263 res = stretchedBox1->explode(testVector,1);
264 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
265 res = stretchedBox2->explode(testVector,1);
266 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
267 res = stretchedBox3->explode(testVector,1);
268 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
269 res = stretchedBox4->explode(testVector,1);
270 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
271 res = tiltedBox1->explode(testVector,1);
272 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
273 res = tiltedBox2->explode(testVector,1);
274 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
275 res = tiltedBox3->explode(testVector,1);
276 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
277 res = tiltedBox4->explode(testVector,1);
278 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
279 }
280
281 {
282 testVector = Vector(0.5,0.5,0.5);
283 res = unitBox->explode(testVector,1);
284 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
285 res = stretchedBox1->explode(testVector,1);
286 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
287 res = stretchedBox2->explode(testVector,1);
288 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
289 res = stretchedBox3->explode(testVector,1);
290 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
291 res = stretchedBox4->explode(testVector,1);
292 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
293 res = tiltedBox1->explode(testVector,1);
294 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
295 res = tiltedBox2->explode(testVector,1);
296 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
297 res = tiltedBox3->explode(testVector,1);
298 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
299 res = tiltedBox4->explode(testVector,1);
300 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
301 }
302
303 {
304 testVector = Vector(1,1,1);
305 res = unitBox->explode(testVector,1);
306 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
307 res = stretchedBox1->explode(testVector,1);
308 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
309 res = stretchedBox2->explode(testVector,1);
310 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
311 res = stretchedBox3->explode(testVector,1);
312 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
313 res = stretchedBox4->explode(testVector,1);
314 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
315 res = tiltedBox1->explode(testVector,1);
316 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
317 res = tiltedBox2->explode(testVector,1);
318 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
319 res = tiltedBox3->explode(testVector,1);
320 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
321 res = tiltedBox4->explode(testVector,1);
322 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
323 }
324
325 {
326 testVector = Vector(2,1,1);
327 res = stretchedBox2->explode(testVector,1);
328 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
329 res = stretchedBox3->explode(testVector,1);
330 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
331 res = stretchedBox4->explode(testVector,1);
332 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
333 }
334
335 {
336 testVector = Vector(1,2,1);
337 res = stretchedBox1->explode(testVector,1);
338 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
339 res = stretchedBox2->explode(testVector,1);
340 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
341 res = stretchedBox4->explode(testVector,1);
342 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
343 res = tiltedBox2->explode(testVector,1);
344 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
345 }
346
347 {
348 testVector = Vector(1,1,2);
349 res = stretchedBox1->explode(testVector,1);
350 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
351 res = stretchedBox3->explode(testVector,1);
352 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
353 res = stretchedBox4->explode(testVector,1);
354 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
355 res = tiltedBox1->explode(testVector,1);
356 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
357 res = tiltedBox2->explode(testVector,1);
358 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
359 res = tiltedBox3->explode(testVector,1);
360 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
361 res = tiltedBox4->explode(testVector,1);
362 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
363 }
364
365 {
366 testVector = Vector(3,1,1);
367 res = stretchedBox3->explode(testVector,1);
368 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
369 }
370
371 {
372 testVector = Vector(1,3,1);
373 res = stretchedBox2->explode(testVector,1);
374 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
375 }
376
377 {
378 testVector = Vector(1,1,3);
379 res = stretchedBox1->explode(testVector,1);
380 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
381 }
382
383 {
384 testVector = Vector(2,2,2);
385 res = stretchedBox4->explode(testVector,1);
386 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
387 }
388
389 // Higher level explosions
390
391 {
392 testVector = Vector(0,0,0);
393 res = unitBox->explode(testVector,2);
394 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
395 res = stretchedBox1->explode(testVector,2);
396 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
397 res = stretchedBox2->explode(testVector,2);
398 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
399 res = stretchedBox3->explode(testVector,2);
400 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
401 res = stretchedBox4->explode(testVector,2);
402 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
403 res = tiltedBox1->explode(testVector,2);
404 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
405 res = tiltedBox2->explode(testVector,2);
406 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
407 res = tiltedBox3->explode(testVector,2);
408 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
409 res = tiltedBox4->explode(testVector,2);
410 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
411 }
412
413 {
414 testVector = Vector(0.5,0.5,0.5);
415 res = unitBox->explode(testVector,2);
416 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
417 res = stretchedBox1->explode(testVector,2);
418 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
419 res = stretchedBox2->explode(testVector,2);
420 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
421 res = stretchedBox3->explode(testVector,2);
422 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
423 res = stretchedBox4->explode(testVector,2);
424 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
425 res = tiltedBox1->explode(testVector,2);
426 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
427 res = tiltedBox2->explode(testVector,2);
428 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
429 res = tiltedBox3->explode(testVector,2);
430 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
431 res = tiltedBox4->explode(testVector,2);
432 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
433 }
434
435 {
436 testVector = Vector(1,1,1);
437 res = unitBox->explode(testVector,2);
438 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
439 res = stretchedBox1->explode(testVector,2);
440 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
441 res = stretchedBox2->explode(testVector,2);
442 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
443 res = stretchedBox3->explode(testVector,2);
444 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
445 res = stretchedBox4->explode(testVector,2);
446 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
447 res = tiltedBox1->explode(testVector,2);
448 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
449 res = tiltedBox2->explode(testVector,2);
450 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
451 res = tiltedBox3->explode(testVector,2);
452 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
453 res = tiltedBox4->explode(testVector,2);
454 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
455 }
456
457 {
458 testVector = Vector(2,1,1);
459 res = stretchedBox2->explode(testVector,2);
460 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
461 res = stretchedBox3->explode(testVector,2);
462 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
463 res = stretchedBox4->explode(testVector,2);
464 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
465 }
466
467 {
468 testVector = Vector(1,2,1);
469 res = stretchedBox1->explode(testVector,2);
470 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
471 res = stretchedBox2->explode(testVector,2);
472 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
473 res = stretchedBox4->explode(testVector,2);
474 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
475 res = tiltedBox2->explode(testVector,2);
476 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
477 }
478
479 {
480 testVector = Vector(1,1,2);
481 res = stretchedBox1->explode(testVector,2);
482 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
483 res = stretchedBox3->explode(testVector,2);
484 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
485 res = stretchedBox4->explode(testVector,2);
486 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
487 res = tiltedBox1->explode(testVector,2);
488 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
489 res = tiltedBox2->explode(testVector,2);
490 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
491 res = tiltedBox3->explode(testVector,2);
492 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
493 res = tiltedBox4->explode(testVector,2);
494 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
495 }
496
497 {
498 testVector = Vector(3,1,1);
499 res = stretchedBox3->explode(testVector,2);
500 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
501 }
502
503 {
504 testVector = Vector(1,3,1);
505 res = stretchedBox2->explode(testVector,2);
506 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
507 }
508
509 {
510 testVector = Vector(1,1,3);
511 res = stretchedBox1->explode(testVector,2);
512 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
513 }
514
515 {
516 testVector = Vector(2,2,2);
517 res = stretchedBox4->explode(testVector,2);
518 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
519 }
520
521 // one more set of higher level explosions
522
523 {
524 testVector = Vector(0,0,0);
525 res = unitBox->explode(testVector,3);
526 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
527 res = stretchedBox1->explode(testVector,3);
528 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
529 res = stretchedBox2->explode(testVector,3);
530 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
531 res = stretchedBox3->explode(testVector,3);
532 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
533 res = stretchedBox4->explode(testVector,3);
534 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
535 res = tiltedBox1->explode(testVector,3);
536 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
537 res = tiltedBox2->explode(testVector,3);
538 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
539 res = tiltedBox3->explode(testVector,3);
540 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
541 res = tiltedBox4->explode(testVector,3);
542 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
543 }
544
545 {
546 testVector = Vector(0.5,0.5,0.5);
547 res = unitBox->explode(testVector,3);
548 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
549 res = stretchedBox1->explode(testVector,3);
550 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
551 res = stretchedBox2->explode(testVector,3);
552 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
553 res = stretchedBox3->explode(testVector,3);
554 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
555 res = stretchedBox4->explode(testVector,3);
556 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
557 res = tiltedBox1->explode(testVector,3);
558 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
559 res = tiltedBox2->explode(testVector,3);
560 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
561 res = tiltedBox3->explode(testVector,3);
562 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
563 res = tiltedBox4->explode(testVector,3);
564 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
565 }
566
567 {
568 testVector = Vector(1,1,1);
569 res = unitBox->explode(testVector,3);
570 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
571 res = stretchedBox1->explode(testVector,3);
572 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
573 res = stretchedBox2->explode(testVector,3);
574 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
575 res = stretchedBox3->explode(testVector,3);
576 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
577 res = stretchedBox4->explode(testVector,3);
578 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
579 res = tiltedBox1->explode(testVector,3);
580 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
581 res = tiltedBox2->explode(testVector,3);
582 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
583 res = tiltedBox3->explode(testVector,3);
584 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
585 res = tiltedBox4->explode(testVector,3);
586 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
587 }
588
589 {
590 testVector = Vector(2,1,1);
591 res = stretchedBox2->explode(testVector,3);
592 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
593 res = stretchedBox3->explode(testVector,3);
594 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
595 res = stretchedBox4->explode(testVector,3);
596 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
597 }
598
599 {
600 testVector = Vector(1,2,1);
601 res = stretchedBox1->explode(testVector,3);
602 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
603 res = stretchedBox2->explode(testVector,3);
604 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
605 res = stretchedBox4->explode(testVector,3);
606 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
607 res = tiltedBox2->explode(testVector,3);
608 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
609 }
610
611 {
612 testVector = Vector(1,1,2);
613 res = stretchedBox1->explode(testVector,3);
614 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
615 res = stretchedBox3->explode(testVector,3);
616 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
617 res = stretchedBox4->explode(testVector,3);
618 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
619 res = tiltedBox1->explode(testVector,3);
620 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
621 res = tiltedBox2->explode(testVector,3);
622 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
623 res = tiltedBox3->explode(testVector,3);
624 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
625 res = tiltedBox4->explode(testVector,3);
626 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
627 }
628
629 {
630 testVector = Vector(3,1,1);
631 res = stretchedBox3->explode(testVector,3);
632 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
633 }
634
635 {
636 testVector = Vector(1,3,1);
637 res = stretchedBox2->explode(testVector,3);
638 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
639 }
640
641 {
642 testVector = Vector(1,1,3);
643 res = stretchedBox1->explode(testVector,3);
644 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
645 }
646
647 {
648 testVector = Vector(2,2,2);
649 res = stretchedBox4->explode(testVector,3);
650 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
651 }
652}
653
654void BoxUnittest::BoundaryBounceTest(){
655 Vector testVector(0,0,0);
656 VECTORSET(std::list) res;
657
658 unitBox->setCondition(0,Box::Bounce);
659 stretchedBox1->setCondition(0,Box::Bounce);
660 stretchedBox2->setCondition(0,Box::Bounce);
661 stretchedBox3->setCondition(0,Box::Bounce);
662 stretchedBox4->setCondition(0,Box::Bounce);
663 tiltedBox1->setCondition(0,Box::Bounce);
664 tiltedBox2->setCondition(0,Box::Bounce);
665 tiltedBox3->setCondition(0,Box::Bounce);
666 tiltedBox4->setCondition(0,Box::Bounce);
667
668 {
669 testVector = Vector(0,0,0);
670 res = unitBox->explode(testVector,1);
671 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
672 res = stretchedBox1->explode(testVector,1);
673 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
674 res = stretchedBox2->explode(testVector,1);
675 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
676 res = stretchedBox3->explode(testVector,1);
677 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
678 res = stretchedBox4->explode(testVector,1);
679 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
680 res = tiltedBox1->explode(testVector,1);
681 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
682 res = tiltedBox2->explode(testVector,1);
683 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
684 res = tiltedBox3->explode(testVector,1);
685 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
686 res = tiltedBox4->explode(testVector,1);
687 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
688 }
689
690 {
691 testVector = Vector(0.5,0.5,0.5);
692 res = unitBox->explode(testVector,1);
693 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
694 res = stretchedBox1->explode(testVector,1);
695 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
696 res = stretchedBox2->explode(testVector,1);
697 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
698 res = stretchedBox3->explode(testVector,1);
699 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
700 res = stretchedBox4->explode(testVector,1);
701 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
702 res = tiltedBox1->explode(testVector,1);
703 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
704 res = tiltedBox2->explode(testVector,1);
705 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
706 res = tiltedBox3->explode(testVector,1);
707 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
708 res = tiltedBox4->explode(testVector,1);
709 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
710 }
711
712 {
713 testVector = Vector(0,0,0);
714 res = unitBox->explode(testVector,2);
715 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
716 res = stretchedBox1->explode(testVector,2);
717 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
718 res = stretchedBox2->explode(testVector,2);
719 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
720 res = stretchedBox3->explode(testVector,2);
721 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
722 res = stretchedBox4->explode(testVector,2);
723 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
724 res = tiltedBox1->explode(testVector,2);
725 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
726 res = tiltedBox2->explode(testVector,2);
727 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
728 res = tiltedBox3->explode(testVector,2);
729 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
730 res = tiltedBox4->explode(testVector,2);
731 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
732 }
733
734 {
735 testVector = Vector(0.5,0.5,0.5);
736 res = unitBox->explode(testVector,2);
737 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
738 res = stretchedBox1->explode(testVector,2);
739 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
740 res = stretchedBox2->explode(testVector,2);
741 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
742 res = stretchedBox3->explode(testVector,2);
743 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
744 res = stretchedBox4->explode(testVector,2);
745 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
746 res = tiltedBox1->explode(testVector,2);
747 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
748 res = tiltedBox2->explode(testVector,2);
749 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
750 res = tiltedBox3->explode(testVector,2);
751 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
752 res = tiltedBox4->explode(testVector,2);
753 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
754 }
755
756 unitBox->setCondition(1,Box::Bounce);
757 stretchedBox1->setCondition(1,Box::Bounce);
758 stretchedBox2->setCondition(1,Box::Bounce);
759 stretchedBox3->setCondition(1,Box::Bounce);
760 stretchedBox4->setCondition(1,Box::Bounce);
761 tiltedBox1->setCondition(1,Box::Bounce);
762 tiltedBox2->setCondition(1,Box::Bounce);
763 tiltedBox3->setCondition(1,Box::Bounce);
764 tiltedBox4->setCondition(1,Box::Bounce);
765
766 {
767 testVector = Vector(0,0,0);
768 res = unitBox->explode(testVector,1);
769 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
770 res = stretchedBox1->explode(testVector,1);
771 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
772 res = stretchedBox2->explode(testVector,1);
773 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
774 res = stretchedBox3->explode(testVector,1);
775 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
776 res = stretchedBox4->explode(testVector,1);
777 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
778 res = tiltedBox1->explode(testVector,1);
779 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
780 res = tiltedBox2->explode(testVector,1);
781 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
782 res = tiltedBox3->explode(testVector,1);
783 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
784 res = tiltedBox4->explode(testVector,1);
785 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
786 }
787
788 {
789 testVector = Vector(0.5,0.5,0.5);
790 res = unitBox->explode(testVector,1);
791 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
792 res = stretchedBox1->explode(testVector,1);
793 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
794 res = stretchedBox2->explode(testVector,1);
795 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
796 res = stretchedBox3->explode(testVector,1);
797 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
798 res = stretchedBox4->explode(testVector,1);
799 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
800 res = tiltedBox1->explode(testVector,1);
801 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
802 res = tiltedBox2->explode(testVector,1);
803 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
804 res = tiltedBox3->explode(testVector,1);
805 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
806 res = tiltedBox4->explode(testVector,1);
807 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
808 }
809
810 {
811 testVector = Vector(0,0,0);
812 res = unitBox->explode(testVector,2);
813 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
814 res = stretchedBox1->explode(testVector,2);
815 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
816 res = stretchedBox2->explode(testVector,2);
817 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
818 res = stretchedBox3->explode(testVector,2);
819 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
820 res = stretchedBox4->explode(testVector,2);
821 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
822 res = tiltedBox1->explode(testVector,2);
823 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
824 res = tiltedBox2->explode(testVector,2);
825 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
826 res = tiltedBox3->explode(testVector,2);
827 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
828 res = tiltedBox4->explode(testVector,2);
829 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
830 }
831
832 {
833 testVector = Vector(0.5,0.5,0.5);
834 res = unitBox->explode(testVector,2);
835 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
836 res = stretchedBox1->explode(testVector,2);
837 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
838 res = stretchedBox2->explode(testVector,2);
839 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
840 res = stretchedBox3->explode(testVector,2);
841 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
842 res = stretchedBox4->explode(testVector,2);
843 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
844 res = tiltedBox1->explode(testVector,2);
845 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
846 res = tiltedBox2->explode(testVector,2);
847 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
848 res = tiltedBox3->explode(testVector,2);
849 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
850 res = tiltedBox4->explode(testVector,2);
851 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
852 }
853
854 unitBox->setCondition(2,Box::Bounce);
855 stretchedBox1->setCondition(2,Box::Bounce);
856 stretchedBox2->setCondition(2,Box::Bounce);
857 stretchedBox3->setCondition(2,Box::Bounce);
858 stretchedBox4->setCondition(2,Box::Bounce);
859 tiltedBox1->setCondition(2,Box::Bounce);
860 tiltedBox2->setCondition(2,Box::Bounce);
861 tiltedBox3->setCondition(2,Box::Bounce);
862 tiltedBox4->setCondition(2,Box::Bounce);
863
864 {
865 testVector = Vector(0,0,0);
866 res = unitBox->explode(testVector,1);
867 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
868 res = stretchedBox1->explode(testVector,1);
869 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
870 res = stretchedBox2->explode(testVector,1);
871 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
872 res = stretchedBox3->explode(testVector,1);
873 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
874 res = stretchedBox4->explode(testVector,1);
875 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
876 res = tiltedBox1->explode(testVector,1);
877 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
878 res = tiltedBox2->explode(testVector,1);
879 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
880 res = tiltedBox3->explode(testVector,1);
881 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
882 res = tiltedBox4->explode(testVector,1);
883 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
884 }
885
886 {
887 testVector = Vector(0.5,0.5,0.5);
888 res = unitBox->explode(testVector,1);
889 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
890 res = stretchedBox1->explode(testVector,1);
891 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
892 res = stretchedBox2->explode(testVector,1);
893 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
894 res = stretchedBox3->explode(testVector,1);
895 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
896 res = stretchedBox4->explode(testVector,1);
897 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
898 res = tiltedBox1->explode(testVector,1);
899 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
900 res = tiltedBox2->explode(testVector,1);
901 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
902 res = tiltedBox3->explode(testVector,1);
903 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
904 res = tiltedBox4->explode(testVector,1);
905 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
906 }
907
908 {
909 testVector = Vector(0,0,0);
910 res = unitBox->explode(testVector,2);
911 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
912 res = stretchedBox1->explode(testVector,2);
913 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
914 res = stretchedBox2->explode(testVector,2);
915 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
916 res = stretchedBox3->explode(testVector,2);
917 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
918 res = stretchedBox4->explode(testVector,2);
919 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
920 res = tiltedBox1->explode(testVector,2);
921 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
922 res = tiltedBox2->explode(testVector,2);
923 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
924 res = tiltedBox3->explode(testVector,2);
925 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
926 res = tiltedBox4->explode(testVector,2);
927 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
928 }
929
930 {
931 testVector = Vector(0.5,0.5,0.5);
932 res = unitBox->explode(testVector,2);
933 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
934 res = stretchedBox1->explode(testVector,2);
935 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
936 res = stretchedBox2->explode(testVector,2);
937 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
938 res = stretchedBox3->explode(testVector,2);
939 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
940 res = stretchedBox4->explode(testVector,2);
941 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
942 res = tiltedBox1->explode(testVector,2);
943 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
944 res = tiltedBox2->explode(testVector,2);
945 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
946 res = tiltedBox3->explode(testVector,2);
947 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
948 res = tiltedBox4->explode(testVector,2);
949 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
950 }
951}
952
953void BoxUnittest::BoundaryIgnoreTest(){
954 Vector testVector(0,0,0);
955 VECTORSET(std::list) res;
956
957 unitBox->setCondition(0,Box::Ignore);
958 stretchedBox1->setCondition(0,Box::Ignore);
959 stretchedBox2->setCondition(0,Box::Ignore);
960 stretchedBox3->setCondition(0,Box::Ignore);
961 stretchedBox4->setCondition(0,Box::Ignore);
962 tiltedBox1->setCondition(0,Box::Ignore);
963 tiltedBox2->setCondition(0,Box::Ignore);
964 tiltedBox3->setCondition(0,Box::Ignore);
965 tiltedBox4->setCondition(0,Box::Ignore);
966
967 {
968 testVector = Vector(0,0,0);
969 res = unitBox->explode(testVector,1);
970 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
971 res = stretchedBox1->explode(testVector,1);
972 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
973 res = stretchedBox2->explode(testVector,1);
974 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
975 res = stretchedBox3->explode(testVector,1);
976 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
977 res = stretchedBox4->explode(testVector,1);
978 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
979 res = tiltedBox1->explode(testVector,1);
980 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
981 res = tiltedBox2->explode(testVector,1);
982 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
983 res = tiltedBox3->explode(testVector,1);
984 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
985 res = tiltedBox4->explode(testVector,1);
986 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
987 }
988
989 {
990 testVector = Vector(0.5,0.5,0.5);
991 res = unitBox->explode(testVector,1);
992 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
993 res = stretchedBox1->explode(testVector,1);
994 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
995 res = stretchedBox2->explode(testVector,1);
996 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
997 res = stretchedBox3->explode(testVector,1);
998 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
999 res = stretchedBox4->explode(testVector,1);
1000 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1001 res = tiltedBox1->explode(testVector,1);
1002 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1003 res = tiltedBox2->explode(testVector,1);
1004 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1005 res = tiltedBox3->explode(testVector,1);
1006 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1007 res = tiltedBox4->explode(testVector,1);
1008 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1009 }
1010
1011 {
1012 testVector = Vector(0,0,0);
1013 res = unitBox->explode(testVector,2);
1014 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1015 res = stretchedBox1->explode(testVector,2);
1016 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1017 res = stretchedBox2->explode(testVector,2);
1018 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1019 res = stretchedBox3->explode(testVector,2);
1020 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1021 res = stretchedBox4->explode(testVector,2);
1022 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1023 res = tiltedBox1->explode(testVector,2);
1024 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1025 res = tiltedBox2->explode(testVector,2);
1026 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1027 res = tiltedBox3->explode(testVector,2);
1028 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1029 res = tiltedBox4->explode(testVector,2);
1030 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1031 }
1032
1033 {
1034 testVector = Vector(0.5,0.5,0.5);
1035 res = unitBox->explode(testVector,2);
1036 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1037 res = stretchedBox1->explode(testVector,2);
1038 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1039 res = stretchedBox2->explode(testVector,2);
1040 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1041 res = stretchedBox3->explode(testVector,2);
1042 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1043 res = stretchedBox4->explode(testVector,2);
1044 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1045 res = tiltedBox1->explode(testVector,2);
1046 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1047 res = tiltedBox2->explode(testVector,2);
1048 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1049 res = tiltedBox3->explode(testVector,2);
1050 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1051 res = tiltedBox4->explode(testVector,2);
1052 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1053 }
1054
1055 unitBox->setCondition(1,Box::Ignore);
1056 stretchedBox1->setCondition(1,Box::Ignore);
1057 stretchedBox2->setCondition(1,Box::Ignore);
1058 stretchedBox3->setCondition(1,Box::Ignore);
1059 stretchedBox4->setCondition(1,Box::Ignore);
1060 tiltedBox1->setCondition(1,Box::Ignore);
1061 tiltedBox2->setCondition(1,Box::Ignore);
1062 tiltedBox3->setCondition(1,Box::Ignore);
1063 tiltedBox4->setCondition(1,Box::Ignore);
1064
1065 {
1066 testVector = Vector(0,0,0);
1067 res = unitBox->explode(testVector,1);
1068 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1069 res = stretchedBox1->explode(testVector,1);
1070 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1071 res = stretchedBox2->explode(testVector,1);
1072 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1073 res = stretchedBox3->explode(testVector,1);
1074 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1075 res = stretchedBox4->explode(testVector,1);
1076 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1077 res = tiltedBox1->explode(testVector,1);
1078 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1079 res = tiltedBox2->explode(testVector,1);
1080 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1081 res = tiltedBox3->explode(testVector,1);
1082 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1083 res = tiltedBox4->explode(testVector,1);
1084 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1085 }
1086
1087 {
1088 testVector = Vector(0.5,0.5,0.5);
1089 res = unitBox->explode(testVector,1);
1090 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1091 res = stretchedBox1->explode(testVector,1);
1092 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1093 res = stretchedBox2->explode(testVector,1);
1094 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1095 res = stretchedBox3->explode(testVector,1);
1096 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1097 res = stretchedBox4->explode(testVector,1);
1098 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1099 res = tiltedBox1->explode(testVector,1);
1100 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1101 res = tiltedBox2->explode(testVector,1);
1102 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1103 res = tiltedBox3->explode(testVector,1);
1104 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1105 res = tiltedBox4->explode(testVector,1);
1106 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1107 }
1108
1109 {
1110 testVector = Vector(0,0,0);
1111 res = unitBox->explode(testVector,2);
1112 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1113 res = stretchedBox1->explode(testVector,2);
1114 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1115 res = stretchedBox2->explode(testVector,2);
1116 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1117 res = stretchedBox3->explode(testVector,2);
1118 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1119 res = stretchedBox4->explode(testVector,2);
1120 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1121 res = tiltedBox1->explode(testVector,2);
1122 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1123 res = tiltedBox2->explode(testVector,2);
1124 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1125 res = tiltedBox3->explode(testVector,2);
1126 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1127 res = tiltedBox4->explode(testVector,2);
1128 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1129 }
1130
1131 {
1132 testVector = Vector(0.5,0.5,0.5);
1133 res = unitBox->explode(testVector,2);
1134 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1135 res = stretchedBox1->explode(testVector,2);
1136 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1137 res = stretchedBox2->explode(testVector,2);
1138 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1139 res = stretchedBox3->explode(testVector,2);
1140 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1141 res = stretchedBox4->explode(testVector,2);
1142 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1143 res = tiltedBox1->explode(testVector,2);
1144 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1145 res = tiltedBox2->explode(testVector,2);
1146 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1147 res = tiltedBox3->explode(testVector,2);
1148 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1149 res = tiltedBox4->explode(testVector,2);
1150 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1151 }
1152
1153 unitBox->setCondition(2,Box::Ignore);
1154 stretchedBox1->setCondition(2,Box::Ignore);
1155 stretchedBox2->setCondition(2,Box::Ignore);
1156 stretchedBox3->setCondition(2,Box::Ignore);
1157 stretchedBox4->setCondition(2,Box::Ignore);
1158 tiltedBox1->setCondition(2,Box::Ignore);
1159 tiltedBox2->setCondition(2,Box::Ignore);
1160 tiltedBox3->setCondition(2,Box::Ignore);
1161 tiltedBox4->setCondition(2,Box::Ignore);
1162
1163 {
1164 testVector = Vector(0,0,0);
1165 res = unitBox->explode(testVector,1);
1166 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1167 res = stretchedBox1->explode(testVector,1);
1168 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1169 res = stretchedBox2->explode(testVector,1);
1170 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1171 res = stretchedBox3->explode(testVector,1);
1172 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1173 res = stretchedBox4->explode(testVector,1);
1174 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1175 res = tiltedBox1->explode(testVector,1);
1176 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1177 res = tiltedBox2->explode(testVector,1);
1178 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1179 res = tiltedBox3->explode(testVector,1);
1180 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1181 res = tiltedBox4->explode(testVector,1);
1182 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1183 }
1184
1185 {
1186 testVector = Vector(0.5,0.5,0.5);
1187 res = unitBox->explode(testVector,1);
1188 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1189 res = stretchedBox1->explode(testVector,1);
1190 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1191 res = stretchedBox2->explode(testVector,1);
1192 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1193 res = stretchedBox3->explode(testVector,1);
1194 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1195 res = stretchedBox4->explode(testVector,1);
1196 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1197 res = tiltedBox1->explode(testVector,1);
1198 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1199 res = tiltedBox2->explode(testVector,1);
1200 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1201 res = tiltedBox3->explode(testVector,1);
1202 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1203 res = tiltedBox4->explode(testVector,1);
1204 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1205 }
1206
1207 {
1208 testVector = Vector(0,0,0);
1209 res = unitBox->explode(testVector,2);
1210 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1211 res = stretchedBox1->explode(testVector,2);
1212 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1213 res = stretchedBox2->explode(testVector,2);
1214 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1215 res = stretchedBox3->explode(testVector,2);
1216 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1217 res = stretchedBox4->explode(testVector,2);
1218 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1219 res = tiltedBox1->explode(testVector,2);
1220 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1221 res = tiltedBox2->explode(testVector,2);
1222 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1223 res = tiltedBox3->explode(testVector,2);
1224 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1225 res = tiltedBox4->explode(testVector,2);
1226 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1227 }
1228
1229 {
1230 testVector = Vector(0.5,0.5,0.5);
1231 res = unitBox->explode(testVector,2);
1232 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1233 res = stretchedBox1->explode(testVector,2);
1234 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1235 res = stretchedBox2->explode(testVector,2);
1236 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1237 res = stretchedBox3->explode(testVector,2);
1238 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1239 res = stretchedBox4->explode(testVector,2);
1240 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1241 res = tiltedBox1->explode(testVector,2);
1242 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1243 res = tiltedBox2->explode(testVector,2);
1244 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1245 res = tiltedBox3->explode(testVector,2);
1246 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1247 res = tiltedBox4->explode(testVector,2);
1248 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1249 }
1250}
1251
1252void BoxUnittest::BoundaryMixedTest(){
1253 Vector testVector(0,0,0);
1254 VECTORSET(std::list) res;
1255
1256 unitBox->setCondition(0,Box::Bounce);
1257 unitBox->setCondition(1,Box::Ignore);
1258 unitBox->setCondition(2,Box::Wrap);
1259
1260 stretchedBox1->setCondition(0,Box::Bounce);
1261 stretchedBox1->setCondition(1,Box::Ignore);
1262 stretchedBox1->setCondition(2,Box::Wrap);
1263
1264 stretchedBox2->setCondition(0,Box::Bounce);
1265 stretchedBox2->setCondition(1,Box::Ignore);
1266 stretchedBox2->setCondition(2,Box::Wrap);
1267
1268 stretchedBox3->setCondition(0,Box::Bounce);
1269 stretchedBox3->setCondition(1,Box::Ignore);
1270 stretchedBox3->setCondition(2,Box::Wrap);
1271
1272 stretchedBox4->setCondition(0,Box::Bounce);
1273 stretchedBox4->setCondition(1,Box::Ignore);
1274 stretchedBox4->setCondition(2,Box::Wrap);
1275
1276 tiltedBox1->setCondition(0,Box::Bounce);
1277 tiltedBox1->setCondition(1,Box::Ignore);
1278 tiltedBox1->setCondition(2,Box::Wrap);
1279
1280 tiltedBox2->setCondition(0,Box::Bounce);
1281 tiltedBox2->setCondition(1,Box::Ignore);
1282 tiltedBox2->setCondition(2,Box::Wrap);
1283
1284 tiltedBox3->setCondition(0,Box::Bounce);
1285 tiltedBox3->setCondition(1,Box::Ignore);
1286 tiltedBox3->setCondition(2,Box::Wrap);
1287
1288 tiltedBox4->setCondition(0,Box::Bounce);
1289 tiltedBox4->setCondition(1,Box::Ignore);
1290 tiltedBox4->setCondition(2,Box::Wrap);
1291
1292 {
1293 testVector = Vector(0,0,0);
1294 res = unitBox->explode(testVector,1);
1295 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1296 res = stretchedBox1->explode(testVector,1);
1297 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1298 res = stretchedBox2->explode(testVector,1);
1299 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1300 res = stretchedBox3->explode(testVector,1);
1301 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1302 res = stretchedBox4->explode(testVector,1);
1303 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1304 res = tiltedBox1->explode(testVector,1);
1305 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1306 res = tiltedBox2->explode(testVector,1);
1307 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1308 res = tiltedBox3->explode(testVector,1);
1309 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1310 res = tiltedBox4->explode(testVector,1);
1311 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1312 }
1313
1314 {
1315 testVector = Vector(0.5,0.5,0.5);
1316 res = unitBox->explode(testVector,1);
1317 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1318 res = stretchedBox1->explode(testVector,1);
1319 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1320 res = stretchedBox2->explode(testVector,1);
1321 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1322 res = stretchedBox3->explode(testVector,1);
1323 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1324 res = stretchedBox4->explode(testVector,1);
1325 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1326 res = tiltedBox1->explode(testVector,1);
1327 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1328 res = tiltedBox2->explode(testVector,1);
1329 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1330 res = tiltedBox3->explode(testVector,1);
1331 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1332 res = tiltedBox4->explode(testVector,1);
1333 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1334 }
1335
1336 {
1337 testVector = Vector(0,0,0);
1338 res = unitBox->explode(testVector,2);
1339 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1340 res = stretchedBox1->explode(testVector,2);
1341 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1342 res = stretchedBox2->explode(testVector,2);
1343 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1344 res = stretchedBox3->explode(testVector,2);
1345 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1346 res = stretchedBox4->explode(testVector,2);
1347 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1348 res = tiltedBox1->explode(testVector,2);
1349 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1350 res = tiltedBox2->explode(testVector,2);
1351 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1352 res = tiltedBox3->explode(testVector,2);
1353 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1354 res = tiltedBox4->explode(testVector,2);
1355 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1356 }
1357
1358 {
1359 testVector = Vector(0.5,0.5,0.5);
1360 res = unitBox->explode(testVector,2);
1361 CPPUNIT_ASSERT(testWrapExplode(res,testVector,unitBox));
1362 res = stretchedBox1->explode(testVector,2);
1363 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox1));
1364 res = stretchedBox2->explode(testVector,2);
1365 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox2));
1366 res = stretchedBox3->explode(testVector,2);
1367 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox3));
1368 res = stretchedBox4->explode(testVector,2);
1369 CPPUNIT_ASSERT(testWrapExplode(res,testVector,stretchedBox4));
1370 res = tiltedBox1->explode(testVector,2);
1371 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox1));
1372 res = tiltedBox2->explode(testVector,2);
1373 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox2));
1374 res = tiltedBox3->explode(testVector,2);
1375 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox3));
1376 res = tiltedBox4->explode(testVector,2);
1377 CPPUNIT_ASSERT(testWrapExplode(res,testVector,tiltedBox4));
1378 }
1379
1380}
Note: See TracBrowser for help on using the repository browser.