Ignore:
Timestamp:
Apr 29, 2010, 4:03:30 PM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
Children:
465abf
Parents:
16eb32
Message:

FIX: Bug that caused memory corruption in Vector::GetOneNormalVector() when a two component system was given

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/unittests/vectorunittest.cpp

    r16eb32 r6a314f  
    4343  notunit = Vector(0.,1.,1.);
    4444  two = Vector(2.,1.,0.);
     45  three = Vector(1,2,3);
    4546};
    4647
     
    185186  CPPUNIT_ASSERT_EQUAL( Vector(0.,1.,0.),  two.Projection(otherunit) );
    186187};
     188
     189/**
     190 * Unittest for operation with normals
     191 */
     192void VectorTest::NormalsTest(){
     193  Vector testVector;
     194  // the zero Vector should produce an error
     195  CPPUNIT_ASSERT(!testVector.GetOneNormalVector(zero));
     196
     197  // first one-component system
     198  CPPUNIT_ASSERT(testVector.GetOneNormalVector(unit));
     199  CPPUNIT_ASSERT(testVector.ScalarProduct(unit) < MYEPSILON);
     200
     201  // second one-component system
     202  CPPUNIT_ASSERT(testVector.GetOneNormalVector(otherunit));
     203  CPPUNIT_ASSERT(testVector.ScalarProduct(otherunit) < MYEPSILON);
     204
     205  // first two-component system
     206  CPPUNIT_ASSERT(testVector.GetOneNormalVector(notunit));
     207  CPPUNIT_ASSERT(testVector.ScalarProduct(notunit) < MYEPSILON);
     208
     209  // second two-component system
     210  CPPUNIT_ASSERT(testVector.GetOneNormalVector(two));
     211  CPPUNIT_ASSERT(testVector.ScalarProduct(two) < MYEPSILON);
     212
     213  // three component system
     214  CPPUNIT_ASSERT(testVector.GetOneNormalVector(three));
     215  CPPUNIT_ASSERT(testVector.ScalarProduct(three) < MYEPSILON);
     216}
    187217
    188218/** UnitTest for line intersections.
Note: See TracChangeset for help on using the changeset viewer.