source: src/unittests/ShapeUnittest.cpp@ 6d750f

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

More unittests for Shapes added

  • Property mode set to 100644
File size: 23.5 KB
Line 
1/*
2 * ShapeUnittest.cpp
3 *
4 * Created on: Jun 18, 2010
5 * Author: crueger
6 */
7
8#include "ShapeUnittest.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 "Shapes/Shape.hpp"
19#include "Shapes/BaseShapes.hpp"
20#include "vector.cpp"
21
22// Registers the fixture into the 'registry'
23CPPUNIT_TEST_SUITE_REGISTRATION( ShapeUnittest );
24
25void ShapeUnittest::setUp()
26{
27 v000 = 0*unitVec[0]+0*unitVec[1]+0*unitVec[2];
28 v100 = 1*unitVec[0]+0*unitVec[1]+0*unitVec[2];
29 v200 = -1*unitVec[0]+0*unitVec[1]+0*unitVec[2];
30 v010 = 0*unitVec[0]+1*unitVec[1]+0*unitVec[2];
31 v110 = 1*unitVec[0]+1*unitVec[1]+0*unitVec[2];
32 v210 = -1*unitVec[0]+1*unitVec[1]+0*unitVec[2];
33 v020 = 0*unitVec[0]-1*unitVec[1]+0*unitVec[2];
34 v120 = 1*unitVec[0]-1*unitVec[1]+0*unitVec[2];
35 v220 = -1*unitVec[0]-1*unitVec[1]+0*unitVec[2];
36 v001 = 0*unitVec[0]+0*unitVec[1]+1*unitVec[2];
37 v101 = 1*unitVec[0]+0*unitVec[1]+1*unitVec[2];
38 v201 = -1*unitVec[0]+0*unitVec[1]+1*unitVec[2];
39 v011 = 0*unitVec[0]+1*unitVec[1]+1*unitVec[2];
40 v111 = 1*unitVec[0]+1*unitVec[1]+1*unitVec[2];
41 v211 = -1*unitVec[0]+1*unitVec[1]+1*unitVec[2];
42 v021 = 0*unitVec[0]-1*unitVec[1]+1*unitVec[2];
43 v121 = 1*unitVec[0]-1*unitVec[1]+1*unitVec[2];
44 v221 = -1*unitVec[0]-1*unitVec[1]+1*unitVec[2];
45 v002 = 0*unitVec[0]+0*unitVec[1]-1*unitVec[2];
46 v102 = 1*unitVec[0]+0*unitVec[1]-1*unitVec[2];
47 v202 = -1*unitVec[0]+0*unitVec[1]-1*unitVec[2];
48 v012 = 0*unitVec[0]+1*unitVec[1]-1*unitVec[2];
49 v112 = 1*unitVec[0]+1*unitVec[1]-1*unitVec[2];
50 v212 = -1*unitVec[0]+1*unitVec[1]-1*unitVec[2];
51 v022 = 0*unitVec[0]-1*unitVec[1]-1*unitVec[2];
52 v122 = 1*unitVec[0]-1*unitVec[1]-1*unitVec[2];
53 v222 = -1*unitVec[0]-1*unitVec[1]-1*unitVec[2];
54}
55
56void ShapeUnittest::tearDown()
57{}
58
59
60void ShapeUnittest::baseShapesTest(){
61 CPPUNIT_ASSERT(!Nowhere().isInside(v000));
62 CPPUNIT_ASSERT(!Nowhere().isInside(v100));
63 CPPUNIT_ASSERT(!Nowhere().isInside(v200));
64 CPPUNIT_ASSERT(!Nowhere().isInside(v010));
65 CPPUNIT_ASSERT(!Nowhere().isInside(v110));
66 CPPUNIT_ASSERT(!Nowhere().isInside(v210));
67 CPPUNIT_ASSERT(!Nowhere().isInside(v020));
68 CPPUNIT_ASSERT(!Nowhere().isInside(v120));
69 CPPUNIT_ASSERT(!Nowhere().isInside(v220));
70 CPPUNIT_ASSERT(!Nowhere().isInside(v001));
71 CPPUNIT_ASSERT(!Nowhere().isInside(v101));
72 CPPUNIT_ASSERT(!Nowhere().isInside(v201));
73 CPPUNIT_ASSERT(!Nowhere().isInside(v011));
74 CPPUNIT_ASSERT(!Nowhere().isInside(v111));
75 CPPUNIT_ASSERT(!Nowhere().isInside(v211));
76 CPPUNIT_ASSERT(!Nowhere().isInside(v021));
77 CPPUNIT_ASSERT(!Nowhere().isInside(v121));
78 CPPUNIT_ASSERT(!Nowhere().isInside(v221));
79 CPPUNIT_ASSERT(!Nowhere().isInside(v002));
80 CPPUNIT_ASSERT(!Nowhere().isInside(v102));
81 CPPUNIT_ASSERT(!Nowhere().isInside(v202));
82 CPPUNIT_ASSERT(!Nowhere().isInside(v012));
83 CPPUNIT_ASSERT(!Nowhere().isInside(v112));
84 CPPUNIT_ASSERT(!Nowhere().isInside(v212));
85 CPPUNIT_ASSERT(!Nowhere().isInside(v022));
86 CPPUNIT_ASSERT(!Nowhere().isInside(v122));
87 CPPUNIT_ASSERT(!Nowhere().isInside(v222));
88
89 CPPUNIT_ASSERT(Everywhere().isInside(v000));
90 CPPUNIT_ASSERT(Everywhere().isInside(v100));
91 CPPUNIT_ASSERT(Everywhere().isInside(v200));
92 CPPUNIT_ASSERT(Everywhere().isInside(v010));
93 CPPUNIT_ASSERT(Everywhere().isInside(v110));
94 CPPUNIT_ASSERT(Everywhere().isInside(v210));
95 CPPUNIT_ASSERT(Everywhere().isInside(v020));
96 CPPUNIT_ASSERT(Everywhere().isInside(v120));
97 CPPUNIT_ASSERT(Everywhere().isInside(v220));
98 CPPUNIT_ASSERT(Everywhere().isInside(v001));
99 CPPUNIT_ASSERT(Everywhere().isInside(v101));
100 CPPUNIT_ASSERT(Everywhere().isInside(v201));
101 CPPUNIT_ASSERT(Everywhere().isInside(v011));
102 CPPUNIT_ASSERT(Everywhere().isInside(v111));
103 CPPUNIT_ASSERT(Everywhere().isInside(v211));
104 CPPUNIT_ASSERT(Everywhere().isInside(v021));
105 CPPUNIT_ASSERT(Everywhere().isInside(v121));
106 CPPUNIT_ASSERT(Everywhere().isInside(v221));
107 CPPUNIT_ASSERT(Everywhere().isInside(v002));
108 CPPUNIT_ASSERT(Everywhere().isInside(v102));
109 CPPUNIT_ASSERT(Everywhere().isInside(v202));
110 CPPUNIT_ASSERT(Everywhere().isInside(v012));
111 CPPUNIT_ASSERT(Everywhere().isInside(v112));
112 CPPUNIT_ASSERT(Everywhere().isInside(v212));
113 CPPUNIT_ASSERT(Everywhere().isInside(v022));
114 CPPUNIT_ASSERT(Everywhere().isInside(v122));
115 CPPUNIT_ASSERT(Everywhere().isInside(v222));
116
117 CPPUNIT_ASSERT(Cuboid().isInside(v000));
118 CPPUNIT_ASSERT(Cuboid().isInside(v100));
119 CPPUNIT_ASSERT(Cuboid().isInside(v200));
120 CPPUNIT_ASSERT(Cuboid().isInside(v010));
121 CPPUNIT_ASSERT(Cuboid().isInside(v110));
122 CPPUNIT_ASSERT(Cuboid().isInside(v210));
123 CPPUNIT_ASSERT(Cuboid().isInside(v020));
124 CPPUNIT_ASSERT(Cuboid().isInside(v120));
125 CPPUNIT_ASSERT(Cuboid().isInside(v220));
126 CPPUNIT_ASSERT(Cuboid().isInside(v001));
127 CPPUNIT_ASSERT(Cuboid().isInside(v101));
128 CPPUNIT_ASSERT(Cuboid().isInside(v201));
129 CPPUNIT_ASSERT(Cuboid().isInside(v011));
130 CPPUNIT_ASSERT(Cuboid().isInside(v111));
131 CPPUNIT_ASSERT(Cuboid().isInside(v211));
132 CPPUNIT_ASSERT(Cuboid().isInside(v021));
133 CPPUNIT_ASSERT(Cuboid().isInside(v121));
134 CPPUNIT_ASSERT(Cuboid().isInside(v221));
135 CPPUNIT_ASSERT(Cuboid().isInside(v002));
136 CPPUNIT_ASSERT(Cuboid().isInside(v102));
137 CPPUNIT_ASSERT(Cuboid().isInside(v202));
138 CPPUNIT_ASSERT(Cuboid().isInside(v012));
139 CPPUNIT_ASSERT(Cuboid().isInside(v112));
140 CPPUNIT_ASSERT(Cuboid().isInside(v212));
141 CPPUNIT_ASSERT(Cuboid().isInside(v022));
142 CPPUNIT_ASSERT(Cuboid().isInside(v122));
143 CPPUNIT_ASSERT(Cuboid().isInside(v222));
144
145 CPPUNIT_ASSERT(Sphere().isInside(v000));
146 CPPUNIT_ASSERT(Sphere().isInside(v100));
147 CPPUNIT_ASSERT(Sphere().isInside(v200));
148 CPPUNIT_ASSERT(Sphere().isInside(v010));
149 CPPUNIT_ASSERT(!Sphere().isInside(v110));
150 CPPUNIT_ASSERT(!Sphere().isInside(v210));
151 CPPUNIT_ASSERT(Sphere().isInside(v020));
152 CPPUNIT_ASSERT(!Sphere().isInside(v120));
153 CPPUNIT_ASSERT(!Sphere().isInside(v220));
154 CPPUNIT_ASSERT(Sphere().isInside(v001));
155 CPPUNIT_ASSERT(!Sphere().isInside(v101));
156 CPPUNIT_ASSERT(!Sphere().isInside(v201));
157 CPPUNIT_ASSERT(!Sphere().isInside(v011));
158 CPPUNIT_ASSERT(!Sphere().isInside(v111));
159 CPPUNIT_ASSERT(!Sphere().isInside(v211));
160 CPPUNIT_ASSERT(!Sphere().isInside(v021));
161 CPPUNIT_ASSERT(!Sphere().isInside(v121));
162 CPPUNIT_ASSERT(!Sphere().isInside(v221));
163 CPPUNIT_ASSERT(Sphere().isInside(v002));
164 CPPUNIT_ASSERT(!Sphere().isInside(v102));
165 CPPUNIT_ASSERT(!Sphere().isInside(v202));
166 CPPUNIT_ASSERT(!Sphere().isInside(v012));
167 CPPUNIT_ASSERT(!Sphere().isInside(v112));
168 CPPUNIT_ASSERT(!Sphere().isInside(v212));
169 CPPUNIT_ASSERT(!Sphere().isInside(v022));
170 CPPUNIT_ASSERT(!Sphere().isInside(v122));
171 CPPUNIT_ASSERT(!Sphere().isInside(v222));
172}
173
174void ShapeUnittest::surfaceTest(){
175 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v000));
176 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v100));
177 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v200));
178 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v010));
179 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v110));
180 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v210));
181 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v020));
182 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v120));
183 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v220));
184 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v001));
185 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v101));
186 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v201));
187 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v011));
188 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v111));
189 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v211));
190 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v021));
191 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v121));
192 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v221));
193 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v002));
194 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v102));
195 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v202));
196 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v012));
197 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v112));
198 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v212));
199 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v022));
200 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v122));
201 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v222));
202
203 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v000));
204 CPPUNIT_ASSERT(Cuboid().isOnSurface(v100));
205 CPPUNIT_ASSERT(Cuboid().isOnSurface(v200));
206 CPPUNIT_ASSERT(Cuboid().isOnSurface(v010));
207 CPPUNIT_ASSERT(Cuboid().isOnSurface(v110));
208 CPPUNIT_ASSERT(Cuboid().isOnSurface(v210));
209 CPPUNIT_ASSERT(Cuboid().isOnSurface(v020));
210 CPPUNIT_ASSERT(Cuboid().isOnSurface(v120));
211 CPPUNIT_ASSERT(Cuboid().isOnSurface(v220));
212 CPPUNIT_ASSERT(Cuboid().isOnSurface(v001));
213 CPPUNIT_ASSERT(Cuboid().isOnSurface(v101));
214 CPPUNIT_ASSERT(Cuboid().isOnSurface(v201));
215 CPPUNIT_ASSERT(Cuboid().isOnSurface(v011));
216 CPPUNIT_ASSERT(Cuboid().isOnSurface(v111));
217 CPPUNIT_ASSERT(Cuboid().isOnSurface(v211));
218 CPPUNIT_ASSERT(Cuboid().isOnSurface(v021));
219 CPPUNIT_ASSERT(Cuboid().isOnSurface(v121));
220 CPPUNIT_ASSERT(Cuboid().isOnSurface(v221));
221 CPPUNIT_ASSERT(Cuboid().isOnSurface(v002));
222 CPPUNIT_ASSERT(Cuboid().isOnSurface(v102));
223 CPPUNIT_ASSERT(Cuboid().isOnSurface(v202));
224 CPPUNIT_ASSERT(Cuboid().isOnSurface(v012));
225 CPPUNIT_ASSERT(Cuboid().isOnSurface(v112));
226 CPPUNIT_ASSERT(Cuboid().isOnSurface(v212));
227 CPPUNIT_ASSERT(Cuboid().isOnSurface(v022));
228 CPPUNIT_ASSERT(Cuboid().isOnSurface(v122));
229 CPPUNIT_ASSERT(Cuboid().isOnSurface(v222));
230
231 CPPUNIT_ASSERT(!Sphere().isOnSurface(v000));
232 CPPUNIT_ASSERT(Sphere().isOnSurface(v100));
233 CPPUNIT_ASSERT(Sphere().isOnSurface(v200));
234 CPPUNIT_ASSERT(Sphere().isOnSurface(v010));
235 CPPUNIT_ASSERT(!Sphere().isOnSurface(v110));
236 CPPUNIT_ASSERT(!Sphere().isOnSurface(v210));
237 CPPUNIT_ASSERT(Sphere().isOnSurface(v020));
238 CPPUNIT_ASSERT(!Sphere().isOnSurface(v120));
239 CPPUNIT_ASSERT(!Sphere().isOnSurface(v220));
240 CPPUNIT_ASSERT(Sphere().isOnSurface(v001));
241 CPPUNIT_ASSERT(!Sphere().isOnSurface(v101));
242 CPPUNIT_ASSERT(!Sphere().isOnSurface(v201));
243 CPPUNIT_ASSERT(!Sphere().isOnSurface(v011));
244 CPPUNIT_ASSERT(!Sphere().isOnSurface(v111));
245 CPPUNIT_ASSERT(!Sphere().isOnSurface(v211));
246 CPPUNIT_ASSERT(!Sphere().isOnSurface(v021));
247 CPPUNIT_ASSERT(!Sphere().isOnSurface(v121));
248 CPPUNIT_ASSERT(!Sphere().isOnSurface(v221));
249 CPPUNIT_ASSERT(Sphere().isOnSurface(v002));
250 CPPUNIT_ASSERT(!Sphere().isOnSurface(v102));
251 CPPUNIT_ASSERT(!Sphere().isOnSurface(v202));
252 CPPUNIT_ASSERT(!Sphere().isOnSurface(v012));
253 CPPUNIT_ASSERT(!Sphere().isOnSurface(v112));
254 CPPUNIT_ASSERT(!Sphere().isOnSurface(v212));
255 CPPUNIT_ASSERT(!Sphere().isOnSurface(v022));
256 CPPUNIT_ASSERT(!Sphere().isOnSurface(v122));
257 CPPUNIT_ASSERT(!Sphere().isOnSurface(v222));
258}
259
260void ShapeUnittest::assignmentTest(){
261 Shape s1 = Nowhere();
262 s1 = Everywhere();
263
264 CPPUNIT_ASSERT(s1.isInside(v000));
265 CPPUNIT_ASSERT(s1.isInside(v100));
266 CPPUNIT_ASSERT(s1.isInside(v200));
267 CPPUNIT_ASSERT(s1.isInside(v010));
268 CPPUNIT_ASSERT(s1.isInside(v110));
269 CPPUNIT_ASSERT(s1.isInside(v210));
270 CPPUNIT_ASSERT(s1.isInside(v020));
271 CPPUNIT_ASSERT(s1.isInside(v120));
272 CPPUNIT_ASSERT(s1.isInside(v220));
273 CPPUNIT_ASSERT(s1.isInside(v001));
274 CPPUNIT_ASSERT(s1.isInside(v101));
275 CPPUNIT_ASSERT(s1.isInside(v201));
276 CPPUNIT_ASSERT(s1.isInside(v011));
277 CPPUNIT_ASSERT(s1.isInside(v111));
278 CPPUNIT_ASSERT(s1.isInside(v211));
279 CPPUNIT_ASSERT(s1.isInside(v021));
280 CPPUNIT_ASSERT(s1.isInside(v121));
281 CPPUNIT_ASSERT(s1.isInside(v221));
282 CPPUNIT_ASSERT(s1.isInside(v002));
283 CPPUNIT_ASSERT(s1.isInside(v102));
284 CPPUNIT_ASSERT(s1.isInside(v202));
285 CPPUNIT_ASSERT(s1.isInside(v012));
286 CPPUNIT_ASSERT(s1.isInside(v112));
287 CPPUNIT_ASSERT(s1.isInside(v212));
288 CPPUNIT_ASSERT(s1.isInside(v022));
289 CPPUNIT_ASSERT(s1.isInside(v122));
290 CPPUNIT_ASSERT(s1.isInside(v222));
291
292 Shape s2 = Everywhere();
293 s2 = Nowhere();
294
295 CPPUNIT_ASSERT(!s2.isInside(v000));
296 CPPUNIT_ASSERT(!s2.isInside(v100));
297 CPPUNIT_ASSERT(!s2.isInside(v200));
298 CPPUNIT_ASSERT(!s2.isInside(v010));
299 CPPUNIT_ASSERT(!s2.isInside(v110));
300 CPPUNIT_ASSERT(!s2.isInside(v210));
301 CPPUNIT_ASSERT(!s2.isInside(v020));
302 CPPUNIT_ASSERT(!s2.isInside(v120));
303 CPPUNIT_ASSERT(!s2.isInside(v220));
304 CPPUNIT_ASSERT(!s2.isInside(v001));
305 CPPUNIT_ASSERT(!s2.isInside(v101));
306 CPPUNIT_ASSERT(!s2.isInside(v201));
307 CPPUNIT_ASSERT(!s2.isInside(v011));
308 CPPUNIT_ASSERT(!s2.isInside(v111));
309 CPPUNIT_ASSERT(!s2.isInside(v211));
310 CPPUNIT_ASSERT(!s2.isInside(v021));
311 CPPUNIT_ASSERT(!s2.isInside(v121));
312 CPPUNIT_ASSERT(!s2.isInside(v221));
313 CPPUNIT_ASSERT(!s2.isInside(v002));
314 CPPUNIT_ASSERT(!s2.isInside(v102));
315 CPPUNIT_ASSERT(!s2.isInside(v202));
316 CPPUNIT_ASSERT(!s2.isInside(v012));
317 CPPUNIT_ASSERT(!s2.isInside(v112));
318 CPPUNIT_ASSERT(!s2.isInside(v212));
319 CPPUNIT_ASSERT(!s2.isInside(v022));
320 CPPUNIT_ASSERT(!s2.isInside(v122));
321 CPPUNIT_ASSERT(!s2.isInside(v222));
322
323}
324void ShapeUnittest::operatorTest(){
325 {
326 Shape s1 = !Nowhere();
327 CPPUNIT_ASSERT(s1.isInside(v000));
328 CPPUNIT_ASSERT(s1.isInside(v100));
329 CPPUNIT_ASSERT(s1.isInside(v200));
330 CPPUNIT_ASSERT(s1.isInside(v010));
331 CPPUNIT_ASSERT(s1.isInside(v110));
332 CPPUNIT_ASSERT(s1.isInside(v210));
333 CPPUNIT_ASSERT(s1.isInside(v020));
334 CPPUNIT_ASSERT(s1.isInside(v120));
335 CPPUNIT_ASSERT(s1.isInside(v220));
336 CPPUNIT_ASSERT(s1.isInside(v001));
337 CPPUNIT_ASSERT(s1.isInside(v101));
338 CPPUNIT_ASSERT(s1.isInside(v201));
339 CPPUNIT_ASSERT(s1.isInside(v011));
340 CPPUNIT_ASSERT(s1.isInside(v111));
341 CPPUNIT_ASSERT(s1.isInside(v211));
342 CPPUNIT_ASSERT(s1.isInside(v021));
343 CPPUNIT_ASSERT(s1.isInside(v121));
344 CPPUNIT_ASSERT(s1.isInside(v221));
345 CPPUNIT_ASSERT(s1.isInside(v002));
346 CPPUNIT_ASSERT(s1.isInside(v102));
347 CPPUNIT_ASSERT(s1.isInside(v202));
348 CPPUNIT_ASSERT(s1.isInside(v012));
349 CPPUNIT_ASSERT(s1.isInside(v112));
350 CPPUNIT_ASSERT(s1.isInside(v212));
351 CPPUNIT_ASSERT(s1.isInside(v022));
352 CPPUNIT_ASSERT(s1.isInside(v122));
353 CPPUNIT_ASSERT(s1.isInside(v222));
354
355 Shape s2 = !Everywhere();
356 CPPUNIT_ASSERT(!s2.isInside(v000));
357 CPPUNIT_ASSERT(!s2.isInside(v100));
358 CPPUNIT_ASSERT(!s2.isInside(v200));
359 CPPUNIT_ASSERT(!s2.isInside(v010));
360 CPPUNIT_ASSERT(!s2.isInside(v110));
361 CPPUNIT_ASSERT(!s2.isInside(v210));
362 CPPUNIT_ASSERT(!s2.isInside(v020));
363 CPPUNIT_ASSERT(!s2.isInside(v120));
364 CPPUNIT_ASSERT(!s2.isInside(v220));
365 CPPUNIT_ASSERT(!s2.isInside(v001));
366 CPPUNIT_ASSERT(!s2.isInside(v101));
367 CPPUNIT_ASSERT(!s2.isInside(v201));
368 CPPUNIT_ASSERT(!s2.isInside(v011));
369 CPPUNIT_ASSERT(!s2.isInside(v111));
370 CPPUNIT_ASSERT(!s2.isInside(v211));
371 CPPUNIT_ASSERT(!s2.isInside(v021));
372 CPPUNIT_ASSERT(!s2.isInside(v121));
373 CPPUNIT_ASSERT(!s2.isInside(v221));
374 CPPUNIT_ASSERT(!s2.isInside(v002));
375 CPPUNIT_ASSERT(!s2.isInside(v102));
376 CPPUNIT_ASSERT(!s2.isInside(v202));
377 CPPUNIT_ASSERT(!s2.isInside(v012));
378 CPPUNIT_ASSERT(!s2.isInside(v112));
379 CPPUNIT_ASSERT(!s2.isInside(v212));
380 CPPUNIT_ASSERT(!s2.isInside(v022));
381 CPPUNIT_ASSERT(!s2.isInside(v122));
382 CPPUNIT_ASSERT(!s2.isInside(v222));
383 }
384
385 {
386 Shape s1 = Nowhere() || Everywhere();
387 CPPUNIT_ASSERT(s1.isInside(v000));
388 CPPUNIT_ASSERT(s1.isInside(v100));
389 CPPUNIT_ASSERT(s1.isInside(v200));
390 CPPUNIT_ASSERT(s1.isInside(v010));
391 CPPUNIT_ASSERT(s1.isInside(v110));
392 CPPUNIT_ASSERT(s1.isInside(v210));
393 CPPUNIT_ASSERT(s1.isInside(v020));
394 CPPUNIT_ASSERT(s1.isInside(v120));
395 CPPUNIT_ASSERT(s1.isInside(v220));
396 CPPUNIT_ASSERT(s1.isInside(v001));
397 CPPUNIT_ASSERT(s1.isInside(v101));
398 CPPUNIT_ASSERT(s1.isInside(v201));
399 CPPUNIT_ASSERT(s1.isInside(v011));
400 CPPUNIT_ASSERT(s1.isInside(v111));
401 CPPUNIT_ASSERT(s1.isInside(v211));
402 CPPUNIT_ASSERT(s1.isInside(v021));
403 CPPUNIT_ASSERT(s1.isInside(v121));
404 CPPUNIT_ASSERT(s1.isInside(v221));
405 CPPUNIT_ASSERT(s1.isInside(v002));
406 CPPUNIT_ASSERT(s1.isInside(v102));
407 CPPUNIT_ASSERT(s1.isInside(v202));
408 CPPUNIT_ASSERT(s1.isInside(v012));
409 CPPUNIT_ASSERT(s1.isInside(v112));
410 CPPUNIT_ASSERT(s1.isInside(v212));
411 CPPUNIT_ASSERT(s1.isInside(v022));
412 CPPUNIT_ASSERT(s1.isInside(v122));
413 CPPUNIT_ASSERT(s1.isInside(v222));
414
415 Shape s2 = Nowhere() && Everywhere();
416 CPPUNIT_ASSERT(!s2.isInside(v000));
417 CPPUNIT_ASSERT(!s2.isInside(v100));
418 CPPUNIT_ASSERT(!s2.isInside(v200));
419 CPPUNIT_ASSERT(!s2.isInside(v010));
420 CPPUNIT_ASSERT(!s2.isInside(v110));
421 CPPUNIT_ASSERT(!s2.isInside(v210));
422 CPPUNIT_ASSERT(!s2.isInside(v020));
423 CPPUNIT_ASSERT(!s2.isInside(v120));
424 CPPUNIT_ASSERT(!s2.isInside(v220));
425 CPPUNIT_ASSERT(!s2.isInside(v001));
426 CPPUNIT_ASSERT(!s2.isInside(v101));
427 CPPUNIT_ASSERT(!s2.isInside(v201));
428 CPPUNIT_ASSERT(!s2.isInside(v011));
429 CPPUNIT_ASSERT(!s2.isInside(v111));
430 CPPUNIT_ASSERT(!s2.isInside(v211));
431 CPPUNIT_ASSERT(!s2.isInside(v021));
432 CPPUNIT_ASSERT(!s2.isInside(v121));
433 CPPUNIT_ASSERT(!s2.isInside(v221));
434 CPPUNIT_ASSERT(!s2.isInside(v002));
435 CPPUNIT_ASSERT(!s2.isInside(v102));
436 CPPUNIT_ASSERT(!s2.isInside(v202));
437 CPPUNIT_ASSERT(!s2.isInside(v012));
438 CPPUNIT_ASSERT(!s2.isInside(v112));
439 CPPUNIT_ASSERT(!s2.isInside(v212));
440 CPPUNIT_ASSERT(!s2.isInside(v022));
441 CPPUNIT_ASSERT(!s2.isInside(v122));
442 CPPUNIT_ASSERT(!s2.isInside(v222));
443 }
444
445 {
446 Shape s1 = Everywhere() || Nowhere();
447 CPPUNIT_ASSERT(s1.isInside(v000));
448 CPPUNIT_ASSERT(s1.isInside(v100));
449 CPPUNIT_ASSERT(s1.isInside(v200));
450 CPPUNIT_ASSERT(s1.isInside(v010));
451 CPPUNIT_ASSERT(s1.isInside(v110));
452 CPPUNIT_ASSERT(s1.isInside(v210));
453 CPPUNIT_ASSERT(s1.isInside(v020));
454 CPPUNIT_ASSERT(s1.isInside(v120));
455 CPPUNIT_ASSERT(s1.isInside(v220));
456 CPPUNIT_ASSERT(s1.isInside(v001));
457 CPPUNIT_ASSERT(s1.isInside(v101));
458 CPPUNIT_ASSERT(s1.isInside(v201));
459 CPPUNIT_ASSERT(s1.isInside(v011));
460 CPPUNIT_ASSERT(s1.isInside(v111));
461 CPPUNIT_ASSERT(s1.isInside(v211));
462 CPPUNIT_ASSERT(s1.isInside(v021));
463 CPPUNIT_ASSERT(s1.isInside(v121));
464 CPPUNIT_ASSERT(s1.isInside(v221));
465 CPPUNIT_ASSERT(s1.isInside(v002));
466 CPPUNIT_ASSERT(s1.isInside(v102));
467 CPPUNIT_ASSERT(s1.isInside(v202));
468 CPPUNIT_ASSERT(s1.isInside(v012));
469 CPPUNIT_ASSERT(s1.isInside(v112));
470 CPPUNIT_ASSERT(s1.isInside(v212));
471 CPPUNIT_ASSERT(s1.isInside(v022));
472 CPPUNIT_ASSERT(s1.isInside(v122));
473 CPPUNIT_ASSERT(s1.isInside(v222));
474
475 Shape s2 = Everywhere() && Nowhere();
476 CPPUNIT_ASSERT(!s2.isInside(v000));
477 CPPUNIT_ASSERT(!s2.isInside(v100));
478 CPPUNIT_ASSERT(!s2.isInside(v200));
479 CPPUNIT_ASSERT(!s2.isInside(v010));
480 CPPUNIT_ASSERT(!s2.isInside(v110));
481 CPPUNIT_ASSERT(!s2.isInside(v210));
482 CPPUNIT_ASSERT(!s2.isInside(v020));
483 CPPUNIT_ASSERT(!s2.isInside(v120));
484 CPPUNIT_ASSERT(!s2.isInside(v220));
485 CPPUNIT_ASSERT(!s2.isInside(v001));
486 CPPUNIT_ASSERT(!s2.isInside(v101));
487 CPPUNIT_ASSERT(!s2.isInside(v201));
488 CPPUNIT_ASSERT(!s2.isInside(v011));
489 CPPUNIT_ASSERT(!s2.isInside(v111));
490 CPPUNIT_ASSERT(!s2.isInside(v211));
491 CPPUNIT_ASSERT(!s2.isInside(v021));
492 CPPUNIT_ASSERT(!s2.isInside(v121));
493 CPPUNIT_ASSERT(!s2.isInside(v221));
494 CPPUNIT_ASSERT(!s2.isInside(v002));
495 CPPUNIT_ASSERT(!s2.isInside(v102));
496 CPPUNIT_ASSERT(!s2.isInside(v202));
497 CPPUNIT_ASSERT(!s2.isInside(v012));
498 CPPUNIT_ASSERT(!s2.isInside(v112));
499 CPPUNIT_ASSERT(!s2.isInside(v212));
500 CPPUNIT_ASSERT(!s2.isInside(v022));
501 CPPUNIT_ASSERT(!s2.isInside(v122));
502 CPPUNIT_ASSERT(!s2.isInside(v222));
503 }
504
505 {
506 Shape s1 = Sphere() && Cuboid(); // should be the same as Sphere
507
508 CPPUNIT_ASSERT(s1.isInside(v000));
509 CPPUNIT_ASSERT(s1.isInside(v100));
510 CPPUNIT_ASSERT(s1.isInside(v200));
511 CPPUNIT_ASSERT(s1.isInside(v010));
512 CPPUNIT_ASSERT(!s1.isInside(v110));
513 CPPUNIT_ASSERT(!s1.isInside(v210));
514 CPPUNIT_ASSERT(s1.isInside(v020));
515 CPPUNIT_ASSERT(!s1.isInside(v120));
516 CPPUNIT_ASSERT(!s1.isInside(v220));
517 CPPUNIT_ASSERT(s1.isInside(v001));
518 CPPUNIT_ASSERT(!s1.isInside(v101));
519 CPPUNIT_ASSERT(!s1.isInside(v201));
520 CPPUNIT_ASSERT(!s1.isInside(v011));
521 CPPUNIT_ASSERT(!s1.isInside(v111));
522 CPPUNIT_ASSERT(!s1.isInside(v211));
523 CPPUNIT_ASSERT(!s1.isInside(v021));
524 CPPUNIT_ASSERT(!s1.isInside(v121));
525 CPPUNIT_ASSERT(!s1.isInside(v221));
526 CPPUNIT_ASSERT(s1.isInside(v002));
527 CPPUNIT_ASSERT(!s1.isInside(v102));
528 CPPUNIT_ASSERT(!s1.isInside(v202));
529 CPPUNIT_ASSERT(!s1.isInside(v012));
530 CPPUNIT_ASSERT(!s1.isInside(v112));
531 CPPUNIT_ASSERT(!s1.isInside(v212));
532 CPPUNIT_ASSERT(!s1.isInside(v022));
533 CPPUNIT_ASSERT(!s1.isInside(v122));
534 CPPUNIT_ASSERT(!s1.isInside(v222));
535
536 CPPUNIT_ASSERT(!s1.isOnSurface(v000));
537 CPPUNIT_ASSERT(s1.isOnSurface(v100));
538 CPPUNIT_ASSERT(s1.isOnSurface(v200));
539 CPPUNIT_ASSERT(s1.isOnSurface(v010));
540 CPPUNIT_ASSERT(!s1.isOnSurface(v110));
541 CPPUNIT_ASSERT(!s1.isOnSurface(v210));
542 CPPUNIT_ASSERT(s1.isOnSurface(v020));
543 CPPUNIT_ASSERT(!s1.isOnSurface(v120));
544 CPPUNIT_ASSERT(!s1.isOnSurface(v220));
545 CPPUNIT_ASSERT(s1.isOnSurface(v001));
546 CPPUNIT_ASSERT(!s1.isOnSurface(v101));
547 CPPUNIT_ASSERT(!s1.isOnSurface(v201));
548 CPPUNIT_ASSERT(!s1.isOnSurface(v011));
549 CPPUNIT_ASSERT(!s1.isOnSurface(v111));
550 CPPUNIT_ASSERT(!s1.isOnSurface(v211));
551 CPPUNIT_ASSERT(!s1.isOnSurface(v021));
552 CPPUNIT_ASSERT(!s1.isOnSurface(v121));
553 CPPUNIT_ASSERT(!s1.isOnSurface(v221));
554 CPPUNIT_ASSERT(s1.isOnSurface(v002));
555 CPPUNIT_ASSERT(!s1.isOnSurface(v102));
556 CPPUNIT_ASSERT(!s1.isOnSurface(v202));
557 CPPUNIT_ASSERT(!s1.isOnSurface(v012));
558 CPPUNIT_ASSERT(!s1.isOnSurface(v112));
559 CPPUNIT_ASSERT(!s1.isOnSurface(v212));
560 CPPUNIT_ASSERT(!s1.isOnSurface(v022));
561 CPPUNIT_ASSERT(!s1.isOnSurface(v122));
562 CPPUNIT_ASSERT(!s1.isOnSurface(v222));
563
564
565 Shape s2 = Sphere() || Cuboid(); // Should be same as Cuboid
566
567 CPPUNIT_ASSERT(s2.isInside(v000));
568 CPPUNIT_ASSERT(s2.isInside(v100));
569 CPPUNIT_ASSERT(s2.isInside(v200));
570 CPPUNIT_ASSERT(s2.isInside(v010));
571 CPPUNIT_ASSERT(s2.isInside(v110));
572 CPPUNIT_ASSERT(s2.isInside(v210));
573 CPPUNIT_ASSERT(s2.isInside(v020));
574 CPPUNIT_ASSERT(s2.isInside(v120));
575 CPPUNIT_ASSERT(s2.isInside(v220));
576 CPPUNIT_ASSERT(s2.isInside(v001));
577 CPPUNIT_ASSERT(s2.isInside(v101));
578 CPPUNIT_ASSERT(s2.isInside(v201));
579 CPPUNIT_ASSERT(s2.isInside(v011));
580 CPPUNIT_ASSERT(s2.isInside(v111));
581 CPPUNIT_ASSERT(s2.isInside(v211));
582 CPPUNIT_ASSERT(s2.isInside(v021));
583 CPPUNIT_ASSERT(s2.isInside(v121));
584 CPPUNIT_ASSERT(s2.isInside(v221));
585 CPPUNIT_ASSERT(s2.isInside(v002));
586 CPPUNIT_ASSERT(s2.isInside(v102));
587 CPPUNIT_ASSERT(s2.isInside(v202));
588 CPPUNIT_ASSERT(s2.isInside(v012));
589 CPPUNIT_ASSERT(s2.isInside(v112));
590 CPPUNIT_ASSERT(s2.isInside(v212));
591 CPPUNIT_ASSERT(s2.isInside(v022));
592 CPPUNIT_ASSERT(s2.isInside(v122));
593 CPPUNIT_ASSERT(s2.isInside(v222));
594
595 CPPUNIT_ASSERT(!s2.isOnSurface(v000));
596 CPPUNIT_ASSERT(s2.isOnSurface(v100));
597 CPPUNIT_ASSERT(s2.isOnSurface(v200));
598 CPPUNIT_ASSERT(s2.isOnSurface(v010));
599 CPPUNIT_ASSERT(s2.isOnSurface(v110));
600 CPPUNIT_ASSERT(s2.isOnSurface(v210));
601 CPPUNIT_ASSERT(s2.isOnSurface(v020));
602 CPPUNIT_ASSERT(s2.isOnSurface(v120));
603 CPPUNIT_ASSERT(s2.isOnSurface(v220));
604 CPPUNIT_ASSERT(s2.isOnSurface(v001));
605 CPPUNIT_ASSERT(s2.isOnSurface(v101));
606 CPPUNIT_ASSERT(s2.isOnSurface(v201));
607 CPPUNIT_ASSERT(s2.isOnSurface(v011));
608 CPPUNIT_ASSERT(s2.isOnSurface(v111));
609 CPPUNIT_ASSERT(s2.isOnSurface(v211));
610 CPPUNIT_ASSERT(s2.isOnSurface(v021));
611 CPPUNIT_ASSERT(s2.isOnSurface(v121));
612 CPPUNIT_ASSERT(s2.isOnSurface(v221));
613 CPPUNIT_ASSERT(s2.isOnSurface(v002));
614 CPPUNIT_ASSERT(s2.isOnSurface(v102));
615 CPPUNIT_ASSERT(s2.isOnSurface(v202));
616 CPPUNIT_ASSERT(s2.isOnSurface(v012));
617 CPPUNIT_ASSERT(s2.isOnSurface(v112));
618 CPPUNIT_ASSERT(s2.isOnSurface(v212));
619 CPPUNIT_ASSERT(s2.isOnSurface(v022));
620 CPPUNIT_ASSERT(s2.isOnSurface(v122));
621 CPPUNIT_ASSERT(s2.isOnSurface(v222));
622 }
623
624}
Note: See TracBrowser for help on using the repository browser.