Commit 128f5a14 authored by cutealien's avatar cutealien

Replace asserts in tests with new macro assert_log.

This is done to allow all tests running through even when one has a problem. Otherwise people just comment-out the asserts. The macro will log file, line and assert-test to the tests.log.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4126 dfc29bdd-3216-0410-991c-e03cc46cb475
parent ccd125ed
Changes in 1.8 (??.??.2011) Changes in 1.8 (??.??.2011)
- replace asserts in tests with macro assert_log to allow running all tests through on problems.
- added IGUIElement::setName and IGUIElement::getName (similar to ISceneNode) - added IGUIElement::setName and IGUIElement::getName (similar to ISceneNode)
- CSceneCollisionManager::getScreenCoordinatesFrom3DPosition uses now getCurrentRenderTargetSize instead of getScreenSize so it can work with render textures. - CSceneCollisionManager::getScreenCoordinatesFrom3DPosition uses now getCurrentRenderTargetSize instead of getScreenSize so it can work with render textures.
......
This diff is collapsed.
...@@ -312,7 +312,7 @@ bool testSpecialZip(IFileSystem* fs, const char* archiveName, const char* filena ...@@ -312,7 +312,7 @@ bool testSpecialZip(IFileSystem* fs, const char* archiveName, const char* filena
logTestString("%s name: %s\n", fileList->isDirectory(f)?"Directory":"File", fileList->getFileName(f).c_str()); logTestString("%s name: %s\n", fileList->isDirectory(f)?"Directory":"File", fileList->getFileName(f).c_str());
logTestString("Full path: %s\n", fileList->getFullFileName(f).c_str()); logTestString("Full path: %s\n", fileList->getFullFileName(f).c_str());
} }
if (!fs->existFile(filename)) if (!fs->existFile(filename))
{ {
logTestString("existFile failed\n"); logTestString("existFile failed\n");
...@@ -429,14 +429,14 @@ bool testAddRemove(IFileSystem* fs, const io::path& archiveName) ...@@ -429,14 +429,14 @@ bool testAddRemove(IFileSystem* fs, const io::path& archiveName)
bool archiveReader() bool archiveReader()
{ {
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(1, 1)); IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(1, 1));
assert(device); assert_log(device);
if(!device) if(!device)
return false; return false;
io::IFileSystem * fs = device->getFileSystem (); io::IFileSystem * fs = device->getFileSystem ();
if ( !fs ) if ( !fs )
return false; return false;
bool ret = true; bool ret = true;
logTestString("Testing mount file.\n"); logTestString("Testing mount file.\n");
ret &= testArchive(fs, "media/file_with_path"); ret &= testArchive(fs, "media/file_with_path");
......
...@@ -10,7 +10,7 @@ bool b3dAnimation(void) ...@@ -10,7 +10,7 @@ bool b3dAnimation(void)
{ {
// Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions. // Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2d<u32>(160, 120), 32); IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2d<u32>(160, 120), 32);
assert(device); assert_log(device);
if (!device) if (!device)
return false; return false;
...@@ -18,14 +18,14 @@ bool b3dAnimation(void) ...@@ -18,14 +18,14 @@ bool b3dAnimation(void)
scene::ISceneManager * smgr = device->getSceneManager(); scene::ISceneManager * smgr = device->getSceneManager();
scene::ISkinnedMesh* mesh = (scene::ISkinnedMesh*)smgr->getMesh("../media/ninja.b3d"); scene::ISkinnedMesh* mesh = (scene::ISkinnedMesh*)smgr->getMesh("../media/ninja.b3d");
assert(mesh); assert_log(mesh);
bool result = false; bool result = false;
if (!mesh) if (!mesh)
return false; return false;
scene::IAnimatedMeshSceneNode* node1 = smgr->addAnimatedMeshSceneNode(mesh); scene::IAnimatedMeshSceneNode* node1 = smgr->addAnimatedMeshSceneNode(mesh);
assert(node1); assert_log(node1);
/** Verify that two skinned animated mesh scene nodes can use different frames of the skinned mesh */ /** Verify that two skinned animated mesh scene nodes can use different frames of the skinned mesh */
if(node1) if(node1)
...@@ -38,7 +38,7 @@ bool b3dAnimation(void) ...@@ -38,7 +38,7 @@ bool b3dAnimation(void)
} }
scene::IAnimatedMeshSceneNode* node2 = smgr->addAnimatedMeshSceneNode(mesh); scene::IAnimatedMeshSceneNode* node2 = smgr->addAnimatedMeshSceneNode(mesh);
assert(node2); assert_log(node2);
if(node2) if(node2)
{ {
node2->setPosition(core::vector3df(3, -3, 10)); node2->setPosition(core::vector3df(3, -3, 10));
......
...@@ -12,7 +12,7 @@ bool billboardSize(void) ...@@ -12,7 +12,7 @@ bool billboardSize(void)
{ {
// Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions. // Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2d<u32>(160, 120), 32); IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2d<u32>(160, 120), 32);
assert(device); assert_log(device);
if (!device) if (!device)
return false; return false;
...@@ -114,7 +114,7 @@ bool billboardOrientation(void) ...@@ -114,7 +114,7 @@ bool billboardOrientation(void)
{ {
// Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions. // Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2d<u32>(160, 120), 32); IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2d<u32>(160, 120), 32);
assert(device); assert_log(device);
if (!device) if (!device)
return false; return false;
......
...@@ -25,7 +25,7 @@ public: ...@@ -25,7 +25,7 @@ public:
logTestString("*** Error: collision point, expected %f %f %f\n", logTestString("*** Error: collision point, expected %f %f %f\n",
ExpectedCollisionPoint.X, ExpectedCollisionPoint.Y, ExpectedCollisionPoint.Z); ExpectedCollisionPoint.X, ExpectedCollisionPoint.Y, ExpectedCollisionPoint.Z);
expectedCollisionCallbackPositions = false; expectedCollisionCallbackPositions = false;
assert(false); assert_log(false);
} }
const vector3df & nodePosition = animator.getCollisionResultPosition(); const vector3df & nodePosition = animator.getCollisionResultPosition();
...@@ -34,14 +34,14 @@ public: ...@@ -34,14 +34,14 @@ public:
logTestString("*** Error: result position, expected %f %f %f\n", logTestString("*** Error: result position, expected %f %f %f\n",
ExpectedNodePosition.X, ExpectedNodePosition.Y, ExpectedNodePosition.Z); ExpectedNodePosition.X, ExpectedNodePosition.Y, ExpectedNodePosition.Z);
expectedCollisionCallbackPositions = false; expectedCollisionCallbackPositions = false;
assert(false); assert_log(false);
} }
if(animator.getTargetNode() != ExpectedTarget) if(animator.getTargetNode() != ExpectedTarget)
{ {
logTestString("*** Error: wrong node\n"); logTestString("*** Error: wrong node\n");
expectedCollisionCallbackPositions = false; expectedCollisionCallbackPositions = false;
assert(false); assert_log(false);
} }
return ConsumeNextCollision; return ConsumeNextCollision;
...@@ -73,7 +73,7 @@ private: ...@@ -73,7 +73,7 @@ private:
bool collisionResponseAnimator(void) bool collisionResponseAnimator(void)
{ {
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL); IrrlichtDevice * device = irr::createDevice(video::EDT_NULL);
assert(device); assert_log(device);
if(!device) if(!device)
return false; return false;
...@@ -140,14 +140,14 @@ bool collisionResponseAnimator(void) ...@@ -140,14 +140,14 @@ bool collisionResponseAnimator(void)
if(testNode1->getAbsolutePosition().X > -15.f) if(testNode1->getAbsolutePosition().X > -15.f)
{ {
logTestString("collisionResponseAnimator test node 1 wasn't stopped from moving.\n"); logTestString("collisionResponseAnimator test node 1 wasn't stopped from moving.\n");
assert(false); assert_log(false);
result = false; result = false;
} }
if(testNode2->getAbsolutePosition().X < 50.f) if(testNode2->getAbsolutePosition().X < 50.f)
{ {
logTestString("collisionResponseAnimator test node 2 was stopped from moving.\n"); logTestString("collisionResponseAnimator test node 2 was stopped from moving.\n");
assert(false); assert_log(false);
result = false; result = false;
} }
...@@ -167,7 +167,7 @@ bool collisionResponseAnimator(void) ...@@ -167,7 +167,7 @@ bool collisionResponseAnimator(void)
if(testNode2->getAbsolutePosition().X != -50.f) if(testNode2->getAbsolutePosition().X != -50.f)
{ {
logTestString("collisionResponseAnimator test node 2 was stopped from moving.\n"); logTestString("collisionResponseAnimator test node 2 was stopped from moving.\n");
assert(false); assert_log(false);
result = false; result = false;
} }
...@@ -184,7 +184,7 @@ bool collisionResponseAnimator(void) ...@@ -184,7 +184,7 @@ bool collisionResponseAnimator(void)
if(testNode2->getAbsolutePosition().X > -15.f) if(testNode2->getAbsolutePosition().X > -15.f)
{ {
logTestString("collisionResponseAnimator test node 2 moved too far.\n"); logTestString("collisionResponseAnimator test node 2 moved too far.\n");
assert(false); assert_log(false);
result = false; result = false;
} }
......
...@@ -62,7 +62,7 @@ bool cursorSetVisible(void) ...@@ -62,7 +62,7 @@ bool cursorSetVisible(void)
if(!result) if(!result)
{ {
logTestString("ERROR: cursorSetVisible received %d events.\n", moveTrapper.MouseMovesReceived); logTestString("ERROR: cursorSetVisible received %d events.\n", moveTrapper.MouseMovesReceived);
assert(false); assert_log(false);
} }
return result; return result;
......
...@@ -38,39 +38,39 @@ bool disambiguateTextures(void) ...@@ -38,39 +38,39 @@ bool disambiguateTextures(void)
IVideoDriver * driver = device->getVideoDriver(); IVideoDriver * driver = device->getVideoDriver();
ITexture * tex1 = driver->getTexture("../media/tools.png"); ITexture * tex1 = driver->getTexture("../media/tools.png");
assert(tex1); assert_log(tex1);
if(!tex1) if(!tex1)
logTestString("Unable to open ../media/tools.png\n"); logTestString("Unable to open ../media/tools.png\n");
ITexture * tex2 = driver->getTexture("../media/tools.png"); ITexture * tex2 = driver->getTexture("../media/tools.png");
assert(tex2); assert_log(tex2);
if(!tex2) if(!tex2)
logTestString("Unable to open ../media/tools.png\n"); logTestString("Unable to open ../media/tools.png\n");
IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png"); IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
assert(readFile); assert_log(readFile);
if(!readFile) if(!readFile)
logTestString("Unable to open ../media/tools.png\n"); logTestString("Unable to open ../media/tools.png\n");
ITexture * tex3 = driver->getTexture(readFile); ITexture * tex3 = driver->getTexture(readFile);
assert(tex3); assert_log(tex3);
if(!readFile) if(!readFile)
logTestString("Unable to create texture from ../media/tools.png\n"); logTestString("Unable to create texture from ../media/tools.png\n");
readFile->drop(); readFile->drop();
// All 3 of the above textures should be identical. // All 3 of the above textures should be identical.
assert(tex1 == tex2); assert_log(tex1 == tex2);
assert(tex1 == tex3); assert_log(tex1 == tex3);
stringc newWd = wd + "/empty/empty"; stringc newWd = wd + "/empty/empty";
bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd.c_str()); bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd.c_str());
assert(changed); assert_log(changed);
ITexture * tex4 = driver->getTexture("../../media/tools.png"); ITexture * tex4 = driver->getTexture("../../media/tools.png");
assert(tex4); assert_log(tex4);
if(!tex4) if(!tex4)
logTestString("Unable to open ../../media/tools.png\n"); logTestString("Unable to open ../../media/tools.png\n");
assert(tex1 != tex4); assert_log(tex1 != tex4);
// The working directory must be restored for the other tests to work. // The working directory must be restored for the other tests to work.
changed &= device->getFileSystem()->changeWorkingDirectoryTo(wd.c_str()); changed &= device->getFileSystem()->changeWorkingDirectoryTo(wd.c_str());
......
...@@ -15,7 +15,7 @@ bool enumerateImageManipulators(void) ...@@ -15,7 +15,7 @@ bool enumerateImageManipulators(void)
IVideoDriver* driver = device->getVideoDriver(); IVideoDriver* driver = device->getVideoDriver();
const char* filenames[] = const char* filenames[] =
{ {
"foo.bmp", "foo.bmp",
"foo.jpg", "foo.jpg",
...@@ -49,11 +49,11 @@ bool enumerateImageManipulators(void) ...@@ -49,11 +49,11 @@ bool enumerateImageManipulators(void)
for (i = 0; i < loaders; ++i) for (i = 0; i < loaders; ++i)
{ {
IImageLoader * loader = driver->getImageLoader(i); IImageLoader * loader = driver->getImageLoader(i);
if(!loader) if(!loader)
{ {
logTestString("Failed to get image loader %d\n", i); logTestString("Failed to get image loader %d\n", i);
assert(false); assert_log(false);
result = false; result = false;
} }
...@@ -67,7 +67,7 @@ bool enumerateImageManipulators(void) ...@@ -67,7 +67,7 @@ bool enumerateImageManipulators(void)
} }
IImageLoader * loader = driver->getImageLoader(i); IImageLoader * loader = driver->getImageLoader(i);
assert(loader == 0); assert_log(loader == 0);
if(loader) if(loader)
{ {
logTestString("Got a loader when none was expected (%d)\n", i); logTestString("Got a loader when none was expected (%d)\n", i);
...@@ -79,7 +79,7 @@ bool enumerateImageManipulators(void) ...@@ -79,7 +79,7 @@ bool enumerateImageManipulators(void)
if(!loaderForFilename[filename]) if(!loaderForFilename[filename])
{ {
logTestString("File type '%s' doesn't have a loader\n", filenames[filename]); logTestString("File type '%s' doesn't have a loader\n", filenames[filename]);
assert(false); assert_log(false);
result = false; result = false;
} }
} }
...@@ -88,11 +88,11 @@ bool enumerateImageManipulators(void) ...@@ -88,11 +88,11 @@ bool enumerateImageManipulators(void)
for (i = 0; i < writers; ++i) for (i = 0; i < writers; ++i)
{ {
IImageWriter * writer = driver->getImageWriter(i); IImageWriter * writer = driver->getImageWriter(i);
if(!writer) if(!writer)
{ {
logTestString("Failed to get image writer %d\n", i); logTestString("Failed to get image writer %d\n", i);
assert(false); assert_log(false);
result = false; result = false;
} }
...@@ -107,7 +107,7 @@ bool enumerateImageManipulators(void) ...@@ -107,7 +107,7 @@ bool enumerateImageManipulators(void)
} }
IImageWriter * writer = driver->getImageWriter(i); IImageWriter * writer = driver->getImageWriter(i);
assert(writer == 0); assert_log(writer == 0);
if(writer) if(writer)
{ {
logTestString("Got a writer when none was expected (%d)\n", i); logTestString("Got a writer when none was expected (%d)\n", i);
...@@ -120,7 +120,7 @@ bool enumerateImageManipulators(void) ...@@ -120,7 +120,7 @@ bool enumerateImageManipulators(void)
if(!writerForFilename[filename] && (filename<writersUntil)) if(!writerForFilename[filename] && (filename<writersUntil))
{ {
logTestString("File type '%s' doesn't have a writer\n", filenames[filename]); logTestString("File type '%s' doesn't have a writer\n", filenames[filename]);
assert(false); assert_log(false);
result = false; result = false;
} }
} }
......
...@@ -125,48 +125,48 @@ static bool testgetRelativeFilename(io::IFileSystem* fs) ...@@ -125,48 +125,48 @@ static bool testgetRelativeFilename(io::IFileSystem* fs)
bool filesystem(void) bool filesystem(void)
{ {
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(1, 1)); IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(1, 1));
assert(device); assert_log(device);
if(!device) if(!device)
return false; return false;
io::IFileSystem * fs = device->getFileSystem (); io::IFileSystem * fs = device->getFileSystem ();
if ( !fs ) if ( !fs )
return false; return false;
bool result = true; bool result = true;
io::path workingDir = device->getFileSystem()->getWorkingDirectory(); io::path workingDir = device->getFileSystem()->getWorkingDirectory();
io::path empty; io::path empty;
if ( fs->existFile(empty) ) if ( fs->existFile(empty) )
{ {
logTestString("Empty filename should not exist.\n"); logTestString("Empty filename should not exist.\n");
result = false; result = false;
} }
io::path newWd = workingDir + "/media"; io::path newWd = workingDir + "/media";
bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd); bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd);
assert(changed); assert_log(changed);
if ( fs->existFile(empty) ) if ( fs->existFile(empty) )
{ {
logTestString("Empty filename should not exist even in another workingdirectory.\n"); logTestString("Empty filename should not exist even in another workingdirectory.\n");
result = false; result = false;
} }
// The working directory must be restored for the other tests to work. // The working directory must be restored for the other tests to work.
changed = device->getFileSystem()->changeWorkingDirectoryTo(workingDir.c_str()); changed = device->getFileSystem()->changeWorkingDirectoryTo(workingDir.c_str());
assert(changed); assert_log(changed);
// adding a folder archive which just should not really change anything // adding a folder archive which just should not really change anything
device->getFileSystem()->addFileArchive( "./" ); device->getFileSystem()->addFileArchive( "./" );
if ( fs->existFile(empty) ) if ( fs->existFile(empty) )
{ {
logTestString("Empty filename should not exist in folder file archive.\n"); logTestString("Empty filename should not exist in folder file archive.\n");
result = false; result = false;
} }
// remove it again to not affect other tests // remove it again to not affect other tests
device->getFileSystem()->removeFileArchive( device->getFileSystem()->getFileArchiveCount() ); device->getFileSystem()->removeFileArchive( device->getFileSystem()->getFileArchiveCount() );
......
...@@ -16,7 +16,7 @@ bool guiDisabledMenu(void) ...@@ -16,7 +16,7 @@ bool guiDisabledMenu(void)
{ {
IrrlichtDevice *device = createDevice( video::EDT_BURNINGSVIDEO, IrrlichtDevice *device = createDevice( video::EDT_BURNINGSVIDEO,
dimension2d<u32>(160, 40), 32); dimension2d<u32>(160, 40), 32);
assert(device); assert_log(device);
if (!device) if (!device)
return false; return false;
......
...@@ -14,7 +14,7 @@ using namespace gui; ...@@ -14,7 +14,7 @@ using namespace gui;
static bool saveScene(void) static bool saveScene(void)
{ {
IrrlichtDevice *device = createDevice( EDT_NULL, dimension2d<u32>(160, 120), 32); IrrlichtDevice *device = createDevice( EDT_NULL, dimension2d<u32>(160, 120), 32);
assert(device); assert_log(device);
if (!device) if (!device)
return false; return false;
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "testUtils.h" #include "testUtils.h"
#include <irrlicht.h> #include <irrlicht.h>
#include <assert.h>
using namespace irr; using namespace irr;
using namespace core; using namespace core;
...@@ -12,7 +11,7 @@ core::map<int, int> countReferences; ...@@ -12,7 +11,7 @@ core::map<int, int> countReferences;
struct SDummy struct SDummy
{ {
SDummy(int a) : x(a) SDummy(int a) : x(a)
{ {
countReferences.insert(x,1); countReferences.insert(x,1);
} }
...@@ -22,7 +21,7 @@ struct SDummy ...@@ -22,7 +21,7 @@ struct SDummy
countReferences.insert(x,1); countReferences.insert(x,1);
} }
SDummy(const SDummy& other) SDummy(const SDummy& other)
{ {
x = other.x; x = other.x;
countReferences[x] = countReferences[x] + 1; countReferences[x] = countReferences[x] + 1;
...@@ -109,7 +108,7 @@ static bool testSwap() ...@@ -109,7 +108,7 @@ static bool testSwap()
result &= (array1 == copy2); result &= (array1 == copy2);
result &= (array2 == copy1); result &= (array2 == copy1);
assert( result ); assert_log( result );
return result; return result;
} }
......
#include "testUtils.h" #include "testUtils.h"
#include <irrlicht.h> #include <irrlicht.h>
#include <assert.h>
using namespace irr; using namespace irr;
using namespace core; using namespace core;
...@@ -53,7 +52,7 @@ static bool testSwap() ...@@ -53,7 +52,7 @@ static bool testSwap()
result &= compareLists<int>(list1, copy2); result &= compareLists<int>(list1, copy2);
result &= compareLists<int>(list2, copy1); result &= compareLists<int>(list2, copy1);
assert( result ); assert_log( result );
return result; return result;
} }
......
#include "testUtils.h" #include "testUtils.h"
#include <irrlicht.h> #include <irrlicht.h>
#include <assert.h>
using namespace irr; using namespace irr;
using namespace core; using namespace core;
...@@ -44,7 +43,7 @@ static bool testSwap() ...@@ -44,7 +43,7 @@ static bool testSwap()
result &= compareMaps(map1, copy2); result &= compareMaps(map1, copy2);
result &= compareMaps(map2, copy1); result &= compareMaps(map2, copy1);
assert( result ); assert_log( result );
return result; return result;
} }
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "testUtils.h" #include "testUtils.h"
#include <irrlicht.h> #include <irrlicht.h>
#include <assert.h>
using namespace irr; using namespace irr;
using namespace core; using namespace core;
...@@ -116,7 +115,7 @@ bool testAppendStringc() ...@@ -116,7 +115,7 @@ bool testAppendStringc()
// Test the functionality of irrString // Test the functionality of irrString
/** Validation is done with asserts() against expected results. */ /** Validation is done with assert_log() against expected results. */
bool testIrrString(void) bool testIrrString(void)
{ {
bool allExpected = true; bool allExpected = true;
...@@ -125,39 +124,39 @@ bool testIrrString(void) ...@@ -125,39 +124,39 @@ bool testIrrString(void)
{ {
// Check empty string // Check empty string
core::stringc empty; core::stringc empty;
assert(empty.size()==0); assert_log(empty.size()==0);
assert(empty[0]==0); assert_log(empty[0]==0);
assert(empty.c_str()!=0); assert_log(empty.c_str()!=0);
assert(*(empty.c_str())==0); assert_log(*(empty.c_str())==0);
// Assign content // Assign content
empty = "Test"; empty = "Test";
assert(empty.size()==4); assert_log(empty.size()==4);
assert(empty[0]=='T'); assert_log(empty[0]=='T');
assert(empty[3]=='t'); assert_log(empty[3]=='t');
assert(*(empty.c_str())=='T'); assert_log(*(empty.c_str())=='T');
//Assign empty string, should be same as in the beginning //Assign empty string, should be same as in the beginning
empty = ""; empty = "";
assert(empty.size()==0); assert_log(empty.size()==0);
assert(empty[0]==0); assert_log(empty[0]==0);
assert(*(empty.c_str())==0); assert_log(*(empty.c_str())==0);
} }
logTestString("Test stringw\n"); logTestString("Test stringw\n");
{ {
core::stringw empty; core::stringw empty;
assert(empty.size()==0); assert_log(empty.size()==0);
assert(empty[0]==0); assert_log(empty[0]==0);
assert(empty.c_str()!=0); assert_log(empty.c_str()!=0);
assert(*(empty.c_str())==0); assert_log(*(empty.c_str())==0);
empty = L"Test"; empty = L"Test";
assert(empty.size()==4); assert_log(empty.size()==4);
assert(empty[0]==L'T'); assert_log(empty[0]==L'T');
assert(empty[3]=='t'); assert_log(empty[3]=='t');
assert(*(empty.c_str())==L'T'); assert_log(*(empty.c_str())==L'T');
empty = L""; empty = L"";
assert(empty.size()==0); assert_log(empty.size()==0);
assert(empty[0]==0); assert_log(empty[0]==0);
assert(*(empty.c_str())==0); assert_log(*(empty.c_str())==0);
assert(allExpected &= testSplit()); assert_log(allExpected &= testSplit());
} }
allExpected &= testAppendStringc(); allExpected &= testAppendStringc();
......
...@@ -31,12 +31,12 @@ static bool runTestWithDriver(E_DRIVER_TYPE driverType) ...@@ -31,12 +31,12 @@ static bool runTestWithDriver(E_DRIVER_TYPE driverType)
bool result = true; bool result = true;
bool added = device->getFileSystem()->addFileArchive("../media/map-20kdm2.pk3"); bool added = device->getFileSystem()->addFileArchive("../media/map-20kdm2.pk3");
assert(added); assert_log(added);
if(added) if(added)
{ {
ISceneNode * node = smgr->addOctreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024); ISceneNode * node = smgr->addOctreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024);
assert(node); assert_log(node);
if (node) if (node)
{ {
......
...@@ -28,7 +28,7 @@ bool loadFromFileFolder(void) ...@@ -28,7 +28,7 @@ bool loadFromFileFolder(void)
u32 numTexs = driver->getTextureCount(); u32 numTexs = driver->getTextureCount();
ITexture * tex1 = driver->getTexture("../media/tools.png"); ITexture * tex1 = driver->getTexture("../media/tools.png");
assert(tex1); assert_log(tex1);
if(!tex1) if(!tex1)
logTestString("Unable to open ../media/tools.png\n"); logTestString("Unable to open ../media/tools.png\n");
if (driver->getTextureCount()!=numTexs+1) if (driver->getTextureCount()!=numTexs+1)
...@@ -38,7 +38,7 @@ bool loadFromFileFolder(void) ...@@ -38,7 +38,7 @@ bool loadFromFileFolder(void)
} }
IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png"); IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
assert(readFile); assert_log(readFile);
if(!readFile) if(!readFile)
logTestString("Unable to open ../media/tools.png\n"); logTestString("Unable to open ../media/tools.png\n");
if (driver->getTextureCount()!=numTexs+1) if (driver->getTextureCount()!=numTexs+1)
...@@ -48,7 +48,7 @@ bool loadFromFileFolder(void) ...@@ -48,7 +48,7 @@ bool loadFromFileFolder(void)
} }
ITexture * tex2 = driver->getTexture(readFile); ITexture * tex2 = driver->getTexture(readFile);
assert(tex2); assert_log(tex2);
if(!readFile) if(!readFile)
logTestString("Unable to create texture from ../media/tools.png\n"); logTestString("Unable to create texture from ../media/tools.png\n");
if (driver->getTextureCount()!=numTexs+1) if (driver->getTextureCount()!=numTexs+1)
...@@ -63,7 +63,7 @@ bool loadFromFileFolder(void) ...@@ -63,7 +63,7 @@ bool loadFromFileFolder(void)
device->getFileSystem()->addFileArchive( "../media/" ); device->getFileSystem()->addFileArchive( "../media/" );
ITexture * tex3 = driver->getTexture("tools.png"); ITexture * tex3 = driver->getTexture("tools.png");
assert(tex3); assert_log(tex3);
if(!tex3) if(!tex3)
logTestString("Unable to open tools.png\n"); logTestString("Unable to open tools.png\n");
if (driver->getTextureCount()!=numTexs+1) if (driver->getTextureCount()!=numTexs+1)
...@@ -73,7 +73,7 @@ bool loadFromFileFolder(void) ...@@ -73,7 +73,7 @@ bool loadFromFileFolder(void)
} }
ITexture * tex4 = driver->getTexture("tools.png"); ITexture * tex4 = driver->getTexture("tools.png");
assert(tex4); assert_log(tex4);
if(!tex4) if(!tex4)
logTestString("Unable to open tools.png\n"); logTestString("Unable to open tools.png\n");
if (driver->getTextureCount()!=numTexs+1) if (driver->getTextureCount()!=numTexs+1)
......
...@@ -21,30 +21,30 @@ bool identity(void) ...@@ -21,30 +21,30 @@ bool identity(void)
// Check default init // Check default init
result &= (m==core::IdentityMatrix); result &= (m==core::IdentityMatrix);
result &= (core::IdentityMatrix==m); result &= (core::IdentityMatrix==m);
assert(result); assert_log(result);
// Since the last test can be made with isDefinitelyIdentityMatrix we set it to false here // Since the last test can be made with isDefinitelyIdentityMatrix we set it to false here
m.setDefinitelyIdentityMatrix(false); m.setDefinitelyIdentityMatrix(false);
result &= (m==core::IdentityMatrix); result &= (m==core::IdentityMatrix);
result &= (core::IdentityMatrix==m); result &= (core::IdentityMatrix==m);
assert(result); assert_log(result);
// also equals should see this // also equals should see this
result &= m.equals(core::IdentityMatrix); result &= m.equals(core::IdentityMatrix);
result &= core::IdentityMatrix.equals(m); result &= core::IdentityMatrix.equals(m);
assert(result); assert_log(result);
// Check inequality // Check inequality
m[12]=5.f; m[12]=5.f;
result &= (m!=core::IdentityMatrix); result &= (m!=core::IdentityMatrix);
result &= (core::IdentityMatrix!=m); result &= (core::IdentityMatrix!=m);
result &= !m.equals(core::IdentityMatrix); result &= !m.equals(core::IdentityMatrix);
result &= !core::IdentityMatrix.equals(m); result &= !core::IdentityMatrix.equals(m);
assert(result); assert_log(result);
// Test multiplication // Test multiplication
result &= (m==(core::IdentityMatrix*m)); result &= (m==(core::IdentityMatrix*m));
result &= m.equals(core::IdentityMatrix*m); result &= m.equals(core::IdentityMatrix*m);
result &= (m==(m*core::IdentityMatrix)); result &= (m==(m*core::IdentityMatrix));
result &= m.equals(m*core::IdentityMatrix); result &= m.equals(m*core::IdentityMatrix);
assert(result); assert_log(result);
return result; return result;
} }
...@@ -59,30 +59,30 @@ bool transformations(void) ...@@ -59,30 +59,30 @@ bool transformations(void)
m *= s; m *= s;
m.setTranslation(core::vector3df(5,6,7)); m.setTranslation(core::vector3df(5,6,7));
result &= (core::vector3df(5,6,7).equals(m.getTranslation())); result &= (core::vector3df(5,6,7).equals(m.getTranslation()));
assert(result); assert_log(result);
result &= (core::vector3df(2,3,4).equals(m.getScale())); result &= (core::vector3df(2,3,4).equals(m.getScale()));
assert(result); assert_log(result);
core::vector3df newRotation = m.getRotationDegrees(); core::vector3df newRotation = m.getRotationDegrees();
result &= (core::vector3df(30,40,50).equals(newRotation, 0.000004f)); result &= (core::vector3df(30,40,50).equals(newRotation, 0.000004f));
assert(result); assert_log(result);
m.setRotationDegrees(vector3df(90.0001f, 270.85f, 180.0f)); m.setRotationDegrees(vector3df(90.0001f, 270.85f, 180.0f));
s.setRotationDegrees(vector3df(0,0, 0.860866f)); s.setRotationDegrees(vector3df(0,0, 0.860866f));
m *= s; m *= s;
newRotation = m.getRotationDegrees(); newRotation = m.getRotationDegrees();
result &= (core::vector3df(0,270,270).equals(newRotation, 0.0001f)); result &= (core::vector3df(0,270,270).equals(newRotation, 0.0001f));
assert(result); assert_log(result);
m.setRotationDegrees(vector3df(270.0f, 89.8264f, 0.000100879f)); m.setRotationDegrees(vector3df(270.0f, 89.8264f, 0.000100879f));
s.setRotationDegrees(vector3df(0,0, 0.189398f)); s.setRotationDegrees(vector3df(0,0, 0.189398f));
m *= s; m *= s;
newRotation = m.getRotationDegrees(); newRotation = m.getRotationDegrees();
result &= (core::vector3df(0,90,90).equals(newRotation, 0.0001f)); result &= (core::vector3df(0,90,90).equals(newRotation, 0.0001f));
assert(result); assert_log(result);
m.setRotationDegrees(vector3df(270.0f, 89.0602f, 359.999f)); m.setRotationDegrees(vector3df(270.0f, 89.0602f, 359.999f));
s.setRotationDegrees(vector3df(0,0, 0.949104f)); s.setRotationDegrees(vector3df(0,0, 0.949104f));
m *= s; m *= s;
newRotation = m.getRotationDegrees(); newRotation = m.getRotationDegrees();
result &= (core::vector3df(0,90,89.999f).equals(newRotation)); result &= (core::vector3df(0,90,89.999f).equals(newRotation));
assert(result); assert_log(result);
return result; return result;
} }
...@@ -102,14 +102,14 @@ bool rotations(void) ...@@ -102,14 +102,14 @@ bool rotations(void)
rot4.setRotationDegrees(core::vector3df(90,90,90)); rot4.setRotationDegrees(core::vector3df(90,90,90));
rot5 = rot3*rot2*rot1; rot5 = rot3*rot2*rot1;
result &= (rot4.equals(rot5, ROUNDING_ERROR_f32)); result &= (rot4.equals(rot5, ROUNDING_ERROR_f32));
assert(result); assert_log(result);
rot4.transformVect(vec1);rot5.transformVect(vec12); rot4.transformVect(vec1);rot5.transformVect(vec12);
rot4.transformVect(vec2);rot5.transformVect(vec22); rot4.transformVect(vec2);rot5.transformVect(vec22);
rot4.transformVect(vec3);rot5.transformVect(vec32); rot4.transformVect(vec3);rot5.transformVect(vec32);
result &= (vec1.equals(vec12)); result &= (vec1.equals(vec12));
result &= (vec2.equals(vec22)); result &= (vec2.equals(vec22));
result &= (vec3.equals(vec32)); result &= (vec3.equals(vec32));
assert(result); assert_log(result);
vec1.set(1,2,3);vec12.set(1,2,3); vec1.set(1,2,3);vec12.set(1,2,3);
vec2.set(-5,0,0);vec22.set(-5,0,0); vec2.set(-5,0,0);vec22.set(-5,0,0);
...@@ -120,14 +120,14 @@ bool rotations(void) ...@@ -120,14 +120,14 @@ bool rotations(void)
rot4.setRotationDegrees(core::vector3df(45,45,45)); rot4.setRotationDegrees(core::vector3df(45,45,45));
rot5 = rot3*rot2*rot1; rot5 = rot3*rot2*rot1;
result &= (rot4.equals(rot5, ROUNDING_ERROR_f32)); result &= (rot4.equals(rot5, ROUNDING_ERROR_f32));
assert(result); assert_log(result);
rot4.transformVect(vec1);rot5.transformVect(vec12); rot4.transformVect(vec1);rot5.transformVect(vec12);
rot4.transformVect(vec2);rot5.transformVect(vec22); rot4.transformVect(vec2);rot5.transformVect(vec22);
rot4.transformVect(vec3);rot5.transformVect(vec32); rot4.transformVect(vec3);rot5.transformVect(vec32);
result &= (vec1.equals(vec12)); result &= (vec1.equals(vec12));
result &= (vec2.equals(vec22)); result &= (vec2.equals(vec22));
result &= (vec3.equals(vec32)); result &= (vec3.equals(vec32));
assert(result); assert_log(result);
vec1.set(1,2,3);vec12.set(1,2,3); vec1.set(1,2,3);vec12.set(1,2,3);
vec2.set(-5,0,0);vec22.set(-5,0,0); vec2.set(-5,0,0);vec22.set(-5,0,0);
...@@ -138,7 +138,7 @@ bool rotations(void) ...@@ -138,7 +138,7 @@ bool rotations(void)
rot4.setRotationDegrees(core::vector3df(-60,-60,-60)); rot4.setRotationDegrees(core::vector3df(-60,-60,-60));
rot5 = rot3*rot2*rot1; rot5 = rot3*rot2*rot1;
result &= (rot4.equals(rot5, ROUNDING_ERROR_f32)); result &= (rot4.equals(rot5, ROUNDING_ERROR_f32));
assert(result); assert_log(result);
rot4.transformVect(vec1);rot5.transformVect(vec12); rot4.transformVect(vec1);rot5.transformVect(vec12);
rot4.transformVect(vec2);rot5.transformVect(vec22); rot4.transformVect(vec2);rot5.transformVect(vec22);
rot4.transformVect(vec3);rot5.transformVect(vec32); rot4.transformVect(vec3);rot5.transformVect(vec32);
...@@ -146,7 +146,7 @@ bool rotations(void) ...@@ -146,7 +146,7 @@ bool rotations(void)
result &= (vec2.equals(vec22)); result &= (vec2.equals(vec22));
// this one needs higher tolerance due to rounding issues // this one needs higher tolerance due to rounding issues
result &= (vec3.equals(vec32, 0.000002f)); result &= (vec3.equals(vec32, 0.000002f));
assert(result); assert_log(result);
vec1.set(1,2,3);vec12.set(1,2,3); vec1.set(1,2,3);vec12.set(1,2,3);
vec2.set(-5,0,0);vec22.set(-5,0,0); vec2.set(-5,0,0);vec22.set(-5,0,0);
...@@ -157,37 +157,37 @@ bool rotations(void) ...@@ -157,37 +157,37 @@ bool rotations(void)
rot4.setRotationDegrees(core::vector3df(113,-27,193)); rot4.setRotationDegrees(core::vector3df(113,-27,193));
rot5 = rot3*rot2*rot1; rot5 = rot3*rot2*rot1;
result &= (rot4.equals(rot5, ROUNDING_ERROR_f32)); result &= (rot4.equals(rot5, ROUNDING_ERROR_f32));
assert(result); assert_log(result);
rot4.transformVect(vec1);rot5.transformVect(vec12); rot4.transformVect(vec1);rot5.transformVect(vec12);
rot4.transformVect(vec2);rot5.transformVect(vec22); rot4.transformVect(vec2);rot5.transformVect(vec22);
rot4.transformVect(vec3);rot5.transformVect(vec32); rot4.transformVect(vec3);rot5.transformVect(vec32);
// these ones need higher tolerance due to rounding issues // these ones need higher tolerance due to rounding issues
result &= (vec1.equals(vec12, 0.000002f)); result &= (vec1.equals(vec12, 0.000002f));
assert(result); assert_log(result);
result &= (vec2.equals(vec22)); result &= (vec2.equals(vec22));
assert(result); assert_log(result);
result &= (vec3.equals(vec32, 0.000002f)); result &= (vec3.equals(vec32, 0.000002f));
assert(result); assert_log(result);
rot1.setRotationDegrees(core::vector3df(0,0,34)); rot1.setRotationDegrees(core::vector3df(0,0,34));
rot2.setRotationDegrees(core::vector3df(0,43,0)); rot2.setRotationDegrees(core::vector3df(0,43,0));
vec1=(rot2*rot1).getRotationDegrees(); vec1=(rot2*rot1).getRotationDegrees();
result &= (vec1.equals(core::vector3df(27.5400505f, 34.4302292f, 42.6845398f), 0.000002f)); result &= (vec1.equals(core::vector3df(27.5400505f, 34.4302292f, 42.6845398f), 0.000002f));
assert(result); assert_log(result);
// corner cases // corner cases
rot1.setRotationDegrees(irr::core::vector3df(180.0f, 0.f, 0.f)); rot1.setRotationDegrees(irr::core::vector3df(180.0f, 0.f, 0.f));
vec1=rot1.getRotationDegrees(); vec1=rot1.getRotationDegrees();
result &= (vec1.equals(core::vector3df(180.0f, 0.f, 0.f), 0.000002f)); result &= (vec1.equals(core::vector3df(180.0f, 0.f, 0.f), 0.000002f));
assert(result); assert_log(result);
rot1.setRotationDegrees(irr::core::vector3df(0.f, 180.0f, 0.f)); rot1.setRotationDegrees(irr::core::vector3df(0.f, 180.0f, 0.f));
vec1=rot1.getRotationDegrees(); vec1=rot1.getRotationDegrees();
result &= (vec1.equals(core::vector3df(180.0f, 360, 180.0f), 0.000002f)); result &= (vec1.equals(core::vector3df(180.0f, 360, 180.0f), 0.000002f));
assert(result); assert_log(result);
rot1.setRotationDegrees(irr::core::vector3df(0.f, 0.f, 180.0f)); rot1.setRotationDegrees(irr::core::vector3df(0.f, 0.f, 180.0f));
vec1=rot1.getRotationDegrees(); vec1=rot1.getRotationDegrees();
result &= (vec1.equals(core::vector3df(0.f, 0.f, 180.0f), 0.000002f)); result &= (vec1.equals(core::vector3df(0.f, 0.f, 180.0f), 0.000002f));
assert(result); assert_log(result);
rot1.makeIdentity(); rot1.makeIdentity();
rot1.setRotationDegrees(core::vector3df(270.f,0,0)); rot1.setRotationDegrees(core::vector3df(270.f,0,0));
...@@ -195,7 +195,7 @@ bool rotations(void) ...@@ -195,7 +195,7 @@ bool rotations(void)
rot2.setRotationDegrees(core::vector3df(-90.f,0,0)); rot2.setRotationDegrees(core::vector3df(-90.f,0,0));
vec1=(rot1*rot2).getRotationDegrees(); vec1=(rot1*rot2).getRotationDegrees();
result &= (vec1.equals(core::vector3df(180.f, 0.f, 0.0f))); result &= (vec1.equals(core::vector3df(180.f, 0.f, 0.0f)));
assert(result); assert_log(result);
return result; return result;
} }
......
...@@ -10,13 +10,13 @@ using namespace irr; ...@@ -10,13 +10,13 @@ using namespace irr;
bool meshLoaders(void) bool meshLoaders(void)
{ {
IrrlichtDevice *device = createDevice(video::EDT_NULL, core::dimension2d<u32>(160, 120), 32); IrrlichtDevice *device = createDevice(video::EDT_NULL, core::dimension2d<u32>(160, 120), 32);
assert(device); assert_log(device);
if (!device) if (!device)
return false; return false;
scene::ISceneManager * smgr = device->getSceneManager(); scene::ISceneManager * smgr = device->getSceneManager();
scene::IAnimatedMesh* mesh = smgr->getMesh("../media/ninja.b3d"); scene::IAnimatedMesh* mesh = smgr->getMesh("../media/ninja.b3d");
assert(mesh); assert_log(mesh);
bool result = (mesh != 0); bool result = (mesh != 0);
......
...@@ -15,7 +15,7 @@ bool meshTransform(void) ...@@ -15,7 +15,7 @@ bool meshTransform(void)
{ {
// Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions. // Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
IrrlichtDevice *device = createDevice(EDT_BURNINGSVIDEO, dimension2d<u32>(160, 120), 32); IrrlichtDevice *device = createDevice(EDT_BURNINGSVIDEO, dimension2d<u32>(160, 120), 32);
assert(device); assert_log(device);
if (!device) if (!device)
return false; return false;
...@@ -25,7 +25,7 @@ bool meshTransform(void) ...@@ -25,7 +25,7 @@ bool meshTransform(void)
IMeshSceneNode* node1 = smgr->addCubeSceneNode(50); IMeshSceneNode* node1 = smgr->addCubeSceneNode(50);
IAnimatedMesh* amesh = smgr->getMesh("../media/sydney.md2"); IAnimatedMesh* amesh = smgr->getMesh("../media/sydney.md2");
IAnimatedMesh* smesh = smgr->getMesh("../media/ninja.b3d"); IAnimatedMesh* smesh = smgr->getMesh("../media/ninja.b3d");
assert(node1 && amesh && smesh); assert_log(node1 && amesh && smesh);
bool result = false; bool result = false;
if (!node1 || !amesh || !smesh) if (!node1 || !amesh || !smesh)
...@@ -35,7 +35,7 @@ bool meshTransform(void) ...@@ -35,7 +35,7 @@ bool meshTransform(void)
node1->setDebugDataVisible(scene::EDS_BBOX_ALL); node1->setDebugDataVisible(scene::EDS_BBOX_ALL);
IMeshSceneNode* node2 = smgr->addMeshSceneNode(amesh->getMesh(10)); IMeshSceneNode* node2 = smgr->addMeshSceneNode(amesh->getMesh(10));
assert(node2); assert_log(node2);
if (!node2) if (!node2)
return false; return false;
...@@ -45,7 +45,7 @@ bool meshTransform(void) ...@@ -45,7 +45,7 @@ bool meshTransform(void)
node2->setMaterialFlag(EMF_LIGHTING, false); node2->setMaterialFlag(EMF_LIGHTING, false);
IMeshSceneNode* node3 = smgr->addMeshSceneNode(smesh->getMesh(10)); IMeshSceneNode* node3 = smgr->addMeshSceneNode(smesh->getMesh(10));
assert(node3); assert_log(node3);
if (!node3) if (!node3)
return false; return false;
......
...@@ -38,7 +38,7 @@ static bool transformPlane(const vector3df & point, const vector3df & normal, ...@@ -38,7 +38,7 @@ static bool transformPlane(const vector3df & point, const vector3df & normal,
if(!sloppyComparePlanes(plane, expected)) if(!sloppyComparePlanes(plane, expected))
{ {
logTestString("Unexpected result\n"); logTestString("Unexpected result\n");
assert(false); assert_log(false);
return false; return false;
} }
...@@ -57,12 +57,12 @@ static bool drawScaledOctree(void) ...@@ -57,12 +57,12 @@ static bool drawScaledOctree(void)
ISceneManager * smgr = device->getSceneManager(); ISceneManager * smgr = device->getSceneManager();
bool added = device->getFileSystem()->addFileArchive("../media/map-20kdm2.pk3"); bool added = device->getFileSystem()->addFileArchive("../media/map-20kdm2.pk3");
assert(added); assert_log(added);
if(added) if(added)
{ {
ISceneNode * node = smgr->addOctreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024); ISceneNode * node = smgr->addOctreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024);
assert(node); assert_log(node);
if (node) if (node)
{ {
......
...@@ -20,12 +20,12 @@ class CustomAnimator : public ISceneNodeAnimator ...@@ -20,12 +20,12 @@ class CustomAnimator : public ISceneNodeAnimator
/** Test that a custom animator can remove itself cleanly from an ISceneNode during its /** Test that a custom animator can remove itself cleanly from an ISceneNode during its
* own animateNode() loop. * own animateNode() loop.
* http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=32271 */ * http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=32271 */
bool removeCustomAnimator(void) bool removeCustomAnimator(void)
{ {
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2du(160, 120)); IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2du(160, 120));
assert(device); assert_log(device);
if(!device) if(!device)
return false; return false;
...@@ -40,7 +40,7 @@ bool removeCustomAnimator(void) ...@@ -40,7 +40,7 @@ bool removeCustomAnimator(void)
// This should result in both custom animators being removed and // This should result in both custom animators being removed and
// deleted cleanly, without a crash. // deleted cleanly, without a crash.
node->OnAnimate(0); node->OnAnimate(0);
device->closeDevice(); device->closeDevice();
device->run(); device->run();
device->drop(); device->drop();
......
...@@ -78,7 +78,7 @@ static bool testGetCollisionResultPosition(IrrlichtDevice * device, ...@@ -78,7 +78,7 @@ static bool testGetCollisionResultPosition(IrrlichtDevice * device,
result = false; result = false;
} }
assert(result); assert_log(result);
cubeSelector->drop(); cubeSelector->drop();
smgr->clear(); smgr->clear();
...@@ -229,7 +229,7 @@ static bool testGetSceneNodeFromScreenCoordinatesBB(IrrlichtDevice * device, ...@@ -229,7 +229,7 @@ static bool testGetSceneNodeFromScreenCoordinatesBB(IrrlichtDevice * device,
logTestString("A node was hit when none was expected.\n"); logTestString("A node was hit when none was expected.\n");
result = false; result = false;
} }
assert(result); assert_log(result);
smgr->clear(); smgr->clear();
...@@ -273,7 +273,7 @@ static bool getScaledPickedNodeBB(IrrlichtDevice * device, ...@@ -273,7 +273,7 @@ static bool getScaledPickedNodeBB(IrrlichtDevice * device,
else if(hit == middleTarget) else if(hit == middleTarget)
logTestString("getSceneNodeFromRayBB() hit the middle (scaled) target.\n"); logTestString("getSceneNodeFromRayBB() hit the middle (scaled) target.\n");
assert(result); assert_log(result);
smgr->clear(); smgr->clear();
...@@ -286,10 +286,10 @@ static bool IntersectBox(const core::vector3df& origin, const core::vector3df& d ...@@ -286,10 +286,10 @@ static bool IntersectBox(const core::vector3df& origin, const core::vector3df& d
{ {
core::vector3df minDist = (box.MinEdge - origin)/dir; core::vector3df minDist = (box.MinEdge - origin)/dir;
core::vector3df maxDist = (box.MaxEdge - origin)/dir; core::vector3df maxDist = (box.MaxEdge - origin)/dir;
core::vector3df realMin(core::min_(minDist.X, maxDist.X),core::min_(minDist.Y, maxDist.Y),core::min_(minDist.Z, maxDist.Z)); core::vector3df realMin(core::min_(minDist.X, maxDist.X),core::min_(minDist.Y, maxDist.Y),core::min_(minDist.Z, maxDist.Z));
core::vector3df realMax(core::max_(minDist.X, maxDist.X),core::max_(minDist.Y, maxDist.Y),core::max_(minDist.Z, maxDist.Z)); core::vector3df realMax(core::max_(minDist.X, maxDist.X),core::max_(minDist.Y, maxDist.Y),core::max_(minDist.Z, maxDist.Z));
f32 minmax = core::min_(realMax.X, realMax.Y, realMax.Z); f32 minmax = core::min_(realMax.X, realMax.Y, realMax.Z);
// nearest distance to intersection // nearest distance to intersection
f32 maxmin = core::max_(realMin.X, realMin.Y, realMin.Z); f32 maxmin = core::max_(realMin.X, realMin.Y, realMin.Z);
...@@ -364,7 +364,7 @@ static bool checkBBoxIntersection(IrrlichtDevice * device, ...@@ -364,7 +364,7 @@ static bool checkBBoxIntersection(IrrlichtDevice * device,
logTestString("Consider replacement of bbox intersection test.\n"); logTestString("Consider replacement of bbox intersection test.\n");
result &= (hits==0); result &= (hits==0);
assert(result); assert_log(result);
// second round without any hits, so check opposite direction // second round without any hits, so check opposite direction
camera->setTarget(core::vector3df(80.f, 80.f, 80.f)); camera->setTarget(core::vector3df(80.f, 80.f, 80.f));
} }
...@@ -445,7 +445,7 @@ static bool compareGetSceneNodeFromRayBBWithBBIntersectsWithLine(IrrlichtDevice ...@@ -445,7 +445,7 @@ static bool compareGetSceneNodeFromRayBBWithBBIntersectsWithLine(IrrlichtDevice
} }
} }
assert(result); assert_log(result);
smgr->clear(); smgr->clear();
...@@ -457,7 +457,7 @@ static bool compareGetSceneNodeFromRayBBWithBBIntersectsWithLine(IrrlichtDevice ...@@ -457,7 +457,7 @@ static bool compareGetSceneNodeFromRayBBWithBBIntersectsWithLine(IrrlichtDevice
bool sceneCollisionManager(void) bool sceneCollisionManager(void)
{ {
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(160, 120)); IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(160, 120));
assert(device); assert_log(device);
if(!device) if(!device)
return false; return false;
......
...@@ -11,7 +11,7 @@ using namespace scene; ...@@ -11,7 +11,7 @@ using namespace scene;
bool sceneNodeAnimator(void) bool sceneNodeAnimator(void)
{ {
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(160, 120)); IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(160, 120));
assert(device); assert_log(device);
if(!device) if(!device)
return false; return false;
...@@ -108,7 +108,7 @@ bool sceneNodeAnimator(void) ...@@ -108,7 +108,7 @@ bool sceneNodeAnimator(void)
if(!result) if(!result)
{ {
logTestString("One or more animators has a bad hasFinished() state\n."); logTestString("One or more animators has a bad hasFinished() state\n.");
assert(false); assert_log(false);
} }
return result; return result;
......
...@@ -19,7 +19,7 @@ bool testDimension2d(void) ...@@ -19,7 +19,7 @@ bool testDimension2d(void)
if(dimension != dimension2df(300.f, -100.f)) if(dimension != dimension2df(300.f, -100.f))
{ {
logTestString("dimension2df != produced unexpected result.\n"); logTestString("dimension2df != produced unexpected result.\n");
assert(false); assert_log(false);
return false; return false;
} }
...@@ -27,7 +27,7 @@ bool testDimension2d(void) ...@@ -27,7 +27,7 @@ bool testDimension2d(void)
if(dimension != dimension2df(100.f, 100.f)) if(dimension != dimension2df(100.f, 100.f))
{ {
logTestString("dimension2df -= produced unexpected result.\n"); logTestString("dimension2df -= produced unexpected result.\n");
assert(false); assert_log(false);
return false; return false;
} }
......
...@@ -114,7 +114,7 @@ static bool testLines(line2df const & line1, ...@@ -114,7 +114,7 @@ static bool testLines(line2df const & line1,
} }
// Test the functionality of line2d>T>::intersectWith(). // Test the functionality of line2d>T>::intersectWith().
/** Validation is done with asserts() against expected results. */ /** Validation is done with assert_log() against expected results. */
bool line2dIntersectWith(void) bool line2dIntersectWith(void)
{ {
bool allExpected = true; bool allExpected = true;
...@@ -123,146 +123,146 @@ bool line2dIntersectWith(void) ...@@ -123,146 +123,146 @@ bool line2dIntersectWith(void)
allExpected &= testLines(line2df(vector2df(1,1),vector2df(1,3)), allExpected &= testLines(line2df(vector2df(1,1),vector2df(1,3)),
line2df(vector2df(0,2),vector2df(2,2)), line2df(vector2df(0,2),vector2df(2,2)),
true, vector2df(1,2)); true, vector2df(1,2));
assert(allExpected); assert_log(allExpected);
// Crossing lines, both diagonal // Crossing lines, both diagonal
allExpected &= testLines(line2df(vector2df(0,0),vector2df(2,2)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(2,2)),
line2df(vector2df(0,2),vector2df(2,0)), line2df(vector2df(0,2),vector2df(2,0)),
true, vector2df(1,1)); true, vector2df(1,1));
assert(allExpected); assert_log(allExpected);
// Non-crossing lines, horizontal and vertical // Non-crossing lines, horizontal and vertical
allExpected &= testLines(line2df(vector2df(1,1),vector2df(1,3)), allExpected &= testLines(line2df(vector2df(1,1),vector2df(1,3)),
line2df(vector2df(0,4),vector2df(2,4)), line2df(vector2df(0,4),vector2df(2,4)),
false, vector2df()); false, vector2df());
assert(allExpected); assert_log(allExpected);
// Non-crossing lines, both diagonal // Non-crossing lines, both diagonal
allExpected &= testLines(line2df(vector2df(0,0),vector2df(2,2)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(2,2)),
line2df(vector2df(3,4),vector2df(4,3)), line2df(vector2df(3,4),vector2df(4,3)),
false, vector2df()); false, vector2df());
assert(allExpected); assert_log(allExpected);
// Meeting at a common point // Meeting at a common point
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
line2df(vector2df(1,0),vector2df(2,0)), line2df(vector2df(1,0),vector2df(2,0)),
true, vector2df(1,0)); true, vector2df(1,0));
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
line2df(vector2df(1,0),vector2df(0,1)), line2df(vector2df(1,0),vector2df(0,1)),
true, vector2df(1,0)); true, vector2df(1,0));
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
line2df(vector2df(1,0),vector2df(0,-1)), line2df(vector2df(1,0),vector2df(0,-1)),
true, vector2df(1,0)); true, vector2df(1,0));
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
line2df(vector2df(0,1),vector2df(1,1)), line2df(vector2df(0,1),vector2df(1,1)),
true, vector2df(0,1)); true, vector2df(0,1));
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
line2df(vector2df(0,1),vector2df(1,-1)), line2df(vector2df(0,1),vector2df(1,-1)),
true, vector2df(0,1)); true, vector2df(0,1));
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
line2df(vector2df(0,1),vector2df(0,2)), line2df(vector2df(0,1),vector2df(0,2)),
true, vector2df(0,1)); true, vector2df(0,1));
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
line2df(vector2df(1,0),vector2df(2,0)), line2df(vector2df(1,0),vector2df(2,0)),
true, vector2df(1,0)); true, vector2df(1,0));
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,1)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,1)),
line2df(vector2df(1,1),vector2df(0,2)), line2df(vector2df(1,1),vector2df(0,2)),
true, vector2df(1,1)); true, vector2df(1,1));
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,1)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,1)),
line2df(vector2df(1,1),vector2df(2,0)), line2df(vector2df(1,1),vector2df(2,0)),
true, vector2df(1,1)); true, vector2df(1,1));
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,1)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,1)),
line2df(vector2df(1,1),vector2df(2,2)), line2df(vector2df(1,1),vector2df(2,2)),
true, vector2df(1,1)); true, vector2df(1,1));
assert(allExpected); assert_log(allExpected);
// Parallel lines, no intersection // Parallel lines, no intersection
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
line2df(vector2df(0,1),vector2df(1,1)), line2df(vector2df(0,1),vector2df(1,1)),
false, vector2df()); false, vector2df());
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
line2df(vector2df(1,0),vector2df(1,1)), line2df(vector2df(1,0),vector2df(1,1)),
false, vector2df()); false, vector2df());
assert(allExpected); assert_log(allExpected);
// Non parallel lines, no intersection // Non parallel lines, no intersection
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
line2df(vector2df(0,1),vector2df(0,2)), line2df(vector2df(0,1),vector2df(0,2)),
false, vector2df()); false, vector2df());
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
line2df(vector2df(1,0),vector2df(2,0)), line2df(vector2df(1,0),vector2df(2,0)),
false, vector2df()); false, vector2df());
assert(allExpected); assert_log(allExpected);
// Coincident (and thus parallel) lines // Coincident (and thus parallel) lines
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
line2df(vector2df(0,0),vector2df(1,0)), line2df(vector2df(0,0),vector2df(1,0)),
true, vector2df(0,0)); true, vector2df(0,0));
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(2,0),vector2df(0,2)), allExpected &= testLines(line2df(vector2df(2,0),vector2df(0,2)),
line2df(vector2df(2,0),vector2df(0,2)), line2df(vector2df(2,0),vector2df(0,2)),
true, vector2df(2,0)); true, vector2df(2,0));
assert(allExpected); assert_log(allExpected);
// Two segments of the same unlimited line, but no intersection // Two segments of the same unlimited line, but no intersection
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,1)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,1)),
line2df(vector2df(2,2),vector2df(3,3)), line2df(vector2df(2,2),vector2df(3,3)),
false, vector2df()); false, vector2df());
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
line2df(vector2df(2,0),vector2df(3,0)), line2df(vector2df(2,0),vector2df(3,0)),
false, vector2df()); false, vector2df());
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
line2df(vector2df(0,2),vector2df(0,3)), line2df(vector2df(0,2),vector2df(0,3)),
false, vector2df()); false, vector2df());
assert(allExpected); assert_log(allExpected);
// Overlapping parallel lines // Overlapping parallel lines
allExpected &= testLines(line2df(vector2df(1,0),vector2df(2,0)), allExpected &= testLines(line2df(vector2df(1,0),vector2df(2,0)),
line2df(vector2df(0,0),vector2df(3,0)), line2df(vector2df(0,0),vector2df(3,0)),
true, vector2df(1.5f, 0)); true, vector2df(1.5f, 0));
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,1),vector2df(0,2)), allExpected &= testLines(line2df(vector2df(0,1),vector2df(0,2)),
line2df(vector2df(0,0),vector2df(0,3)), line2df(vector2df(0,0),vector2df(0,3)),
true, vector2df(0, 1.5f)); true, vector2df(0, 1.5f));
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(1,0),vector2df(2,0)), allExpected &= testLines(line2df(vector2df(1,0),vector2df(2,0)),
line2df(vector2df(0,0),vector2df(3,0)), line2df(vector2df(0,0),vector2df(3,0)),
true, vector2df(1.5f, 0)); true, vector2df(1.5f, 0));
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,1),vector2df(0,2)), allExpected &= testLines(line2df(vector2df(0,1),vector2df(0,2)),
line2df(vector2df(0,0),vector2df(0,3)), line2df(vector2df(0,0),vector2df(0,3)),
true, vector2df(0, 1.5f)); true, vector2df(0, 1.5f));
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(1,1),vector2df(2,2)), allExpected &= testLines(line2df(vector2df(1,1),vector2df(2,2)),
line2df(vector2df(0,0),vector2df(3,3)), line2df(vector2df(0,0),vector2df(3,3)),
true, vector2df(1.5f, 1.5f)); true, vector2df(1.5f, 1.5f));
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(1,2),vector2df(2,1)), allExpected &= testLines(line2df(vector2df(1,2),vector2df(2,1)),
line2df(vector2df(0,3),vector2df(3,0)), line2df(vector2df(0,3),vector2df(3,0)),
true, vector2df(1.5f, 1.5f)); true, vector2df(1.5f, 1.5f));
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(10,8)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(10,8)),
line2df(vector2df(2.5f,2.0f),vector2df(5.0f,4.0f)), line2df(vector2df(2.5f,2.0f),vector2df(5.0f,4.0f)),
true, vector2df(3.75f, 3.0f)); true, vector2df(3.75f, 3.0f));
assert(allExpected); assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(2000,1000)), allExpected &= testLines(line2df(vector2df(0,0),vector2df(2000,1000)),
line2df(vector2df(2,1),vector2df(2.2f,1.4f)), line2df(vector2df(2,1),vector2df(2.2f,1.4f)),
true, vector2df(2.0f, 1.0f)); true, vector2df(2.0f, 1.0f));
assert(allExpected); assert_log(allExpected);
if(!allExpected) if(!allExpected)
logTestString("\nline2dIntersectWith failed\n"); logTestString("\nline2dIntersectWith failed\n");
......
#include "testUtils.h" #include "testUtils.h"
#include "irrlicht.h" #include "irrlicht.h"
#include <assert.h>
using namespace irr; using namespace irr;
using namespace core; using namespace core;
......
...@@ -14,6 +14,15 @@ ...@@ -14,6 +14,15 @@
for (u32 i=video::EDT_DIRECT3D8; i<video::EDT_COUNT; ++i) \ for (u32 i=video::EDT_DIRECT3D8; i<video::EDT_COUNT; ++i) \
result &= X(video::E_DRIVER_TYPE(i)) result &= X(video::E_DRIVER_TYPE(i))
// replacement for assert which does log the lines instead
#define assert_log(X) \
do { \
if ( !(X) ) \
{ \
logTestString("ASSERT in %s:%d: %s\n", __FILE__, __LINE__, #X); \
} \
} while (false)
//! Compare two files //! Compare two files
/** \param fileName1 The first file for comparison. /** \param fileName1 The first file for comparison.
\param fileName2 The second file for comparison. \param fileName2 The second file for comparison.
......
...@@ -14,7 +14,7 @@ static bool compareVectors(const core::vector2d<T> & compare, ...@@ -14,7 +14,7 @@ static bool compareVectors(const core::vector2d<T> & compare,
{ {
logTestString("\nERROR: vector2d %.16f, %.16f != vector2d %.16f, %.16f\n", logTestString("\nERROR: vector2d %.16f, %.16f != vector2d %.16f, %.16f\n",
(f64)compare.X, (f64)compare.Y, (f64)with.X, (f64)with.Y); (f64)compare.X, (f64)compare.Y, (f64)with.X, (f64)with.Y);
assert(compare == with); assert_log(compare == with);
return false; return false;
} }
...@@ -32,7 +32,7 @@ static bool doTests() ...@@ -32,7 +32,7 @@ static bool doTests()
if(!equals(vec.getDistanceFrom(otherVec), (T)15.8113883)) if(!equals(vec.getDistanceFrom(otherVec), (T)15.8113883))
{ {
logTestString("vector2d::getDistanceFrom() failed\n"); logTestString("vector2d::getDistanceFrom() failed\n");
assert(0); assert_log(0);
return false; return false;
} }
......
...@@ -99,7 +99,7 @@ static bool equalVectors(const S& compare, ...@@ -99,7 +99,7 @@ static bool equalVectors(const S& compare,
logTestString("\nERROR: vector3d %.16f, %.16f, %.16f %s vector3d %.16f, %.16f, %.16f\n", logTestString("\nERROR: vector3d %.16f, %.16f, %.16f %s vector3d %.16f, %.16f, %.16f\n",
(f64)compare.val.X, (f64)compare.val.Y, (f64)compare.val.Z, compare.getName(), (f64)compare.val.X, (f64)compare.val.Y, (f64)compare.val.Z, compare.getName(),
(f64)with.X, (f64)with.Y, (f64)with.Z); (f64)with.X, (f64)with.Y, (f64)with.Z);
assert(compare(with)); assert_log(compare(with));
return false; return false;
} }
...@@ -211,7 +211,7 @@ static bool doTests() ...@@ -211,7 +211,7 @@ static bool doTests()
if(!vec.equals(otherVec, (T)0.1)) if(!vec.equals(otherVec, (T)0.1))
{ {
logTestString("vector3d::equals failed\n"); logTestString("vector3d::equals failed\n");
assert(0); assert_log(0);
return false; return false;
} }
...@@ -220,7 +220,7 @@ static bool doTests() ...@@ -220,7 +220,7 @@ static bool doTests()
if(!equals(vec.getDistanceFrom(otherVec), (T)15.8113883)) if(!equals(vec.getDistanceFrom(otherVec), (T)15.8113883))
{ {
logTestString("vector3d::getDistanceFrom() failed\n"); logTestString("vector3d::getDistanceFrom() failed\n");
assert(0); assert_log(0);
return false; return false;
} }
......
Tests finished. 1 test of 1 passed. Tests finished. 1 test of 1 passed.
Compiled as DEBUG Compiled as RELEASE
Test suite pass at GMT Mon Feb 20 19:21:21 2012 Test suite pass at GMT Tue Apr 3 20:04:39 2012
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "testUtils.h" #include "testUtils.h"
#include <irrlicht.h> #include <irrlicht.h>
#include <assert.h>
using namespace irr; using namespace irr;
using namespace core; using namespace core;
...@@ -105,25 +104,25 @@ template<class T> ...@@ -105,25 +104,25 @@ template<class T>
static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool testIsInsideFast) static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool testIsInsideFast)
{ {
bool allExpected=true; bool allExpected=true;
array< vector3d<T> > pointsInside; array< vector3d<T> > pointsInside;
pointsInside.push_back( vector3d<T>(0,0,0) ); pointsInside.push_back( vector3d<T>(0,0,0) );
pointsInside.push_back( (triangleOrig.pointA + triangleOrig.pointB + triangleOrig.pointC) / 3 ); pointsInside.push_back( (triangleOrig.pointA + triangleOrig.pointB + triangleOrig.pointC) / 3 );
pointsInside.push_back( (triangleOrig.pointA + triangleOrig.pointB)/2 + vector3d<T>(0,1,0) ); pointsInside.push_back( (triangleOrig.pointA + triangleOrig.pointB)/2 + vector3d<T>(0,1,0) );
pointsInside.push_back( (triangleOrig.pointA + triangleOrig.pointC)/2 + vector3d<T>(1,0,0) ); pointsInside.push_back( (triangleOrig.pointA + triangleOrig.pointC)/2 + vector3d<T>(1,0,0) );
pointsInside.push_back( (triangleOrig.pointB + triangleOrig.pointC)/2 - vector3d<T>(1,0,0) ); pointsInside.push_back( (triangleOrig.pointB + triangleOrig.pointC)/2 - vector3d<T>(1,0,0) );
for (u32 stage=0; ; ++stage) for (u32 stage=0; ; ++stage)
{ {
triangle3d<T> triangle = triangleOrig; triangle3d<T> triangle = triangleOrig;
if ( !stageModifications(stage, triangle) ) if ( !stageModifications(stage, triangle) )
break; break;
for ( u32 i=0; i < pointsInside.size(); ++i ) for ( u32 i=0; i < pointsInside.size(); ++i )
{ {
vector3d<T> point = pointsInside[i]; vector3d<T> point = pointsInside[i];
stageModifications(stage, point); stageModifications(stage, point);
if ( testIsInside ) if ( testIsInside )
{ {
allExpected &= triangle.isPointInside( point ); allExpected &= triangle.isPointInside( point );
...@@ -133,7 +132,7 @@ static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool te ...@@ -133,7 +132,7 @@ static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool te
return false; return false;
} }
} }
if ( testIsInsideFast ) if ( testIsInsideFast )
{ {
allExpected &= triangle.isPointInsideFast( point ); allExpected &= triangle.isPointInsideFast( point );
...@@ -145,7 +144,7 @@ static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool te ...@@ -145,7 +144,7 @@ static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool te
} }
} }
} }
array< vector3d<T> > pointsOutside; array< vector3d<T> > pointsOutside;
pointsOutside.push_back( triangleOrig.pointA - vector3d<T>(1,0,0) ); pointsOutside.push_back( triangleOrig.pointA - vector3d<T>(1,0,0) );
pointsOutside.push_back( triangleOrig.pointA - vector3d<T>(0,1,0) ); pointsOutside.push_back( triangleOrig.pointA - vector3d<T>(0,1,0) );
...@@ -157,18 +156,18 @@ static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool te ...@@ -157,18 +156,18 @@ static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool te
pointsOutside.push_back( (triangleOrig.pointA + triangleOrig.pointB)/2 - vector3d<T>(0,1,0) ); pointsOutside.push_back( (triangleOrig.pointA + triangleOrig.pointB)/2 - vector3d<T>(0,1,0) );
pointsOutside.push_back( (triangleOrig.pointA + triangleOrig.pointC)/2 - vector3d<T>(1,0,0) ); pointsOutside.push_back( (triangleOrig.pointA + triangleOrig.pointC)/2 - vector3d<T>(1,0,0) );
pointsOutside.push_back( (triangleOrig.pointB + triangleOrig.pointC)/2 + vector3d<T>(1,0,0) ); pointsOutside.push_back( (triangleOrig.pointB + triangleOrig.pointC)/2 + vector3d<T>(1,0,0) );
for (u32 stage=0; ; ++stage) for (u32 stage=0; ; ++stage)
{ {
triangle3d<T> triangle = triangleOrig; triangle3d<T> triangle = triangleOrig;
if ( !stageModifications(stage, triangle) ) if ( !stageModifications(stage, triangle) )
break; break;
for ( u32 i=0; i < pointsOutside.size(); ++i ) for ( u32 i=0; i < pointsOutside.size(); ++i )
{ {
vector3d<T> point = pointsOutside[i]; vector3d<T> point = pointsOutside[i];
stageModifications(stage, point); stageModifications(stage, point);
if ( testIsInside ) if ( testIsInside )
{ {
allExpected &= !triangle.isPointInside( point ); allExpected &= !triangle.isPointInside( point );
...@@ -178,7 +177,7 @@ static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool te ...@@ -178,7 +177,7 @@ static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool te
return false; return false;
} }
} }
if ( testIsInsideFast ) if ( testIsInsideFast )
{ {
allExpected &= !triangle.isPointInsideFast( point ); allExpected &= !triangle.isPointInsideFast( point );
...@@ -190,7 +189,7 @@ static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool te ...@@ -190,7 +189,7 @@ static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool te
} }
} }
} }
array< vector3d<T> > pointsBorder; array< vector3d<T> > pointsBorder;
pointsBorder.push_back( triangleOrig.pointA ); pointsBorder.push_back( triangleOrig.pointA );
pointsBorder.push_back( triangleOrig.pointB ); pointsBorder.push_back( triangleOrig.pointB );
...@@ -198,13 +197,13 @@ static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool te ...@@ -198,13 +197,13 @@ static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool te
pointsBorder.push_back( (triangleOrig.pointA + triangleOrig.pointB)/2 ); pointsBorder.push_back( (triangleOrig.pointA + triangleOrig.pointB)/2 );
pointsBorder.push_back( (triangleOrig.pointA + triangleOrig.pointC)/2 ); pointsBorder.push_back( (triangleOrig.pointA + triangleOrig.pointC)/2 );
pointsBorder.push_back( (triangleOrig.pointB + triangleOrig.pointC)/2 ); pointsBorder.push_back( (triangleOrig.pointB + triangleOrig.pointC)/2 );
for (u32 stage=0; ; ++stage) for (u32 stage=0; ; ++stage)
{ {
triangle3d<T> triangle = triangleOrig; triangle3d<T> triangle = triangleOrig;
if ( !stageModifications(stage, triangle) ) if ( !stageModifications(stage, triangle) )
break; break;
for ( u32 i=0; i < pointsBorder.size(); ++i ) for ( u32 i=0; i < pointsBorder.size(); ++i )
{ {
vector3d<T> point = pointsBorder[i]; vector3d<T> point = pointsBorder[i];
...@@ -219,7 +218,7 @@ static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool te ...@@ -219,7 +218,7 @@ static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool te
return false; return false;
} }
} }
if ( testIsInsideFast ) if ( testIsInsideFast )
{ {
allExpected &= triangle.isPointInsideFast( point ); allExpected &= triangle.isPointInsideFast( point );
...@@ -266,19 +265,18 @@ static bool isPointInsideWithSinglePrecision() ...@@ -266,19 +265,18 @@ static bool isPointInsideWithSinglePrecision()
return ok; return ok;
#else #else
// TODO: Be free to try changing the fpu for other systems. // TODO: Be free to try changing the fpu for other systems.
// I think for MinGW it's still easy, but for Linux this probably also needs changed linker flags. // I think for MinGW it's still easy, but for Linux this probably also needs changed linker flags.
return true; return true;
#endif #endif
} }
// Test the functionality of triangle3d<T> // Test the functionality of triangle3d<T>
/** Validation is done with asserts() against expected results. */
bool testTriangle3d(void) bool testTriangle3d(void)
{ {
bool allExpected = true; bool allExpected = true;
/* TODO: disabled for now. I (aka CuteAlien) have by now an example which allows debugging /* TODO: disabled for now. I (aka CuteAlien) have by now an example which allows debugging
that problem easier and also found some workaround (which needs an interface change that problem easier and also found some workaround (which needs an interface change
and a behaviour change and won't get into 1.7 therefore). and a behaviour change and won't get into 1.7 therefore).
logTestString("Test getIntersectionWithLine with f32\n"); logTestString("Test getIntersectionWithLine with f32\n");
...@@ -305,30 +303,30 @@ bool testTriangle3d(void) ...@@ -305,30 +303,30 @@ bool testTriangle3d(void)
} }
*/ */
/* For now we have no solution yet to fix isPointInside for large integers without /* For now we have no solution yet to fix isPointInside for large integers without
getting worse floating-point precision at the same time. getting worse floating-point precision at the same time.
So instead isPointInsideFast got fixed and should be used for int's. So instead isPointInsideFast got fixed and should be used for int's.
bool testEigen = triangle3di(vector3di(250, 0, 0), vector3di(0, 0, 500), vector3di(500, 0, 500)).isPointInside(vector3di(300,0,300)); bool testEigen = triangle3di(vector3di(250, 0, 0), vector3di(0, 0, 500), vector3di(500, 0, 500)).isPointInside(vector3di(300,0,300));
if ( !testEigen ) // test from Eigen from here: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=44372&p=254331#p254331 if ( !testEigen ) // test from Eigen from here: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=44372&p=254331#p254331
logTestString("Test isPointInside fails with integers\n"); logTestString("Test isPointInside fails with integers\n");
allExpected &= testEigen; allExpected &= testEigen;
*/ */
logTestString("Test isPointInside with f32\n"); logTestString("Test isPointInside with f32\n");
{ {
triangle3d<f32> t(vector3d<f32>(-1000,-1000,0), vector3d<f32>(1000,-1000,0), vector3d<f32>(0,1000,0)); triangle3d<f32> t(vector3d<f32>(-1000,-1000,0), vector3d<f32>(1000,-1000,0), vector3d<f32>(0,1000,0));
allExpected &= isPointInside(t, true, true); allExpected &= isPointInside(t, true, true);
} }
logTestString("Test isPointInside with f64\n"); logTestString("Test isPointInside with f64\n");
{ {
triangle3d<f64> t(vector3d<f64>(-1000,-1000,0), vector3d<f64>(1000,-1000,0), vector3d<f64>(0,1000,0)); triangle3d<f64> t(vector3d<f64>(-1000,-1000,0), vector3d<f64>(1000,-1000,0), vector3d<f64>(0,1000,0));
allExpected &= isPointInside(t, true, true); allExpected &= isPointInside(t, true, true);
} }
logTestString("Test isPointInside with s32\n"); logTestString("Test isPointInside with s32\n");
{ {
triangle3d<s32> t(vector3d<s32>(-1000,-1000,0), vector3d<s32>(1000,-1000,0), vector3d<s32>(0,1000,0)); triangle3d<s32> t(vector3d<s32>(-1000,-1000,0), vector3d<s32>(1000,-1000,0), vector3d<s32>(0,1000,0));
allExpected &= isPointInside(t, false, true); allExpected &= isPointInside(t, false, true);
} }
...@@ -336,7 +334,7 @@ bool testTriangle3d(void) ...@@ -336,7 +334,7 @@ bool testTriangle3d(void)
{ {
allExpected &= isPointInsideWithSinglePrecision(); allExpected &= isPointInsideWithSinglePrecision();
} }
if(allExpected) if(allExpected)
logTestString("\nAll tests passed\n"); logTestString("\nAll tests passed\n");
else else
......
...@@ -24,43 +24,43 @@ static bool doTest(void) ...@@ -24,43 +24,43 @@ static bool doTest(void)
result &= (vector == dimension); // The conversion should be explicit. result &= (vector == dimension); // The conversion should be explicit.
result &= (dimension2 == position); result &= (dimension2 == position);
result &= (position == POSITION((T)99.9, (T)99.9)); result &= (position == POSITION((T)99.9, (T)99.9));
assert(result); assert_log(result);
dimension = (T)2 * position; dimension = (T)2 * position;
result &= (dimension == VECTOR(2 * (T)99.9, 2 * (T)99.9)); result &= (dimension == VECTOR(2 * (T)99.9, 2 * (T)99.9));
assert(result); assert_log(result);
dimension /= (T)2; dimension /= (T)2;
result &= (dimension == POSITION((T)99.9, (T)99.9)); result &= (dimension == POSITION((T)99.9, (T)99.9));
assert(result); assert_log(result);
dimension += vector; dimension += vector;
result &= (dimension == VECTOR(2 * (T)99.9, 2 * (T)99.9)); result &= (dimension == VECTOR(2 * (T)99.9, 2 * (T)99.9));
assert(result); assert_log(result);
dimension -= position; dimension -= position;
result &= (dimension == POSITION((T)99.9, (T)99.9)); result &= (dimension == POSITION((T)99.9, (T)99.9));
assert(result); assert_log(result);
position = dimension; position = dimension;
result &= (position == VECTOR((T)99.9, (T)99.9)); result &= (position == VECTOR((T)99.9, (T)99.9));
assert(result); assert_log(result);
vector += position; vector += position;
result &= (vector == POSITION(2 * (T)99.9, 2 * (T)99.9)); result &= (vector == POSITION(2 * (T)99.9, 2 * (T)99.9));
assert(result); assert_log(result);
vector -= position; vector -= position;
result &= (vector == dimension); result &= (vector == dimension);
assert(result); assert_log(result);
position *= (T)3.5; position *= (T)3.5;
result &= (position == VECTOR((T)3.5 * (T)99.9, (T)3.5 * (T)99.9)); result &= (position == VECTOR((T)3.5 * (T)99.9, (T)3.5 * (T)99.9));
assert(result); assert_log(result);
vector += dimension; vector += dimension;
result &= (vector == VECTOR(2 * (T)99.9, 2 * (T)99.9)); result &= (vector == VECTOR(2 * (T)99.9, 2 * (T)99.9));
assert(result); assert_log(result);
return result; return result;
} }
......
...@@ -57,7 +57,7 @@ bool writeImageToFile(void) ...@@ -57,7 +57,7 @@ bool writeImageToFile(void)
if (!screenshot) if (!screenshot)
{ {
logTestString("Failed to take screenshot\n"); logTestString("Failed to take screenshot\n");
assert(false); assert_log(false);
goto cleanup; goto cleanup;
} }
...@@ -72,7 +72,7 @@ bool writeImageToFile(void) ...@@ -72,7 +72,7 @@ bool writeImageToFile(void)
if (!fixedScreenshot) if (!fixedScreenshot)
{ {
logTestString("Failed to convert screenshot to ECF_A8R8G8B8\n"); logTestString("Failed to convert screenshot to ECF_A8R8G8B8\n");
assert(false); assert_log(false);
goto cleanup; goto cleanup;
} }
...@@ -85,7 +85,7 @@ bool writeImageToFile(void) ...@@ -85,7 +85,7 @@ bool writeImageToFile(void)
if (!driver->writeImageToFile(screenshot, memoryFile)) if (!driver->writeImageToFile(screenshot, memoryFile))
{ {
logTestString("Failed to write png to memory file\n"); logTestString("Failed to write png to memory file\n");
assert(false); assert_log(false);
goto cleanup; goto cleanup;
} }
...@@ -93,14 +93,14 @@ bool writeImageToFile(void) ...@@ -93,14 +93,14 @@ bool writeImageToFile(void)
if (!writtenFile) if (!writtenFile)
{ {
logTestString("Can't open %s for writing.\n", writtenFilename); logTestString("Can't open %s for writing.\n", writtenFilename);
assert(false); assert_log(false);
goto cleanup; goto cleanup;
} }
if (memoryFile->getPos() != writtenFile->write(buffer, memoryFile->getPos())) if (memoryFile->getPos() != writtenFile->write(buffer, memoryFile->getPos()))
{ {
logTestString("Error while writing to %s.\n", writtenFilename); logTestString("Error while writing to %s.\n", writtenFilename);
assert(false); assert_log(false);
goto cleanup; goto cleanup;
} }
...@@ -111,7 +111,7 @@ bool writeImageToFile(void) ...@@ -111,7 +111,7 @@ bool writeImageToFile(void)
if (!binaryCompareFiles(writtenFilename, referenceFilename)) if (!binaryCompareFiles(writtenFilename, referenceFilename))
{ {
logTestString("File written from memory is not the same as the reference file. %s:%d\n" , __FILE__, __LINE__); logTestString("File written from memory is not the same as the reference file. %s:%d\n" , __FILE__, __LINE__);
// assert(false); // assert_log(false);
goto cleanup; goto cleanup;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment