diff --git a/src/osg/Matrixd.cpp b/src/osg/Matrixd.cpp index 946bdd209..515cf07ae 100644 --- a/src/osg/Matrixd.cpp +++ b/src/osg/Matrixd.cpp @@ -14,6 +14,14 @@ #include #include +#ifdef OSG_COMPILE_UNIT_TESTS + + +#include + +#include +#endif + // specialise Matrix_implementaiton to be Matrixd #define Matrix_implementation Matrixd @@ -35,3 +43,65 @@ void osg::Matrixd::set(const osg::Matrixf& rhs) // now compile up Matrix via Matrix_implementation #include "Matrix_implementation.cpp" + +//#if 1 +#ifdef OSG_COMPILE_UNIT_TESTS + +#include +#include + +#include + +namespace osg +{ + +class MatrixdTestFixture +{ +public: + + MatrixdTestFixture(); + + void testMatrixToQuat(const osgUtx::TestContext& ctx); + +private: + + // Some convenience variables for use in the tests + Matrixd m1_, m2_; + double l1_, l2_; + +}; + +MatrixdTestFixture::MatrixdTestFixture(): + m1_(0.3583681546368404100000000000000, -0.933580347769909500000000000000, 3.006977197034146200000000000000e-011, 000000000000000, + -0.933580347769909500000000000000, -0.3583681546368404100000000000000, -1.275368738108216700000000000000e-010, 000000000000000, + 1.298419676971558500000000000000e-010, 1.763260594230249800000000000000e-011, -0.9999999999999997800000000000000, 000000000000000, + -4.134153519264493800000000000000e-005, 8.473552245044272300000000000000e-008, 0.9999996934706840700000000000000, 100000000000000.0 ), + + m2_( 0.3583681546368407400000000000000, -0.9335803477699099500000000000000, 3.007582030796253300000000000000e-011, 000000000000000, + -0.9335803477699099500000000000000, -0.3583681546368407400000000000000, -1.265511449721884600000000000000e-010, 000000000000000, + 1.289238781567697100000000000000e-010, 1.727370550828948600000000000000e-011, -1.000000000000000400000000000000, 000000000000000, + -4.134153473360120600000000000000e-005, 8.473570190103158800000000000000e-008, 0.999999693471385400000000000000, 100000000000000.0), + l1_(1), + l2_(1) +{ +} + +void MatrixdTestFixture::testMatrixToQuat(const osgUtx::TestContext&) +{ + Quat q1,q2; + q1.set(m1_); + q2.set(m2_); + OSGUTX_TEST_F( q1.length() == l1_ ) + OSGUTX_TEST_F( q2.length() == l2_ ) +} + + +OSGUTX_BEGIN_TESTSUITE(Matrixd) + OSGUTX_ADD_TESTCASE(MatrixdTestFixture, testMatrixToQuat) +OSGUTX_END_TESTSUITE + +OSGUTX_AUTOREGISTER_TESTSUITE_AT(Matrixd, root.osg) + +} + +#endif