Changeset 71910a for molecuilder/src/unittests/vectorunittest.cpp
- Timestamp:
- Apr 7, 2010, 3:45:38 PM (16 years ago)
- Children:
- 0f55b2
- Parents:
- 770138
- File:
-
- 1 edited
-
molecuilder/src/unittests/vectorunittest.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/unittests/vectorunittest.cpp
r770138 r71910a 17 17 #include "memoryusageobserver.hpp" 18 18 #include "vector.hpp" 19 #include "vector_ops.hpp" 19 20 #include "vectorunittest.hpp" 21 #include "Plane.hpp" 22 #include "Exceptions/LinearDependenceException.hpp" 20 23 21 24 #ifdef HAVE_TESTRUNNER … … 195 198 { 196 199 // plane at (0,0,0) normal to (1,0,0) cuts line from (0,0,0) to (2,1,0) at ??? 197 CPPUNIT_ASSERT_ EQUAL( true, fixture.GetIntersectionWithPlane(&unit, &zero, &zero, &two) );200 CPPUNIT_ASSERT_NO_THROW(fixture = Plane(unit, zero).GetIntersection(zero, two) ); 198 201 CPPUNIT_ASSERT_EQUAL( zero, fixture ); 199 202 200 203 // plane at (2,1,0) normal to (0,1,0) cuts line from (1,0,0) to (0,1,1) at ??? 201 CPPUNIT_ASSERT_ EQUAL( true, fixture.GetIntersectionWithPlane(&otherunit, &two, &unit, ¬unit) );204 CPPUNIT_ASSERT_NO_THROW(fixture = Plane(otherunit, two).GetIntersection( unit, notunit) ); 202 205 CPPUNIT_ASSERT_EQUAL( Vector(0., 1., 1.), fixture ); 203 206 204 207 // four vectors equal to zero 205 CPPUNIT_ASSERT_EQUAL( false, fixture.GetIntersectionOfTwoLinesOnPlane(&zero, &zero, &zero, &zero, NULL) ); 208 CPPUNIT_ASSERT_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(zero, zero, zero, zero), LinearDependenceException); 209 //CPPUNIT_ASSERT_EQUAL( zero, fixture ); 210 211 // four vectors equal to unit 212 CPPUNIT_ASSERT_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, unit, unit, unit), LinearDependenceException); 213 //CPPUNIT_ASSERT_EQUAL( zero, fixture ); 214 215 // two equal lines 216 CPPUNIT_ASSERT_NO_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, unit, two)); 217 CPPUNIT_ASSERT_EQUAL( unit, fixture ); 218 219 // line from (1,0,0) to (2,1,0) cuts line from (1,0,0) to (0,1,0) at ??? 220 CPPUNIT_ASSERT_NO_THROW( fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, unit, otherunit) ); 221 CPPUNIT_ASSERT_EQUAL( unit, fixture ); 222 223 // line from (1,0,0) to (0,0,0) cuts line from (0,0,0) to (2,1,0) at ??? 224 CPPUNIT_ASSERT_NO_THROW( fixture = GetIntersectionOfTwoLinesOnPlane(unit, zero, zero, two) ); 206 225 CPPUNIT_ASSERT_EQUAL( zero, fixture ); 207 226 208 // four vectors equal to unit 209 CPPUNIT_ASSERT_EQUAL( false, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &unit, &unit, &unit, NULL) ); 227 // line from (1,0,0) to (2,1,0) cuts line from (0,0,0) to (0,1,0) at ??? 228 CPPUNIT_ASSERT_NO_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, zero, otherunit) ); 229 CPPUNIT_ASSERT_EQUAL( Vector(0., -1., 0.), fixture ); 230 }; 231 232 /** UnitTest for vector rotations. 233 */ 234 void VectorTest::VectorRotationTest() 235 { 236 fixture.Init(-1.,0.,0.); 237 238 // zero vector does not change 239 fixture = RotateVector(zero,unit, 1.); 210 240 CPPUNIT_ASSERT_EQUAL( zero, fixture ); 211 241 212 // two equal lines 213 CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &two, &unit, &two, NULL) ); 242 fixture = RotateVector(zero, two, 1.); 243 CPPUNIT_ASSERT_EQUAL( zero, fixture); 244 245 // vector on axis does not change 246 fixture = RotateVector(unit,unit, 1.); 214 247 CPPUNIT_ASSERT_EQUAL( unit, fixture ); 215 248 216 // line from (1,0,0) to (2,1,0) cuts line from (1,0,0) to (0,1,0) at ???217 CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &two, &unit, &otherunit, NULL) );218 CPPUNIT_ASSERT_EQUAL( unit, fixture );219 220 // line from (1,0,0) to (0,0,0) cuts line from (0,0,0) to (2,1,0) at ???221 CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &zero, &zero, &two, NULL) );222 CPPUNIT_ASSERT_EQUAL( zero, fixture );223 224 // line from (1,0,0) to (2,1,0) cuts line from (0,0,0) to (0,1,0) at ???225 CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &two, &zero, &otherunit, NULL) );226 CPPUNIT_ASSERT_EQUAL( Vector(0., -1., 0.), fixture );227 };228 229 /** UnitTest for vector rotations.230 */231 void VectorTest::VectorRotationTest()232 {233 fixture.Init(-1.,0.,0.);234 235 // zero vector does not change236 fixture.CopyVector(&zero);237 fixture.RotateVector(&unit, 1.);238 CPPUNIT_ASSERT_EQUAL( zero, fixture );239 240 fixture.RotateVector(&two, 1.);241 CPPUNIT_ASSERT_EQUAL( zero, fixture);242 243 // vector on axis does not change244 fixture.CopyVector(&unit);245 fixture.RotateVector(&unit, 1.);246 CPPUNIT_ASSERT_EQUAL( unit, fixture );247 248 fixture.RotateVector(&unit, 1.);249 CPPUNIT_ASSERT_EQUAL( unit, fixture );250 251 249 // rotations 252 fixture.CopyVector(&otherunit); 253 fixture.RotateVector(&unit, M_PI); 250 fixture = RotateVector(otherunit, unit, M_PI); 254 251 CPPUNIT_ASSERT_EQUAL( Vector(0.,-1.,0.), fixture ); 255 252 256 fixture.CopyVector(&otherunit); 257 fixture.RotateVector(&unit, 2. * M_PI); 253 fixture = RotateVector(otherunit, unit, 2. * M_PI); 258 254 CPPUNIT_ASSERT_EQUAL( otherunit, fixture ); 259 255 260 fixture.CopyVector(&otherunit); 261 fixture.RotateVector(&unit, 0); 256 fixture = RotateVector(otherunit,unit, 0); 262 257 CPPUNIT_ASSERT_EQUAL( otherunit, fixture ); 263 258 264 fixture.Init(0.,0.,1.); 265 fixture.RotateVector(¬unit, M_PI); 259 fixture = RotateVector(Vector(0.,0.,1.), notunit, M_PI); 266 260 CPPUNIT_ASSERT_EQUAL( otherunit, fixture ); 267 261 }
Note:
See TracChangeset
for help on using the changeset viewer.
