Moved UnitTestFramework from core osg lib into osgunittests example

This commit is contained in:
Robert Osfield 2006-12-19 17:06:59 +00:00
parent bcda53acb1
commit c9c2950759
12 changed files with 140 additions and 172 deletions

View File

@ -94,6 +94,14 @@ SOURCE=..\..\..\examples\osgunittests\osgunittests.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\examples\osgunittestsUnitTestFramework.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\examples\osgunittestsUnitTests_osg.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\examples\osgunittests\performance.cpp
# End Source File
# End Group
@ -102,7 +110,11 @@ SOURCE=..\..\..\examples\osgunittests\performance.cpp
# PROP Default_Filter ";h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\..\examples\performance\performance.h
SOURCE=..\..\..\examples\osgunittests\UnitTestFramework.h
# End Source File
# Begin Source File
SOURCE=..\..\..\examples\osgunittests\performance.h
# End Source File
# Begin Source File

View File

@ -1116,10 +1116,6 @@ SOURCE=..\..\Include\Osg\Uniform
# End Source File
# Begin Source File
SOURCE=..\..\Include\Osg\UnitTestFramework
# End Source File
# Begin Source File
SOURCE=..\..\Include\Osg\Vec2b
# End Source File
# Begin Source File

View File

@ -2358,8 +2358,6 @@
BE1181E205D63B8A00EB53E5 /* TextureRectangle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE1180CA05D63B8900EB53E5 /* TextureRectangle.cpp */; };
BE1181E305D63B8A00EB53E5 /* Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE1180CB05D63B8900EB53E5 /* Timer.cpp */; };
BE1181E405D63B8A00EB53E5 /* Transform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE1180CC05D63B8900EB53E5 /* Transform.cpp */; };
BE1181E505D63B8A00EB53E5 /* UnitTestFramework.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE1180CD05D63B8900EB53E5 /* UnitTestFramework.cpp */; };
BE1181E605D63B8A00EB53E5 /* Vec3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE1180CE05D63B8900EB53E5 /* Vec3.cpp */; };
BE1181E705D63B8A00EB53E5 /* Version.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE1180CF05D63B8900EB53E5 /* Version.cpp */; };
BE1181E805D63B8A00EB53E5 /* VertexProgram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE1180D005D63B8900EB53E5 /* VertexProgram.cpp */; };
BE1181E905D63B8A00EB53E5 /* Viewport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE1180D105D63B8900EB53E5 /* Viewport.cpp */; };
@ -2461,7 +2459,6 @@
BE11848305D70D1800EB53E5 /* Timer in Headers */ = {isa = PBXBuildFile; fileRef = BE11825005D63C0A00EB53E5 /* Timer */; settings = {ATTRIBUTES = (Public, ); }; };
BE11848405D70D1800EB53E5 /* Transform in Headers */ = {isa = PBXBuildFile; fileRef = BE11825105D63C0A00EB53E5 /* Transform */; settings = {ATTRIBUTES = (Public, ); }; };
BE11848505D70D1800EB53E5 /* TriangleFunctor in Headers */ = {isa = PBXBuildFile; fileRef = BE11825205D63C0A00EB53E5 /* TriangleFunctor */; settings = {ATTRIBUTES = (Public, ); }; };
BE11848705D70D1900EB53E5 /* UnitTestFramework in Headers */ = {isa = PBXBuildFile; fileRef = BE11825405D63C0A00EB53E5 /* UnitTestFramework */; settings = {ATTRIBUTES = (Public, ); }; };
BE11848805D70D1900EB53E5 /* Vec2 in Headers */ = {isa = PBXBuildFile; fileRef = BE11825505D63C0A00EB53E5 /* Vec2 */; settings = {ATTRIBUTES = (Public, ); }; };
BE11848905D70D1900EB53E5 /* Vec3 in Headers */ = {isa = PBXBuildFile; fileRef = BE11825605D63C0A00EB53E5 /* Vec3 */; settings = {ATTRIBUTES = (Public, ); }; };
BE11848A05D70D1900EB53E5 /* Vec4 in Headers */ = {isa = PBXBuildFile; fileRef = BE11825705D63C0A00EB53E5 /* Vec4 */; settings = {ATTRIBUTES = (Public, ); }; };
@ -6066,8 +6063,6 @@
BE1180CA05D63B8900EB53E5 /* TextureRectangle.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = TextureRectangle.cpp; path = ../../src/osg/TextureRectangle.cpp; sourceTree = SOURCE_ROOT; };
BE1180CB05D63B8900EB53E5 /* Timer.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = Timer.cpp; path = ../../src/osg/Timer.cpp; sourceTree = SOURCE_ROOT; };
BE1180CC05D63B8900EB53E5 /* Transform.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = Transform.cpp; path = ../../src/osg/Transform.cpp; sourceTree = SOURCE_ROOT; };
BE1180CD05D63B8900EB53E5 /* UnitTestFramework.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = UnitTestFramework.cpp; path = ../../src/osg/UnitTestFramework.cpp; sourceTree = SOURCE_ROOT; };
BE1180CE05D63B8900EB53E5 /* Vec3.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = Vec3.cpp; path = ../../src/osg/Vec3.cpp; sourceTree = SOURCE_ROOT; };
BE1180CF05D63B8900EB53E5 /* Version.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = Version.cpp; path = ../../src/osg/Version.cpp; sourceTree = SOURCE_ROOT; };
BE1180D005D63B8900EB53E5 /* VertexProgram.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = VertexProgram.cpp; path = ../../src/osg/VertexProgram.cpp; sourceTree = SOURCE_ROOT; };
BE1180D105D63B8900EB53E5 /* Viewport.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = Viewport.cpp; path = ../../src/osg/Viewport.cpp; sourceTree = SOURCE_ROOT; };
@ -6170,7 +6165,6 @@
BE11825005D63C0A00EB53E5 /* Timer */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp; fileEncoding = 30; name = Timer; path = ../../include/osg/Timer; sourceTree = SOURCE_ROOT; };
BE11825105D63C0A00EB53E5 /* Transform */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp; fileEncoding = 30; name = Transform; path = ../../include/osg/Transform; sourceTree = SOURCE_ROOT; };
BE11825205D63C0A00EB53E5 /* TriangleFunctor */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp; fileEncoding = 30; name = TriangleFunctor; path = ../../include/osg/TriangleFunctor; sourceTree = SOURCE_ROOT; };
BE11825405D63C0A00EB53E5 /* UnitTestFramework */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp; fileEncoding = 30; name = UnitTestFramework; path = ../../include/osg/UnitTestFramework; sourceTree = SOURCE_ROOT; };
BE11825505D63C0A00EB53E5 /* Vec2 */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp; fileEncoding = 30; name = Vec2; path = ../../include/osg/Vec2; sourceTree = SOURCE_ROOT; };
BE11825605D63C0A00EB53E5 /* Vec3 */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp; fileEncoding = 30; name = Vec3; path = ../../include/osg/Vec3; sourceTree = SOURCE_ROOT; };
BE11825705D63C0A00EB53E5 /* Vec4 */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp; fileEncoding = 30; name = Vec4; path = ../../include/osg/Vec4; sourceTree = SOURCE_ROOT; };
@ -10931,8 +10925,6 @@
BE1180CB05D63B8900EB53E5 /* Timer.cpp */,
BE1180CC05D63B8900EB53E5 /* Transform.cpp */,
009D9F9F081D7218001FA987 /* Uniform.cpp */,
BE1180CD05D63B8900EB53E5 /* UnitTestFramework.cpp */,
BE1180CE05D63B8900EB53E5 /* Vec3.cpp */,
BE1180CF05D63B8900EB53E5 /* Version.cpp */,
BE1180D005D63B8900EB53E5 /* VertexProgram.cpp */,
006E25450AC107DB00FBB48F /* View.cpp */,
@ -11090,7 +11082,6 @@
BE11825205D63C0A00EB53E5 /* TriangleFunctor */,
00CE2D40065BCD25003C8656 /* TriangleIndexFunctor */,
009D9F8F081D7181001FA987 /* Uniform */,
BE11825405D63C0A00EB53E5 /* UnitTestFramework */,
BE11825505D63C0A00EB53E5 /* Vec2 */,
0096C52009195F1100B255F2 /* Vec2b */,
008F443D06CBF87C00F4220C /* Vec2d */,
@ -12790,7 +12781,6 @@
BE11848505D70D1800EB53E5 /* TriangleFunctor in Headers */,
00CE2D67065BCD69003C8656 /* TriangleIndexFunctor in Headers */,
009D9FB9081D7392001FA987 /* Uniform in Headers */,
BE11848705D70D1900EB53E5 /* UnitTestFramework in Headers */,
BE11848805D70D1900EB53E5 /* Vec2 in Headers */,
008F444506CBF88200F4220C /* Vec2d in Headers */,
00C0453B06CC17ED008F84FE /* Vec2f in Headers */,
@ -18400,8 +18390,6 @@
BE1181E205D63B8A00EB53E5 /* TextureRectangle.cpp in Sources */,
BE1181E305D63B8A00EB53E5 /* Timer.cpp in Sources */,
BE1181E405D63B8A00EB53E5 /* Transform.cpp in Sources */,
BE1181E505D63B8A00EB53E5 /* UnitTestFramework.cpp in Sources */,
BE1181E605D63B8A00EB53E5 /* Vec3.cpp in Sources */,
BE1181E705D63B8A00EB53E5 /* Version.cpp in Sources */,
BE1181E805D63B8A00EB53E5 /* VertexProgram.cpp in Sources */,
BE1181E905D63B8A00EB53E5 /* Viewport.cpp in Sources */,

View File

@ -3,6 +3,8 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
performance.cpp\
UnitTestFramework.cpp\
UnitTests_osg.cpp\
osgunittests.cpp\
LIBS += -losgProducer -lProducer -losgText -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)

View File

@ -2,6 +2,9 @@ TOPDIR = ../..
include $(TOPDIR)/Make/makedefs
CXXFILES =\
performance.cpp\
UnitTestFramework.cpp\
UnitTests_osg.cpp\
osgunittests.cpp\
LIBS += -losgProducer -lProducer -losgText -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)

View File

@ -10,7 +10,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#include <osg/UnitTestFramework>
#include "UnitTestFramework.h"
#include <algorithm>

View File

@ -0,0 +1,120 @@
#include "UnitTestFramework.h"
#include <osg/Matrixd>
#include <osg/Vec3>
#include <sstream>
namespace osg
{
///////////////////////////////////////////////////////////////////////////////
//
// Matrixd Tests
//
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)
///////////////////////////////////////////////////////////////////////////////
//
// Vec3 Tests
//
class Vec3TestFixture
{
public:
Vec3TestFixture();
void testAddition(const osgUtx::TestContext& ctx);
void testSubtraction(const osgUtx::TestContext& ctx);
void testScalarMultiplication(const osgUtx::TestContext& ctx);
void testDotProduct(const osgUtx::TestContext& ctx);
private:
// Some convenience variables for use in the tests
Vec3 v1_, v2_, v3_;
};
Vec3TestFixture::Vec3TestFixture():
v1_(1.0f, 1.0f, 1.0f),
v2_(2.0f, 2.0f, 2.0f),
v3_(3.0f, 3.0f, 3.0f)
{
}
void Vec3TestFixture::testAddition(const osgUtx::TestContext&)
{
OSGUTX_TEST_F( v1_ + v2_ == v3_ )
}
void Vec3TestFixture::testSubtraction(const osgUtx::TestContext&)
{
OSGUTX_TEST_F( v3_ - v1_ == v2_ )
}
void Vec3TestFixture::testScalarMultiplication(const osgUtx::TestContext&)
{
OSGUTX_TEST_F( v1_ * 3 == v3_ )
}
void Vec3TestFixture::testDotProduct(const osgUtx::TestContext&)
{
}
OSGUTX_BEGIN_TESTSUITE(Vec3)
OSGUTX_ADD_TESTCASE(Vec3TestFixture, testAddition)
OSGUTX_ADD_TESTCASE(Vec3TestFixture, testSubtraction)
OSGUTX_ADD_TESTCASE(Vec3TestFixture, testScalarMultiplication)
OSGUTX_ADD_TESTCASE(Vec3TestFixture, testDotProduct)
OSGUTX_END_TESTSUITE
OSGUTX_AUTOREGISTER_TESTSUITE_AT(Vec3, root.osg)
}

View File

@ -1,4 +1,3 @@
#include <osg/UnitTestFramework>
#include <osg/ArgumentParser>
#include <osg/ApplicationUsage>
@ -6,6 +5,7 @@
#include <osg/Matrix>
#include <osg/io_utils>
#include "UnitTestFramework.h"
#include "performance.h"
#include <iostream>

View File

@ -111,8 +111,6 @@ CXXFILES =\
Timer.cpp\
Transform.cpp\
Uniform.cpp\
UnitTestFramework.cpp\
Vec3.cpp\
Version.cpp\
VertexProgram.cpp\
View.cpp\

View File

@ -14,14 +14,6 @@
#include <osg/Matrixd>
#include <osg/Matrixf>
#ifdef OSG_COMPILE_UNIT_TESTS
#include <osg/UnitTestFramework>
#include <sstream>
#endif
// specialise Matrix_implementaiton to be Matrixd
#define Matrix_implementation Matrixd
@ -44,64 +36,3 @@ 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 <osg/Vec3>
#include <osg/UnitTestFramework>
#include <sstream>
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

View File

@ -1,82 +0,0 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
// Vec3 is implemented entirely in the header. This .cpp file just
// contains utx test code
#ifdef OSG_COMPILE_UNIT_TESTS
#include <osg/Vec3>
#include <osg/UnitTestFramework>
#include <sstream>
namespace osg
{
class Vec3TestFixture
{
public:
Vec3TestFixture();
void testAddition(const osgUtx::TestContext& ctx);
void testSubtraction(const osgUtx::TestContext& ctx);
void testScalarMultiplication(const osgUtx::TestContext& ctx);
void testDotProduct(const osgUtx::TestContext& ctx);
private:
// Some convenience variables for use in the tests
Vec3 v1_, v2_, v3_;
};
Vec3TestFixture::Vec3TestFixture():
v1_(1.0f, 1.0f, 1.0f),
v2_(2.0f, 2.0f, 2.0f),
v3_(3.0f, 3.0f, 3.0f)
{
}
void Vec3TestFixture::testAddition(const osgUtx::TestContext&)
{
OSGUTX_TEST_F( v1_ + v2_ == v3_ )
}
void Vec3TestFixture::testSubtraction(const osgUtx::TestContext&)
{
OSGUTX_TEST_F( v3_ - v1_ == v2_ )
}
void Vec3TestFixture::testScalarMultiplication(const osgUtx::TestContext&)
{
OSGUTX_TEST_F( v1_ * 3 == v3_ )
}
void Vec3TestFixture::testDotProduct(const osgUtx::TestContext&)
{
}
OSGUTX_BEGIN_TESTSUITE(Vec3)
OSGUTX_ADD_TESTCASE(Vec3TestFixture, testAddition)
OSGUTX_ADD_TESTCASE(Vec3TestFixture, testSubtraction)
OSGUTX_ADD_TESTCASE(Vec3TestFixture, testScalarMultiplication)
OSGUTX_ADD_TESTCASE(Vec3TestFixture, testDotProduct)
OSGUTX_END_TESTSUITE
OSGUTX_AUTOREGISTER_TESTSUITE_AT(Vec3, root.osg)
}
#endif