forked from worldforge/ember
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Activate unit tests through CppUnit.
Start with a unit test for WF-to-Ogre unit conversions.
- Loading branch information
1 parent
7012283
commit 1d2d040
Showing
6 changed files
with
98 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,35 @@ | |||
#include "ConvertTestCase.h" | |||
|
|||
#include "components/ogre/Convert.h" | |||
|
|||
using namespace EmberOgre; | |||
using namespace WFMath; | |||
|
|||
namespace Ember | |||
{ | |||
void ConvertTestCase::testWFMathToOgre() | |||
{ | |||
Point<2> wfMathPoint2(10, 20); | |||
CPPUNIT_ASSERT(wfMathPoint2 == Convert::toWF(Convert::toOgre<Ogre::Vector2>(wfMathPoint2))); | |||
CPPUNIT_ASSERT(wfMathPoint2 == Convert::toWF<Point<2> >(Convert::toOgre<Ogre::Vector3>(wfMathPoint2))); | |||
|
|||
Point<3> wfMathPoint3(10, 20, 30); | |||
CPPUNIT_ASSERT(wfMathPoint3 == Convert::toWF<Point<3> >(Convert::toOgre(wfMathPoint3))); | |||
|
|||
Vector<2> wfMathVector2(10, 20); | |||
CPPUNIT_ASSERT(Point<2>(wfMathVector2) == Convert::toWF(Convert::toOgre(wfMathVector2))); | |||
|
|||
Vector<3> wfMathVector3(10, 20, 30); | |||
CPPUNIT_ASSERT(wfMathVector3 == Convert::toWF<Vector<3> >(Convert::toOgre(wfMathVector3))); | |||
|
|||
Quaternion wfQuaternion(1, 2.4f); | |||
CPPUNIT_ASSERT(wfQuaternion == Convert::toWF(Convert::toOgre(wfQuaternion))); | |||
|
|||
WFMath::AxisBox<3> wfAxisBox3(Point<3>(1,2,3), Point<3>(10, 20, 30)); | |||
CPPUNIT_ASSERT(wfAxisBox3 == Convert::toWF(Convert::toOgre(wfAxisBox3))); | |||
|
|||
WFMath::AxisBox<2> wfAxisBox2(Point<2>(1,2), Point<2>(10, 20)); | |||
CPPUNIT_ASSERT(wfAxisBox2 == Convert::toWF(Convert::toOgre(wfAxisBox2))); | |||
|
|||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,12 @@ | |||
#include <cppunit/extensions/HelperMacros.h> | |||
|
|||
namespace Ember { | |||
class ConvertTestCase : public CppUnit::TestFixture { | |||
CPPUNIT_TEST_SUITE(ConvertTestCase); | |||
CPPUNIT_TEST(testWFMathToOgre); | |||
CPPUNIT_TEST_SUITE_END(); | |||
|
|||
public: | |||
void testWFMathToOgre(); | |||
}; | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,5 +1,13 @@ | |||
noinst_LIBRARIES = libTestServices.a | |||
|
|||
INCLUDES = -I$(top_srcdir)/src | INCLUDES = -I$(top_srcdir)/src | ||
|
|
||
libTestServices_a_SOURCES = TestServices.cpp | if USE_CPPUNIT | ||
TESTS = TestServices | |||
check_PROGRAMS = $(TESTS) | |||
TestServices_SOURCES = TestServices.cpp ConvertTestCase.cpp | |||
|
|||
TestServices_CXXFLAGS = $(CPPUNIT_CFLAGS) | |||
TestServices_LDFLAGS = $(CPPUNIT_LIBS) | |||
|
|||
|
|||
noinst_HEADERS = TestServices.h ConvertTestCase.h | |||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,31 +1,20 @@ | |||
#ifdef USE_CPP_UNIT | |||
#include <cppunit/extensions/TestFactoryRegistry.h> | #include <cppunit/extensions/TestFactoryRegistry.h> | ||
#include <cppunit/ui/text/TestRunner.h> | #include <cppunit/ui/text/TestRunner.h> | ||
|
|
||
//#include "DataModelTest.h" | #include "ConvertTestCase.h" | ||
//#include "InputServiceTest.h" | //#include "InputServiceTest.h" | ||
//#include "StateManagerTest.h" | //#include "StateManagerTest.h" | ||
|
|
||
//CPPUNIT_TEST_SUITE_REGISTRATION( dime::DataModelTestCase ); | CPPUNIT_TEST_SUITE_REGISTRATION( Ember::ConvertTestCase); | ||
//CPPUNIT_TEST_SUITE_REGISTRATION( dime::InputServiceTestCase ); | //CPPUNIT_TEST_SUITE_REGISTRATION( dime::InputServiceTestCase ); | ||
//CPPUNIT_TEST_SUITE_REGISTRATION( dime::StateManagerTestCase ); | //CPPUNIT_TEST_SUITE_REGISTRATION( dime::StateManagerTestCase ); | ||
|
|
||
|
int main(int argc, char **argv) | ||
bool runTests() | |||
{ | |||
CppUnit::TextUi::TestRunner runner; | |||
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); | |||
runner.addTest( registry.makeTest() ); | |||
bool wasSucessful = runner.run( "", false ); | |||
|
|||
return wasSucessful; | |||
} | |||
|
|||
#else | |||
|
|||
bool runTests() | |||
{ | { | ||
return true; | CppUnit::TextUi::TestRunner runner; | ||
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); | |||
runner.addTest(registry.makeTest()); | |||
bool wasSuccessful = runner.run("", false); | |||
return !wasSuccessful; | |||
} | } | ||
|
|
||
#endif |