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)
- 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)
- CSceneCollisionManager::getScreenCoordinatesFrom3DPosition uses now getCurrentRenderTargetSize instead of getScreenSize so it can work with render textures.
......
......@@ -220,7 +220,7 @@ public:
load( reader );
reader->drop();
}
assert(Areas.size() > 0);
assert_log(Areas.size() > 0);
}
//! destructor
......@@ -337,7 +337,7 @@ public:
if (indices[n] == -1)
continue;
//assert(sprites[spriteID].Frames.size() > 0);
//assert_log(sprites[spriteID].Frames.size() > 0);
const int texID = (fallback[n] ?
(*fallback_sprites)[spriteID].Frames[0].textureNumber :
......@@ -437,7 +437,7 @@ public:
//! returns the dimension of a text
virtual core::dimension2d<u32> getDimension(const wchar_t* text) const
{
assert(Areas.size() > 0);
assert_log(Areas.size() > 0);
core::dimension2d<u32> dim(0, 0);
core::dimension2d<u32> thisLine(0, (int)(MaxHeight*m_scale));
......
......@@ -429,7 +429,7 @@ bool testAddRemove(IFileSystem* fs, const io::path& archiveName)
bool archiveReader()
{
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(1, 1));
assert(device);
assert_log(device);
if(!device)
return false;
......
......@@ -10,7 +10,7 @@ bool b3dAnimation(void)
{
// 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);
assert(device);
assert_log(device);
if (!device)
return false;
......@@ -18,14 +18,14 @@ bool b3dAnimation(void)
scene::ISceneManager * smgr = device->getSceneManager();
scene::ISkinnedMesh* mesh = (scene::ISkinnedMesh*)smgr->getMesh("../media/ninja.b3d");
assert(mesh);
assert_log(mesh);
bool result = false;
if (!mesh)
return false;
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 */
if(node1)
......@@ -38,7 +38,7 @@ bool b3dAnimation(void)
}
scene::IAnimatedMeshSceneNode* node2 = smgr->addAnimatedMeshSceneNode(mesh);
assert(node2);
assert_log(node2);
if(node2)
{
node2->setPosition(core::vector3df(3, -3, 10));
......
......@@ -12,7 +12,7 @@ bool billboardSize(void)
{
// 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);
assert(device);
assert_log(device);
if (!device)
return false;
......@@ -114,7 +114,7 @@ bool billboardOrientation(void)
{
// 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);
assert(device);
assert_log(device);
if (!device)
return false;
......
......@@ -25,7 +25,7 @@ public:
logTestString("*** Error: collision point, expected %f %f %f\n",
ExpectedCollisionPoint.X, ExpectedCollisionPoint.Y, ExpectedCollisionPoint.Z);
expectedCollisionCallbackPositions = false;
assert(false);
assert_log(false);
}
const vector3df & nodePosition = animator.getCollisionResultPosition();
......@@ -34,14 +34,14 @@ public:
logTestString("*** Error: result position, expected %f %f %f\n",
ExpectedNodePosition.X, ExpectedNodePosition.Y, ExpectedNodePosition.Z);
expectedCollisionCallbackPositions = false;
assert(false);
assert_log(false);
}
if(animator.getTargetNode() != ExpectedTarget)
{
logTestString("*** Error: wrong node\n");
expectedCollisionCallbackPositions = false;
assert(false);
assert_log(false);
}
return ConsumeNextCollision;
......@@ -73,7 +73,7 @@ private:
bool collisionResponseAnimator(void)
{
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL);
assert(device);
assert_log(device);
if(!device)
return false;
......@@ -140,14 +140,14 @@ bool collisionResponseAnimator(void)
if(testNode1->getAbsolutePosition().X > -15.f)
{
logTestString("collisionResponseAnimator test node 1 wasn't stopped from moving.\n");
assert(false);
assert_log(false);
result = false;
}
if(testNode2->getAbsolutePosition().X < 50.f)
{
logTestString("collisionResponseAnimator test node 2 was stopped from moving.\n");
assert(false);
assert_log(false);
result = false;
}
......@@ -167,7 +167,7 @@ bool collisionResponseAnimator(void)
if(testNode2->getAbsolutePosition().X != -50.f)
{
logTestString("collisionResponseAnimator test node 2 was stopped from moving.\n");
assert(false);
assert_log(false);
result = false;
}
......@@ -184,7 +184,7 @@ bool collisionResponseAnimator(void)
if(testNode2->getAbsolutePosition().X > -15.f)
{
logTestString("collisionResponseAnimator test node 2 moved too far.\n");
assert(false);
assert_log(false);
result = false;
}
......
......@@ -62,7 +62,7 @@ bool cursorSetVisible(void)
if(!result)
{
logTestString("ERROR: cursorSetVisible received %d events.\n", moveTrapper.MouseMovesReceived);
assert(false);
assert_log(false);
}
return result;
......
......@@ -38,39 +38,39 @@ bool disambiguateTextures(void)
IVideoDriver * driver = device->getVideoDriver();
ITexture * tex1 = driver->getTexture("../media/tools.png");
assert(tex1);
assert_log(tex1);
if(!tex1)
logTestString("Unable to open ../media/tools.png\n");
ITexture * tex2 = driver->getTexture("../media/tools.png");
assert(tex2);
assert_log(tex2);
if(!tex2)
logTestString("Unable to open ../media/tools.png\n");
IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
assert(readFile);
assert_log(readFile);
if(!readFile)
logTestString("Unable to open ../media/tools.png\n");
ITexture * tex3 = driver->getTexture(readFile);
assert(tex3);
assert_log(tex3);
if(!readFile)
logTestString("Unable to create texture from ../media/tools.png\n");
readFile->drop();
// All 3 of the above textures should be identical.
assert(tex1 == tex2);
assert(tex1 == tex3);
assert_log(tex1 == tex2);
assert_log(tex1 == tex3);
stringc newWd = wd + "/empty/empty";
bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd.c_str());
assert(changed);
assert_log(changed);
ITexture * tex4 = driver->getTexture("../../media/tools.png");
assert(tex4);
assert_log(tex4);
if(!tex4)
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.
changed &= device->getFileSystem()->changeWorkingDirectoryTo(wd.c_str());
......
......@@ -53,7 +53,7 @@ bool enumerateImageManipulators(void)
if(!loader)
{
logTestString("Failed to get image loader %d\n", i);
assert(false);
assert_log(false);
result = false;
}
......@@ -67,7 +67,7 @@ bool enumerateImageManipulators(void)
}
IImageLoader * loader = driver->getImageLoader(i);
assert(loader == 0);
assert_log(loader == 0);
if(loader)
{
logTestString("Got a loader when none was expected (%d)\n", i);
......@@ -79,7 +79,7 @@ bool enumerateImageManipulators(void)
if(!loaderForFilename[filename])
{
logTestString("File type '%s' doesn't have a loader\n", filenames[filename]);
assert(false);
assert_log(false);
result = false;
}
}
......@@ -92,7 +92,7 @@ bool enumerateImageManipulators(void)
if(!writer)
{
logTestString("Failed to get image writer %d\n", i);
assert(false);
assert_log(false);
result = false;
}
......@@ -107,7 +107,7 @@ bool enumerateImageManipulators(void)
}
IImageWriter * writer = driver->getImageWriter(i);
assert(writer == 0);
assert_log(writer == 0);
if(writer)
{
logTestString("Got a writer when none was expected (%d)\n", i);
......@@ -120,7 +120,7 @@ bool enumerateImageManipulators(void)
if(!writerForFilename[filename] && (filename<writersUntil))
{
logTestString("File type '%s' doesn't have a writer\n", filenames[filename]);
assert(false);
assert_log(false);
result = false;
}
}
......
......@@ -125,7 +125,7 @@ static bool testgetRelativeFilename(io::IFileSystem* fs)
bool filesystem(void)
{
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(1, 1));
assert(device);
assert_log(device);
if(!device)
return false;
......@@ -146,7 +146,7 @@ bool filesystem(void)
io::path newWd = workingDir + "/media";
bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd);
assert(changed);
assert_log(changed);
if ( fs->existFile(empty) )
{
......@@ -156,7 +156,7 @@ bool filesystem(void)
// The working directory must be restored for the other tests to work.
changed = device->getFileSystem()->changeWorkingDirectoryTo(workingDir.c_str());
assert(changed);
assert_log(changed);
// adding a folder archive which just should not really change anything
device->getFileSystem()->addFileArchive( "./" );
......
......@@ -16,7 +16,7 @@ bool guiDisabledMenu(void)
{
IrrlichtDevice *device = createDevice( video::EDT_BURNINGSVIDEO,
dimension2d<u32>(160, 40), 32);
assert(device);
assert_log(device);
if (!device)
return false;
......
......@@ -14,7 +14,7 @@ using namespace gui;
static bool saveScene(void)
{
IrrlichtDevice *device = createDevice( EDT_NULL, dimension2d<u32>(160, 120), 32);
assert(device);
assert_log(device);
if (!device)
return false;
......
......@@ -3,7 +3,6 @@
#include "testUtils.h"
#include <irrlicht.h>
#include <assert.h>
using namespace irr;
using namespace core;
......@@ -109,7 +108,7 @@ static bool testSwap()
result &= (array1 == copy2);
result &= (array2 == copy1);
assert( result );
assert_log( result );
return result;
}
......
#include "testUtils.h"
#include <irrlicht.h>
#include <assert.h>
using namespace irr;
using namespace core;
......@@ -53,7 +52,7 @@ static bool testSwap()
result &= compareLists<int>(list1, copy2);
result &= compareLists<int>(list2, copy1);
assert( result );
assert_log( result );
return result;
}
......
#include "testUtils.h"
#include <irrlicht.h>
#include <assert.h>
using namespace irr;
using namespace core;
......@@ -44,7 +43,7 @@ static bool testSwap()
result &= compareMaps(map1, copy2);
result &= compareMaps(map2, copy1);
assert( result );
assert_log( result );
return result;
}
......
......@@ -3,7 +3,6 @@
#include "testUtils.h"
#include <irrlicht.h>
#include <assert.h>
using namespace irr;
using namespace core;
......@@ -116,7 +115,7 @@ bool testAppendStringc()
// 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 allExpected = true;
......@@ -125,39 +124,39 @@ bool testIrrString(void)
{
// Check empty string
core::stringc empty;
assert(empty.size()==0);
assert(empty[0]==0);
assert(empty.c_str()!=0);
assert(*(empty.c_str())==0);
assert_log(empty.size()==0);
assert_log(empty[0]==0);
assert_log(empty.c_str()!=0);
assert_log(*(empty.c_str())==0);
// Assign content
empty = "Test";
assert(empty.size()==4);
assert(empty[0]=='T');
assert(empty[3]=='t');
assert(*(empty.c_str())=='T');
assert_log(empty.size()==4);
assert_log(empty[0]=='T');
assert_log(empty[3]=='t');
assert_log(*(empty.c_str())=='T');
//Assign empty string, should be same as in the beginning
empty = "";
assert(empty.size()==0);
assert(empty[0]==0);
assert(*(empty.c_str())==0);
assert_log(empty.size()==0);
assert_log(empty[0]==0);
assert_log(*(empty.c_str())==0);
}
logTestString("Test stringw\n");
{
core::stringw empty;
assert(empty.size()==0);
assert(empty[0]==0);
assert(empty.c_str()!=0);
assert(*(empty.c_str())==0);
assert_log(empty.size()==0);
assert_log(empty[0]==0);
assert_log(empty.c_str()!=0);
assert_log(*(empty.c_str())==0);
empty = L"Test";
assert(empty.size()==4);
assert(empty[0]==L'T');
assert(empty[3]=='t');
assert(*(empty.c_str())==L'T');
assert_log(empty.size()==4);
assert_log(empty[0]==L'T');
assert_log(empty[3]=='t');
assert_log(*(empty.c_str())==L'T');
empty = L"";
assert(empty.size()==0);
assert(empty[0]==0);
assert(*(empty.c_str())==0);
assert(allExpected &= testSplit());
assert_log(empty.size()==0);
assert_log(empty[0]==0);
assert_log(*(empty.c_str())==0);
assert_log(allExpected &= testSplit());
}
allExpected &= testAppendStringc();
......
......@@ -31,12 +31,12 @@ static bool runTestWithDriver(E_DRIVER_TYPE driverType)
bool result = true;
bool added = device->getFileSystem()->addFileArchive("../media/map-20kdm2.pk3");
assert(added);
assert_log(added);
if(added)
{
ISceneNode * node = smgr->addOctreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024);
assert(node);
assert_log(node);
if (node)
{
......
......@@ -28,7 +28,7 @@ bool loadFromFileFolder(void)
u32 numTexs = driver->getTextureCount();
ITexture * tex1 = driver->getTexture("../media/tools.png");
assert(tex1);
assert_log(tex1);
if(!tex1)
logTestString("Unable to open ../media/tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
......@@ -38,7 +38,7 @@ bool loadFromFileFolder(void)
}
IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
assert(readFile);
assert_log(readFile);
if(!readFile)
logTestString("Unable to open ../media/tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
......@@ -48,7 +48,7 @@ bool loadFromFileFolder(void)
}
ITexture * tex2 = driver->getTexture(readFile);
assert(tex2);
assert_log(tex2);
if(!readFile)
logTestString("Unable to create texture from ../media/tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
......@@ -63,7 +63,7 @@ bool loadFromFileFolder(void)
device->getFileSystem()->addFileArchive( "../media/" );
ITexture * tex3 = driver->getTexture("tools.png");
assert(tex3);
assert_log(tex3);
if(!tex3)
logTestString("Unable to open tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
......@@ -73,7 +73,7 @@ bool loadFromFileFolder(void)
}
ITexture * tex4 = driver->getTexture("tools.png");
assert(tex4);
assert_log(tex4);
if(!tex4)
logTestString("Unable to open tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
......
......@@ -21,30 +21,30 @@ bool identity(void)
// Check default init
result &= (m==core::IdentityMatrix);
result &= (core::IdentityMatrix==m);
assert(result);
assert_log(result);
// Since the last test can be made with isDefinitelyIdentityMatrix we set it to false here
m.setDefinitelyIdentityMatrix(false);
result &= (m==core::IdentityMatrix);
result &= (core::IdentityMatrix==m);
assert(result);
assert_log(result);
// also equals should see this
result &= m.equals(core::IdentityMatrix);
result &= core::IdentityMatrix.equals(m);
assert(result);
assert_log(result);
// Check inequality
m[12]=5.f;
result &= (m!=core::IdentityMatrix);
result &= (core::IdentityMatrix!=m);
result &= !m.equals(core::IdentityMatrix);
result &= !core::IdentityMatrix.equals(m);
assert(result);
assert_log(result);
// Test multiplication
result &= (m==(core::IdentityMatrix*m));
result &= m.equals(core::IdentityMatrix*m);
result &= (m==(m*core::IdentityMatrix));
result &= m.equals(m*core::IdentityMatrix);
assert(result);
assert_log(result);
return result;
}
......@@ -59,30 +59,30 @@ bool transformations(void)
m *= s;
m.setTranslation(core::vector3df(5,6,7));
result &= (core::vector3df(5,6,7).equals(m.getTranslation()));
assert(result);
assert_log(result);
result &= (core::vector3df(2,3,4).equals(m.getScale()));
assert(result);
assert_log(result);
core::vector3df newRotation = m.getRotationDegrees();
result &= (core::vector3df(30,40,50).equals(newRotation, 0.000004f));
assert(result);
assert_log(result);
m.setRotationDegrees(vector3df(90.0001f, 270.85f, 180.0f));
s.setRotationDegrees(vector3df(0,0, 0.860866f));
m *= s;
newRotation = m.getRotationDegrees();
result &= (core::vector3df(0,270,270).equals(newRotation, 0.0001f));
assert(result);
assert_log(result);
m.setRotationDegrees(vector3df(270.0f, 89.8264f, 0.000100879f));
s.setRotationDegrees(vector3df(0,0, 0.189398f));
m *= s;
newRotation = m.getRotationDegrees();
result &= (core::vector3df(0,90,90).equals(newRotation, 0.0001f));
assert(result);
assert_log(result);
m.setRotationDegrees(vector3df(270.0f, 89.0602f, 359.999f));
s.setRotationDegrees(vector3df(0,0, 0.949104f));
m *= s;
newRotation = m.getRotationDegrees();
result &= (core::vector3df(0,90,89.999f).equals(newRotation));
assert(result);
assert_log(result);
return result;
}
......@@ -102,14 +102,14 @@ bool rotations(void)
rot4.setRotationDegrees(core::vector3df(90,90,90));
rot5 = rot3*rot2*rot1;
result &= (rot4.equals(rot5, ROUNDING_ERROR_f32));
assert(result);
assert_log(result);
rot4.transformVect(vec1);rot5.transformVect(vec12);
rot4.transformVect(vec2);rot5.transformVect(vec22);
rot4.transformVect(vec3);rot5.transformVect(vec32);
result &= (vec1.equals(vec12));
result &= (vec2.equals(vec22));
result &= (vec3.equals(vec32));
assert(result);
assert_log(result);
vec1.set(1,2,3);vec12.set(1,2,3);
vec2.set(-5,0,0);vec22.set(-5,0,0);
......@@ -120,14 +120,14 @@ bool rotations(void)
rot4.setRotationDegrees(core::vector3df(45,45,45));
rot5 = rot3*rot2*rot1;
result &= (rot4.equals(rot5, ROUNDING_ERROR_f32));
assert(result);
assert_log(result);
rot4.transformVect(vec1);rot5.transformVect(vec12);
rot4.transformVect(vec2);rot5.transformVect(vec22);
rot4.transformVect(vec3);rot5.transformVect(vec32);
result &= (vec1.equals(vec12));
result &= (vec2.equals(vec22));
result &= (vec3.equals(vec32));
assert(result);
assert_log(result);
vec1.set(1,2,3);vec12.set(1,2,3);
vec2.set(-5,0,0);vec22.set(-5,0,0);
......@@ -138,7 +138,7 @@ bool rotations(void)
rot4.setRotationDegrees(core::vector3df(-60,-60,-60));
rot5 = rot3*rot2*rot1;
result &= (rot4.equals(rot5, ROUNDING_ERROR_f32));
assert(result);
assert_log(result);
rot4.transformVect(vec1);rot5.transformVect(vec12);
rot4.transformVect(vec2);rot5.transformVect(vec22);
rot4.transformVect(vec3);rot5.transformVect(vec32);
......@@ -146,7 +146,7 @@ bool rotations(void)
result &= (vec2.equals(vec22));
// this one needs higher tolerance due to rounding issues
result &= (vec3.equals(vec32, 0.000002f));
assert(result);
assert_log(result);
vec1.set(1,2,3);vec12.set(1,2,3);
vec2.set(-5,0,0);vec22.set(-5,0,0);
......@@ -157,37 +157,37 @@ bool rotations(void)
rot4.setRotationDegrees(core::vector3df(113,-27,193));
rot5 = rot3*rot2*rot1;
result &= (rot4.equals(rot5, ROUNDING_ERROR_f32));
assert(result);
assert_log(result);
rot4.transformVect(vec1);rot5.transformVect(vec12);
rot4.transformVect(vec2);rot5.transformVect(vec22);
rot4.transformVect(vec3);rot5.transformVect(vec32);
// these ones need higher tolerance due to rounding issues
result &= (vec1.equals(vec12, 0.000002f));
assert(result);
assert_log(result);
result &= (vec2.equals(vec22));
assert(result);
assert_log(result);
result &= (vec3.equals(vec32, 0.000002f));
assert(result);
assert_log(result);
rot1.setRotationDegrees(core::vector3df(0,0,34));
rot2.setRotationDegrees(core::vector3df(0,43,0));
vec1=(rot2*rot1).getRotationDegrees();
result &= (vec1.equals(core::vector3df(27.5400505f, 34.4302292f, 42.6845398f), 0.000002f));
assert(result);
assert_log(result);
// corner cases
rot1.setRotationDegrees(irr::core::vector3df(180.0f, 0.f, 0.f));
vec1=rot1.getRotationDegrees();
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));
vec1=rot1.getRotationDegrees();
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));
vec1=rot1.getRotationDegrees();
result &= (vec1.equals(core::vector3df(0.f, 0.f, 180.0f), 0.000002f));
assert(result);
assert_log(result);
rot1.makeIdentity();
rot1.setRotationDegrees(core::vector3df(270.f,0,0));
......@@ -195,7 +195,7 @@ bool rotations(void)
rot2.setRotationDegrees(core::vector3df(-90.f,0,0));
vec1=(rot1*rot2).getRotationDegrees();
result &= (vec1.equals(core::vector3df(180.f, 0.f, 0.0f)));
assert(result);
assert_log(result);
return result;
}
......
......@@ -10,13 +10,13 @@ using namespace irr;
bool meshLoaders(void)
{
IrrlichtDevice *device = createDevice(video::EDT_NULL, core::dimension2d<u32>(160, 120), 32);
assert(device);
assert_log(device);
if (!device)
return false;
scene::ISceneManager * smgr = device->getSceneManager();
scene::IAnimatedMesh* mesh = smgr->getMesh("../media/ninja.b3d");
assert(mesh);
assert_log(mesh);
bool result = (mesh != 0);
......
......@@ -15,7 +15,7 @@ bool meshTransform(void)
{
// Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
IrrlichtDevice *device = createDevice(EDT_BURNINGSVIDEO, dimension2d<u32>(160, 120), 32);
assert(device);
assert_log(device);
if (!device)
return false;
......@@ -25,7 +25,7 @@ bool meshTransform(void)
IMeshSceneNode* node1 = smgr->addCubeSceneNode(50);
IAnimatedMesh* amesh = smgr->getMesh("../media/sydney.md2");
IAnimatedMesh* smesh = smgr->getMesh("../media/ninja.b3d");
assert(node1 && amesh && smesh);
assert_log(node1 && amesh && smesh);
bool result = false;
if (!node1 || !amesh || !smesh)
......@@ -35,7 +35,7 @@ bool meshTransform(void)
node1->setDebugDataVisible(scene::EDS_BBOX_ALL);
IMeshSceneNode* node2 = smgr->addMeshSceneNode(amesh->getMesh(10));
assert(node2);
assert_log(node2);
if (!node2)
return false;
......@@ -45,7 +45,7 @@ bool meshTransform(void)
node2->setMaterialFlag(EMF_LIGHTING, false);
IMeshSceneNode* node3 = smgr->addMeshSceneNode(smesh->getMesh(10));
assert(node3);
assert_log(node3);
if (!node3)
return false;
......
......@@ -38,7 +38,7 @@ static bool transformPlane(const vector3df & point, const vector3df & normal,
if(!sloppyComparePlanes(plane, expected))
{
logTestString("Unexpected result\n");
assert(false);
assert_log(false);
return false;
}
......@@ -57,12 +57,12 @@ static bool drawScaledOctree(void)
ISceneManager * smgr = device->getSceneManager();
bool added = device->getFileSystem()->addFileArchive("../media/map-20kdm2.pk3");
assert(added);
assert_log(added);
if(added)
{
ISceneNode * node = smgr->addOctreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024);
assert(node);
assert_log(node);
if (node)
{
......
......@@ -25,7 +25,7 @@ class CustomAnimator : public ISceneNodeAnimator
bool removeCustomAnimator(void)
{
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2du(160, 120));
assert(device);
assert_log(device);
if(!device)
return false;
......
......@@ -78,7 +78,7 @@ static bool testGetCollisionResultPosition(IrrlichtDevice * device,
result = false;
}
assert(result);
assert_log(result);
cubeSelector->drop();
smgr->clear();
......@@ -229,7 +229,7 @@ static bool testGetSceneNodeFromScreenCoordinatesBB(IrrlichtDevice * device,
logTestString("A node was hit when none was expected.\n");
result = false;
}
assert(result);
assert_log(result);
smgr->clear();
......@@ -273,7 +273,7 @@ static bool getScaledPickedNodeBB(IrrlichtDevice * device,
else if(hit == middleTarget)
logTestString("getSceneNodeFromRayBB() hit the middle (scaled) target.\n");
assert(result);
assert_log(result);
smgr->clear();
......@@ -364,7 +364,7 @@ static bool checkBBoxIntersection(IrrlichtDevice * device,
logTestString("Consider replacement of bbox intersection test.\n");
result &= (hits==0);
assert(result);
assert_log(result);
// second round without any hits, so check opposite direction
camera->setTarget(core::vector3df(80.f, 80.f, 80.f));
}
......@@ -445,7 +445,7 @@ static bool compareGetSceneNodeFromRayBBWithBBIntersectsWithLine(IrrlichtDevice
}
}
assert(result);
assert_log(result);
smgr->clear();
......@@ -457,7 +457,7 @@ static bool compareGetSceneNodeFromRayBBWithBBIntersectsWithLine(IrrlichtDevice
bool sceneCollisionManager(void)
{
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(160, 120));
assert(device);
assert_log(device);
if(!device)
return false;
......
......@@ -11,7 +11,7 @@ using namespace scene;
bool sceneNodeAnimator(void)
{
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(160, 120));
assert(device);
assert_log(device);
if(!device)
return false;
......@@ -108,7 +108,7 @@ bool sceneNodeAnimator(void)
if(!result)
{
logTestString("One or more animators has a bad hasFinished() state\n.");
assert(false);
assert_log(false);
}
return result;
......
......@@ -19,7 +19,7 @@ bool testDimension2d(void)
if(dimension != dimension2df(300.f, -100.f))
{
logTestString("dimension2df != produced unexpected result.\n");
assert(false);
assert_log(false);
return false;
}
......@@ -27,7 +27,7 @@ bool testDimension2d(void)
if(dimension != dimension2df(100.f, 100.f))
{
logTestString("dimension2df -= produced unexpected result.\n");
assert(false);
assert_log(false);
return false;
}
......
......@@ -114,7 +114,7 @@ static bool testLines(line2df const & line1,
}
// 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 allExpected = true;
......@@ -123,146 +123,146 @@ bool line2dIntersectWith(void)
allExpected &= testLines(line2df(vector2df(1,1),vector2df(1,3)),
line2df(vector2df(0,2),vector2df(2,2)),
true, vector2df(1,2));
assert(allExpected);
assert_log(allExpected);
// Crossing lines, both diagonal
allExpected &= testLines(line2df(vector2df(0,0),vector2df(2,2)),
line2df(vector2df(0,2),vector2df(2,0)),
true, vector2df(1,1));
assert(allExpected);
assert_log(allExpected);
// Non-crossing lines, horizontal and vertical
allExpected &= testLines(line2df(vector2df(1,1),vector2df(1,3)),
line2df(vector2df(0,4),vector2df(2,4)),
false, vector2df());
assert(allExpected);
assert_log(allExpected);
// Non-crossing lines, both diagonal
allExpected &= testLines(line2df(vector2df(0,0),vector2df(2,2)),
line2df(vector2df(3,4),vector2df(4,3)),
false, vector2df());
assert(allExpected);
assert_log(allExpected);
// Meeting at a common point
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
line2df(vector2df(1,0),vector2df(2,0)),
true, vector2df(1,0));
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
line2df(vector2df(1,0),vector2df(0,1)),
true, vector2df(1,0));
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
line2df(vector2df(1,0),vector2df(0,-1)),
true, vector2df(1,0));
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
line2df(vector2df(0,1),vector2df(1,1)),
true, vector2df(0,1));
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
line2df(vector2df(0,1),vector2df(1,-1)),
true, vector2df(0,1));
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
line2df(vector2df(0,1),vector2df(0,2)),
true, vector2df(0,1));
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
line2df(vector2df(1,0),vector2df(2,0)),
true, vector2df(1,0));
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,1)),
line2df(vector2df(1,1),vector2df(0,2)),
true, vector2df(1,1));
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,1)),
line2df(vector2df(1,1),vector2df(2,0)),
true, vector2df(1,1));
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,1)),
line2df(vector2df(1,1),vector2df(2,2)),
true, vector2df(1,1));
assert(allExpected);
assert_log(allExpected);
// Parallel lines, no intersection
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
line2df(vector2df(0,1),vector2df(1,1)),
false, vector2df());
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
line2df(vector2df(1,0),vector2df(1,1)),
false, vector2df());
assert(allExpected);
assert_log(allExpected);
// Non parallel lines, no intersection
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
line2df(vector2df(0,1),vector2df(0,2)),
false, vector2df());
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
line2df(vector2df(1,0),vector2df(2,0)),
false, vector2df());
assert(allExpected);
assert_log(allExpected);
// Coincident (and thus parallel) lines
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
line2df(vector2df(0,0),vector2df(1,0)),
true, vector2df(0,0));
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(2,0),vector2df(0,2)),
line2df(vector2df(2,0),vector2df(0,2)),
true, vector2df(2,0));
assert(allExpected);
assert_log(allExpected);
// Two segments of the same unlimited line, but no intersection
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,1)),
line2df(vector2df(2,2),vector2df(3,3)),
false, vector2df());
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(1,0)),
line2df(vector2df(2,0),vector2df(3,0)),
false, vector2df());
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(0,1)),
line2df(vector2df(0,2),vector2df(0,3)),
false, vector2df());
assert(allExpected);
assert_log(allExpected);
// Overlapping parallel lines
allExpected &= testLines(line2df(vector2df(1,0),vector2df(2,0)),
line2df(vector2df(0,0),vector2df(3,0)),
true, vector2df(1.5f, 0));
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,1),vector2df(0,2)),
line2df(vector2df(0,0),vector2df(0,3)),
true, vector2df(0, 1.5f));
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(1,0),vector2df(2,0)),
line2df(vector2df(0,0),vector2df(3,0)),
true, vector2df(1.5f, 0));
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,1),vector2df(0,2)),
line2df(vector2df(0,0),vector2df(0,3)),
true, vector2df(0, 1.5f));
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(1,1),vector2df(2,2)),
line2df(vector2df(0,0),vector2df(3,3)),
true, vector2df(1.5f, 1.5f));
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(1,2),vector2df(2,1)),
line2df(vector2df(0,3),vector2df(3,0)),
true, vector2df(1.5f, 1.5f));
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(10,8)),
line2df(vector2df(2.5f,2.0f),vector2df(5.0f,4.0f)),
true, vector2df(3.75f, 3.0f));
assert(allExpected);
assert_log(allExpected);
allExpected &= testLines(line2df(vector2df(0,0),vector2df(2000,1000)),
line2df(vector2df(2,1),vector2df(2.2f,1.4f)),
true, vector2df(2.0f, 1.0f));
assert(allExpected);
assert_log(allExpected);
if(!allExpected)
logTestString("\nline2dIntersectWith failed\n");
......
#include "testUtils.h"
#include "irrlicht.h"
#include <assert.h>
using namespace irr;
using namespace core;
......
......@@ -14,6 +14,15 @@
for (u32 i=video::EDT_DIRECT3D8; i<video::EDT_COUNT; ++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
/** \param fileName1 The first file for comparison.
\param fileName2 The second file for comparison.
......
......@@ -14,7 +14,7 @@ static bool compareVectors(const core::vector2d<T> & compare,
{
logTestString("\nERROR: vector2d %.16f, %.16f != vector2d %.16f, %.16f\n",
(f64)compare.X, (f64)compare.Y, (f64)with.X, (f64)with.Y);
assert(compare == with);
assert_log(compare == with);
return false;
}
......@@ -32,7 +32,7 @@ static bool doTests()
if(!equals(vec.getDistanceFrom(otherVec), (T)15.8113883))
{
logTestString("vector2d::getDistanceFrom() failed\n");
assert(0);
assert_log(0);
return false;
}
......
......@@ -99,7 +99,7 @@ static bool equalVectors(const S& compare,
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)with.X, (f64)with.Y, (f64)with.Z);
assert(compare(with));
assert_log(compare(with));
return false;
}
......@@ -211,7 +211,7 @@ static bool doTests()
if(!vec.equals(otherVec, (T)0.1))
{
logTestString("vector3d::equals failed\n");
assert(0);
assert_log(0);
return false;
}
......@@ -220,7 +220,7 @@ static bool doTests()
if(!equals(vec.getDistanceFrom(otherVec), (T)15.8113883))
{
logTestString("vector3d::getDistanceFrom() failed\n");
assert(0);
assert_log(0);
return false;
}
......
Tests finished. 1 test of 1 passed.
Compiled as DEBUG
Test suite pass at GMT Mon Feb 20 19:21:21 2012
Compiled as RELEASE
Test suite pass at GMT Tue Apr 3 20:04:39 2012
......@@ -3,7 +3,6 @@
#include "testUtils.h"
#include <irrlicht.h>
#include <assert.h>
using namespace irr;
using namespace core;
......@@ -273,7 +272,6 @@ static bool isPointInsideWithSinglePrecision()
}
// Test the functionality of triangle3d<T>
/** Validation is done with asserts() against expected results. */
bool testTriangle3d(void)
{
bool allExpected = true;
......
......@@ -24,43 +24,43 @@ static bool doTest(void)
result &= (vector == dimension); // The conversion should be explicit.
result &= (dimension2 == position);
result &= (position == POSITION((T)99.9, (T)99.9));
assert(result);
assert_log(result);
dimension = (T)2 * position;
result &= (dimension == VECTOR(2 * (T)99.9, 2 * (T)99.9));
assert(result);
assert_log(result);
dimension /= (T)2;
result &= (dimension == POSITION((T)99.9, (T)99.9));
assert(result);
assert_log(result);
dimension += vector;
result &= (dimension == VECTOR(2 * (T)99.9, 2 * (T)99.9));
assert(result);
assert_log(result);
dimension -= position;
result &= (dimension == POSITION((T)99.9, (T)99.9));
assert(result);
assert_log(result);
position = dimension;
result &= (position == VECTOR((T)99.9, (T)99.9));
assert(result);
assert_log(result);
vector += position;
result &= (vector == POSITION(2 * (T)99.9, 2 * (T)99.9));
assert(result);
assert_log(result);
vector -= position;
result &= (vector == dimension);
assert(result);
assert_log(result);
position *= (T)3.5;
result &= (position == VECTOR((T)3.5 * (T)99.9, (T)3.5 * (T)99.9));
assert(result);
assert_log(result);
vector += dimension;
result &= (vector == VECTOR(2 * (T)99.9, 2 * (T)99.9));
assert(result);
assert_log(result);
return result;
}
......
......@@ -57,7 +57,7 @@ bool writeImageToFile(void)
if (!screenshot)
{
logTestString("Failed to take screenshot\n");
assert(false);
assert_log(false);
goto cleanup;
}
......@@ -72,7 +72,7 @@ bool writeImageToFile(void)
if (!fixedScreenshot)
{
logTestString("Failed to convert screenshot to ECF_A8R8G8B8\n");
assert(false);
assert_log(false);
goto cleanup;
}
......@@ -85,7 +85,7 @@ bool writeImageToFile(void)
if (!driver->writeImageToFile(screenshot, memoryFile))
{
logTestString("Failed to write png to memory file\n");
assert(false);
assert_log(false);
goto cleanup;
}
......@@ -93,14 +93,14 @@ bool writeImageToFile(void)
if (!writtenFile)
{
logTestString("Can't open %s for writing.\n", writtenFilename);
assert(false);
assert_log(false);
goto cleanup;
}
if (memoryFile->getPos() != writtenFile->write(buffer, memoryFile->getPos()))
{
logTestString("Error while writing to %s.\n", writtenFilename);
assert(false);
assert_log(false);
goto cleanup;
}
......@@ -111,7 +111,7 @@ bool writeImageToFile(void)
if (!binaryCompareFiles(writtenFilename, referenceFilename))
{
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;
}
......
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