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.
......
...@@ -15,16 +15,16 @@ class ScalableFont : public gui::IGUIFontBitmap ...@@ -15,16 +15,16 @@ class ScalableFont : public gui::IGUIFontBitmap
irr::core::stringc m_file_name; irr::core::stringc m_file_name;
bool m_has_alpha; bool m_has_alpha;
float m_scale; float m_scale;
TextureInfo() TextureInfo()
{ {
m_has_alpha = false; m_has_alpha = false;
m_scale = 1.0f; m_scale = 1.0f;
} }
}; };
std::map<int /* texture file ID */, TextureInfo> m_texture_files; std::map<int /* texture file ID */, TextureInfo> m_texture_files;
void lazyLoadTexture(int texID) void lazyLoadTexture(int texID)
{ {
const bool mipmap = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); const bool mipmap = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);
...@@ -33,7 +33,7 @@ class ScalableFont : public gui::IGUIFontBitmap ...@@ -33,7 +33,7 @@ class ScalableFont : public gui::IGUIFontBitmap
SpriteBank->setTexture(texID, Driver->getTexture( m_texture_files[texID].m_file_name )); SpriteBank->setTexture(texID, Driver->getTexture( m_texture_files[texID].m_file_name ));
// set previous mip-map+filter state // set previous mip-map+filter state
Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, mipmap); Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, mipmap);
// couldn't load texture, abort. // couldn't load texture, abort.
if (!SpriteBank->getTexture(texID)) if (!SpriteBank->getTexture(texID))
{ {
...@@ -70,29 +70,29 @@ class ScalableFont : public gui::IGUIFontBitmap ...@@ -70,29 +70,29 @@ class ScalableFont : public gui::IGUIFontBitmap
core::stringc filename = xml->getAttributeValue(L"filename"); core::stringc filename = xml->getAttributeValue(L"filename");
core::stringc fn = filename; core::stringc fn = filename;
u32 i = (u32)xml->getAttributeValueAsInt(L"index"); u32 i = (u32)xml->getAttributeValueAsInt(L"index");
float scale=1.0f; float scale=1.0f;
if (xml->getAttributeValue(L"scale")) if (xml->getAttributeValue(L"scale"))
scale = xml->getAttributeValueAsFloat(L"scale"); scale = xml->getAttributeValueAsFloat(L"scale");
//std::cout << "scale = " << scale << std::endl; //std::cout << "scale = " << scale << std::endl;
core::stringw alpha = xml->getAttributeValue(L"hasAlpha"); core::stringw alpha = xml->getAttributeValue(L"hasAlpha");
//std::cout << "---- Adding font texture " << fn.c_str() << "; alpha=" << alpha.c_str() << std::endl; //std::cout << "---- Adding font texture " << fn.c_str() << "; alpha=" << alpha.c_str() << std::endl;
// make sure the sprite bank has enough textures in it // make sure the sprite bank has enough textures in it
while (i+1 > SpriteBank->getTextureCount()) while (i+1 > SpriteBank->getTextureCount())
{ {
SpriteBank->addTexture(NULL); SpriteBank->addTexture(NULL);
} }
TextureInfo info; TextureInfo info;
info.m_file_name = fn; info.m_file_name = fn;
info.m_has_alpha = (alpha == core::stringw("true")); info.m_has_alpha = (alpha == core::stringw("true"));
info.m_scale = scale; info.m_scale = scale;
m_texture_files[i] = info; m_texture_files[i] = info;
} }
else if (core::stringw(L"c") == xml->getNodeName()) else if (core::stringw(L"c") == xml->getNodeName())
{ {
...@@ -101,16 +101,16 @@ class ScalableFont : public gui::IGUIFontBitmap ...@@ -101,16 +101,16 @@ class ScalableFont : public gui::IGUIFontBitmap
gui::SGUISpriteFrame f; gui::SGUISpriteFrame f;
gui::SGUISprite s; gui::SGUISprite s;
core::rect<s32> rectangle; core::rect<s32> rectangle;
a.underhang = xml->getAttributeValueAsInt(L"u"); a.underhang = xml->getAttributeValueAsInt(L"u");
a.overhang = xml->getAttributeValueAsInt(L"o"); a.overhang = xml->getAttributeValueAsInt(L"o");
a.spriteno = SpriteBank->getSprites().size(); a.spriteno = SpriteBank->getSprites().size();
s32 texno = xml->getAttributeValueAsInt(L"i"); s32 texno = xml->getAttributeValueAsInt(L"i");
// parse rectangle // parse rectangle
core::stringc rectstr = xml->getAttributeValue(L"r"); core::stringc rectstr = xml->getAttributeValue(L"r");
wchar_t ch = xml->getAttributeValue(L"c")[0]; wchar_t ch = xml->getAttributeValue(L"c")[0];
const c8 *c = rectstr.c_str(); const c8 *c = rectstr.c_str();
s32 val; s32 val;
val = 0; val = 0;
...@@ -122,7 +122,7 @@ class ScalableFont : public gui::IGUIFontBitmap ...@@ -122,7 +122,7 @@ class ScalableFont : public gui::IGUIFontBitmap
} }
rectangle.UpperLeftCorner.X = val; rectangle.UpperLeftCorner.X = val;
while (*c == L' ' || *c == L',') c++; while (*c == L' ' || *c == L',') c++;
val = 0; val = 0;
while (*c >= '0' && *c <= '9') while (*c >= '0' && *c <= '9')
{ {
...@@ -132,7 +132,7 @@ class ScalableFont : public gui::IGUIFontBitmap ...@@ -132,7 +132,7 @@ class ScalableFont : public gui::IGUIFontBitmap
} }
rectangle.UpperLeftCorner.Y = val; rectangle.UpperLeftCorner.Y = val;
while (*c == L' ' || *c == L',') c++; while (*c == L' ' || *c == L',') c++;
val = 0; val = 0;
while (*c >= '0' && *c <= '9') while (*c >= '0' && *c <= '9')
{ {
...@@ -142,7 +142,7 @@ class ScalableFont : public gui::IGUIFontBitmap ...@@ -142,7 +142,7 @@ class ScalableFont : public gui::IGUIFontBitmap
} }
rectangle.LowerRightCorner.X = val; rectangle.LowerRightCorner.X = val;
while (*c == L' ' || *c == L',') c++; while (*c == L' ' || *c == L',') c++;
val = 0; val = 0;
while (*c >= '0' && *c <= '9') while (*c >= '0' && *c <= '9')
{ {
...@@ -151,24 +151,24 @@ class ScalableFont : public gui::IGUIFontBitmap ...@@ -151,24 +151,24 @@ class ScalableFont : public gui::IGUIFontBitmap
c++; c++;
} }
rectangle.LowerRightCorner.Y = val; rectangle.LowerRightCorner.Y = val;
CharacterMap[ch] = Areas.size(); CharacterMap[ch] = Areas.size();
// make frame // make frame
f.rectNumber = SpriteBank->getPositions().size(); f.rectNumber = SpriteBank->getPositions().size();
f.textureNumber = texno; f.textureNumber = texno;
// add frame to sprite // add frame to sprite
s.Frames.push_back(f); s.Frames.push_back(f);
s.frameTime = 0; s.frameTime = 0;
// add rectangle to sprite bank // add rectangle to sprite bank
SpriteBank->getPositions().push_back(rectangle); SpriteBank->getPositions().push_back(rectangle);
a.width = rectangle.getWidth(); a.width = rectangle.getWidth();
// add sprite to sprite bank // add sprite to sprite bank
SpriteBank->getSprites().push_back(s); SpriteBank->getSprites().push_back(s);
// add character to font // add character to font
Areas.push_back(a); Areas.push_back(a);
} }
...@@ -179,11 +179,11 @@ class ScalableFont : public gui::IGUIFontBitmap ...@@ -179,11 +179,11 @@ class ScalableFont : public gui::IGUIFontBitmap
public: public:
bool m_black_border; bool m_black_border;
ScalableFont* m_fallback_font; ScalableFont* m_fallback_font;
float m_fallback_font_scale; float m_fallback_font_scale;
int m_fallback_kerning_width; int m_fallback_kerning_width;
//! constructor //! constructor
ScalableFont(gui::IGUIEnvironment *env, const io::path& filename) ScalableFont(gui::IGUIEnvironment *env, const io::path& filename)
: Driver(0), SpriteBank(0), Environment(env), WrongCharacter(0), : Driver(0), SpriteBank(0), Environment(env), WrongCharacter(0),
...@@ -192,7 +192,7 @@ public: ...@@ -192,7 +192,7 @@ public:
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("ScalableFont"); setDebugName("ScalableFont");
#endif #endif
m_fallback_font = NULL; m_fallback_font = NULL;
m_fallback_kerning_width = 0; m_fallback_kerning_width = 0;
m_fallback_font_scale = 1.0f; m_fallback_font_scale = 1.0f;
...@@ -213,14 +213,14 @@ public: ...@@ -213,14 +213,14 @@ public:
Driver->grab(); Driver->grab();
setInvisibleCharacters ( L" " ); setInvisibleCharacters ( L" " );
io::IXMLReader* reader = env->getFileSystem()->createXMLReader(filename.c_str()); io::IXMLReader* reader = env->getFileSystem()->createXMLReader(filename.c_str());
if (reader) if (reader)
{ {
load( reader ); load( reader );
reader->drop(); reader->drop();
} }
assert(Areas.size() > 0); assert_log(Areas.size() > 0);
} }
//! destructor //! destructor
...@@ -239,7 +239,7 @@ public: ...@@ -239,7 +239,7 @@ public:
return false; return false;
doReadXmlFile(xml); doReadXmlFile(xml);
// set bad character // set bad character
WrongCharacter = getAreaIDFromCharacter(L' ', NULL); WrongCharacter = getAreaIDFromCharacter(L' ', NULL);
...@@ -262,7 +262,7 @@ public: ...@@ -262,7 +262,7 @@ public:
bool vcenter=false, const core::rect<s32>* clip=0) bool vcenter=false, const core::rect<s32>* clip=0)
{ {
if (!Driver) return; if (!Driver) return;
core::position2d<s32> offset = position.UpperLeftCorner; core::position2d<s32> offset = position.UpperLeftCorner;
core::dimension2d<s32> text_dimension; core::dimension2d<s32> text_dimension;
...@@ -274,7 +274,7 @@ public: ...@@ -274,7 +274,7 @@ public:
core::array<core::position2di> offsets(text_size); core::array<core::position2di> offsets(text_size);
core::array<bool> fallback; core::array<bool> fallback;
fallback.set_used(text_size); fallback.set_used(text_size);
for (u32 i = 0; i<text_size; i++) for (u32 i = 0; i<text_size; i++)
{ {
wchar_t c = text[i]; wchar_t c = text[i];
...@@ -285,7 +285,7 @@ public: ...@@ -285,7 +285,7 @@ public:
offset.X = position.UpperLeftCorner.X + position.getWidth()/2; offset.X = position.UpperLeftCorner.X + position.getWidth()/2;
continue; continue;
} }
if (c == L'\r' || // Windows breaks if (c == L'\r' || // Windows breaks
c == L'\n') // Unix breaks c == L'\n') // Unix breaks
{ {
...@@ -303,7 +303,7 @@ public: ...@@ -303,7 +303,7 @@ public:
fallback[i] = use_fallback_font; fallback[i] = use_fallback_font;
offset.X += area.underhang; offset.X += area.underhang;
offsets.push_back(offset); offsets.push_back(offset);
// Invisible character. add something to the array anyway so that // Invisible character. add something to the array anyway so that
// indices from the various arrays remain in sync // indices from the various arrays remain in sync
indices.push_back((Invisible.findFirst(c) < 0) ? (int)area.spriteno indices.push_back((Invisible.findFirst(c) < 0) ? (int)area.spriteno
: -1); : -1);
...@@ -313,7 +313,7 @@ public: ...@@ -313,7 +313,7 @@ public:
// ---- do the actual rendering // ---- do the actual rendering
const int indiceAmount = indices.size(); const int indiceAmount = indices.size();
core::array< gui::SGUISprite >& sprites = SpriteBank->getSprites(); core::array< gui::SGUISprite >& sprites = SpriteBank->getSprites();
core::array< core::rect<s32> >& positions = SpriteBank->getPositions(); core::array< core::rect<s32> >& positions = SpriteBank->getPositions();
core::array< gui::SGUISprite >* fallback_sprites; core::array< gui::SGUISprite >* fallback_sprites;
core::array< core::rect<s32> >* fallback_positions; core::array< core::rect<s32> >* fallback_positions;
if (m_fallback_font!=NULL) if (m_fallback_font!=NULL)
...@@ -336,43 +336,43 @@ public: ...@@ -336,43 +336,43 @@ public:
continue; continue;
if (indices[n] == -1) if (indices[n] == -1)
continue; continue;
//assert(sprites[spriteID].Frames.size() > 0); //assert_log(sprites[spriteID].Frames.size() > 0);
const int texID = (fallback[n] ? const int texID = (fallback[n] ?
(*fallback_sprites)[spriteID].Frames[0].textureNumber : (*fallback_sprites)[spriteID].Frames[0].textureNumber :
sprites[spriteID].Frames[0].textureNumber); sprites[spriteID].Frames[0].textureNumber);
core::rect<s32> source = (fallback[n] ? core::rect<s32> source = (fallback[n] ?
(*fallback_positions)[(*fallback_sprites)[spriteID].Frames[0].rectNumber] : (*fallback_positions)[(*fallback_sprites)[spriteID].Frames[0].rectNumber] :
positions[sprites[spriteID].Frames[0].rectNumber]); positions[sprites[spriteID].Frames[0].rectNumber]);
const TextureInfo& info = (fallback[n] ? const TextureInfo& info = (fallback[n] ?
(*(m_fallback_font->m_texture_files.find(texID))).second : (*(m_fallback_font->m_texture_files.find(texID))).second :
(*(m_texture_files.find(texID))).second); (*(m_texture_files.find(texID))).second);
float char_scale = info.m_scale; float char_scale = info.m_scale;
core::dimension2d<s32> size = source.getSize(); core::dimension2d<s32> size = source.getSize();
float scale = (fallback[n] ? m_scale*m_fallback_font_scale : m_scale); float scale = (fallback[n] ? m_scale*m_fallback_font_scale : m_scale);
size.Width = (int)(size.Width * scale * char_scale); size.Width = (int)(size.Width * scale * char_scale);
size.Height = (int)(size.Height * scale * char_scale); size.Height = (int)(size.Height * scale * char_scale);
// align vertically if character is smaller // align vertically if character is smaller
int y_shift = (size.Height < MaxHeight*m_scale ? (int)((MaxHeight*m_scale - size.Height)/2.0f) : 0); int y_shift = (size.Height < MaxHeight*m_scale ? (int)((MaxHeight*m_scale - size.Height)/2.0f) : 0);
core::rect<s32> dest(offsets[n] + core::position2di(0, y_shift), size); core::rect<s32> dest(offsets[n] + core::position2di(0, y_shift), size);
video::SColor colors[] = {color, color, color, color}; video::SColor colors[] = {color, color, color, color};
video::ITexture* texture = (fallback[n] ? video::ITexture* texture = (fallback[n] ?
m_fallback_font->SpriteBank->getTexture(texID) : m_fallback_font->SpriteBank->getTexture(texID) :
SpriteBank->getTexture(texID) ); SpriteBank->getTexture(texID) );
if (texture == NULL) if (texture == NULL)
{ {
// perform lazy loading // perform lazy loading
if (fallback[n]) if (fallback[n])
{ {
m_fallback_font->lazyLoadTexture(texID); m_fallback_font->lazyLoadTexture(texID);
...@@ -383,19 +383,19 @@ public: ...@@ -383,19 +383,19 @@ public:
lazyLoadTexture(texID); lazyLoadTexture(texID);
texture = SpriteBank->getTexture(texID); texture = SpriteBank->getTexture(texID);
} }
if (texture == NULL) if (texture == NULL)
{ {
continue; // no such character continue; // no such character
} }
} }
if (m_black_border) if (m_black_border)
{ {
// draw black border // draw black border
video::SColor black(color.getAlpha(),0,0,0); video::SColor black(color.getAlpha(),0,0,0);
video::SColor black_colors[] = {black, black, black, black}; video::SColor black_colors[] = {black, black, black, black};
for (int x_delta=-2; x_delta<=2; x_delta++) for (int x_delta=-2; x_delta<=2; x_delta++)
{ {
for (int y_delta=-2; y_delta<=2; y_delta++) for (int y_delta=-2; y_delta<=2; y_delta++)
...@@ -406,10 +406,10 @@ public: ...@@ -406,10 +406,10 @@ public:
source, source,
clip, clip,
black_colors, true); black_colors, true);
} }
} }
} }
if (fallback[n]) if (fallback[n])
{ {
// draw text over // draw text over
...@@ -429,7 +429,7 @@ public: ...@@ -429,7 +429,7 @@ public:
source, source,
clip, clip,
colors, true); colors, true);
} }
} }
} }
...@@ -437,8 +437,8 @@ public: ...@@ -437,8 +437,8 @@ public:
//! returns the dimension of a text //! returns the dimension of a text
virtual core::dimension2d<u32> getDimension(const wchar_t* text) const 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> dim(0, 0);
core::dimension2d<u32> thisLine(0, (int)(MaxHeight*m_scale)); core::dimension2d<u32> thisLine(0, (int)(MaxHeight*m_scale));
...@@ -458,9 +458,9 @@ public: ...@@ -458,9 +458,9 @@ public:
bool fallback = false; bool fallback = false;
const SFontArea &area = getAreaFromCharacter(*p, &fallback); const SFontArea &area = getAreaFromCharacter(*p, &fallback);
thisLine.Width += area.underhang; thisLine.Width += area.underhang;
thisLine.Width += getCharWidth(area, fallback); thisLine.Width += getCharWidth(area, fallback);
} }
...@@ -473,7 +473,7 @@ public: ...@@ -473,7 +473,7 @@ public:
dim.Height = (int)(dim.Height + 0.9f); dim.Height = (int)(dim.Height + 0.9f);
//std::cout << dim.Width << ", " << dim.Height << std::endl; //std::cout << dim.Width << ", " << dim.Height << std::endl;
return dim; return dim;
} }
//! Calculates the index of the character in the text which is on a specific position. //! Calculates the index of the character in the text which is on a specific position.
...@@ -557,25 +557,25 @@ private: ...@@ -557,25 +557,25 @@ private:
s32 width; s32 width;
u32 spriteno; u32 spriteno;
}; };
int getCharWidth(const SFontArea& area, const bool fallback) const int getCharWidth(const SFontArea& area, const bool fallback) const
{ {
core::array< gui::SGUISprite >& sprites = SpriteBank->getSprites(); core::array< gui::SGUISprite >& sprites = SpriteBank->getSprites();
core::array< gui::SGUISprite >* fallback_sprites = (m_fallback_font != NULL ? core::array< gui::SGUISprite >* fallback_sprites = (m_fallback_font != NULL ?
&m_fallback_font->SpriteBank->getSprites() : &m_fallback_font->SpriteBank->getSprites() :
NULL); NULL);
const int texID = (fallback ? const int texID = (fallback ?
(*fallback_sprites)[area.spriteno].Frames[0].textureNumber : (*fallback_sprites)[area.spriteno].Frames[0].textureNumber :
sprites[area.spriteno].Frames[0].textureNumber); sprites[area.spriteno].Frames[0].textureNumber);
const TextureInfo& info = (fallback ? const TextureInfo& info = (fallback ?
(*(m_fallback_font->m_texture_files.find(texID))).second : (*(m_fallback_font->m_texture_files.find(texID))).second :
(*(m_texture_files.find(texID))).second); (*(m_texture_files.find(texID))).second);
const float char_scale = info.m_scale; const float char_scale = info.m_scale;
//std::cout << "area.spriteno=" << area.spriteno << ", char_scale=" << char_scale << std::endl; //std::cout << "area.spriteno=" << area.spriteno << ", char_scale=" << char_scale << std::endl;
if (fallback) if (fallback)
return (int)(((area.width + area.overhang)*m_fallback_font_scale + m_fallback_kerning_width) * m_scale * char_scale); return (int)(((area.width + area.overhang)*m_fallback_font_scale + m_fallback_kerning_width) * m_scale * char_scale);
else else
...@@ -607,7 +607,7 @@ private: ...@@ -607,7 +607,7 @@ private:
{ {
const int area_id = getAreaIDFromCharacter(c, fallback_font); const int area_id = getAreaIDFromCharacter(c, fallback_font);
const bool use_fallback_font = (fallback_font && *fallback_font); const bool use_fallback_font = (fallback_font && *fallback_font);
// Note: fallback_font can be NULL // Note: fallback_font can be NULL
return ( use_fallback_font ? m_fallback_font->Areas[area_id] : Areas[area_id]); return ( use_fallback_font ? m_fallback_font->Areas[area_id] : Areas[area_id]);
} // getAreaFromCharacter } // getAreaFromCharacter
...@@ -668,7 +668,7 @@ static bool draw2DImage4c(video::E_DRIVER_TYPE type) ...@@ -668,7 +668,7 @@ static bool draw2DImage4c(video::E_DRIVER_TYPE type)
video::ITexture* images = driver->getTexture("../media/2ddemo.png"); video::ITexture* images = driver->getTexture("../media/2ddemo.png");
driver->makeColorKeyTexture(images, core::position2d<s32>(0,0)); driver->makeColorKeyTexture(images, core::position2d<s32>(0,0));
core::rect<s32> imp1(349,15,385,78); core::rect<s32> imp1(349,15,385,78);
core::rect<s32> imp2(387,15,423,78); core::rect<s32> imp2(387,15,423,78);
...@@ -677,7 +677,7 @@ static bool draw2DImage4c(video::E_DRIVER_TYPE type) ...@@ -677,7 +677,7 @@ static bool draw2DImage4c(video::E_DRIVER_TYPE type)
device->getFileSystem()->changeWorkingDirectoryTo("media"); device->getFileSystem()->changeWorkingDirectoryTo("media");
ScalableFont* font = new ScalableFont(device->getGUIEnvironment(), "title_font.xml"); ScalableFont* font = new ScalableFont(device->getGUIEnvironment(), "title_font.xml");
font->m_fallback_font_scale = 4.0f; font->m_fallback_font_scale = 4.0f;
font->m_fallback_kerning_width = 15; font->m_fallback_kerning_width = 15;
font->setKerningWidth(-18); font->setKerningWidth(-18);
font->m_black_border = true; font->m_black_border = true;
...@@ -687,25 +687,25 @@ static bool draw2DImage4c(video::E_DRIVER_TYPE type) ...@@ -687,25 +687,25 @@ static bool draw2DImage4c(video::E_DRIVER_TYPE type)
*/ */
driver->getMaterial2D().UseMipMaps = true; driver->getMaterial2D().UseMipMaps = true;
driver->getMaterial2D().TextureLayer[0].BilinearFilter = true; driver->getMaterial2D().TextureLayer[0].BilinearFilter = true;
{ {
driver->beginScene(true, true, video::SColor(255,120,102,136)); driver->beginScene(true, true, video::SColor(255,120,102,136));
driver->enableMaterial2D(); driver->enableMaterial2D();
// draw fire & dragons background world // draw fire & dragons background world
driver->draw2DImage(images, core::position2di(), driver->draw2DImage(images, core::position2di(),
core::rect<s32>(0,0,342,224), 0, core::rect<s32>(0,0,342,224), 0,
video::SColor(255,255,255,255), true); video::SColor(255,255,255,255), true);
// draw flying imp // draw flying imp
driver->draw2DImage(images, core::position2d<s32>(114,75), driver->draw2DImage(images, core::position2d<s32>(114,75),
imp1, 0, video::SColor(255,255,255,255), true); imp1, 0, video::SColor(255,255,255,255), true);
// draw second flying imp // draw second flying imp
driver->draw2DImage(images, core::position2d<s32>(220,55), driver->draw2DImage(images, core::position2d<s32>(220,55),
imp2, 0, video::SColor(255,255,255,255), true); imp2, 0, video::SColor(255,255,255,255), true);
driver->draw2DImage(images, core::rect<s32>(10,10,108,48), driver->draw2DImage(images, core::rect<s32>(10,10,108,48),
core::rect<s32>(354,87,442,118)); core::rect<s32>(354,87,442,118));
...@@ -715,15 +715,15 @@ static bool draw2DImage4c(video::E_DRIVER_TYPE type) ...@@ -715,15 +715,15 @@ static bool draw2DImage4c(video::E_DRIVER_TYPE type)
font->draw( L"WXYZsSdDrRjJbB", core::rect<s32>(30,20,300,300), font->draw( L"WXYZsSdDrRjJbB", core::rect<s32>(30,20,300,300),
video::SColor(255,255,255,255) ); video::SColor(255,255,255,255) );
driver->enableMaterial2D(false); driver->enableMaterial2D(false);
driver->draw2DImage(images, core::recti(10,90,108,128), driver->draw2DImage(images, core::recti(10,90,108,128),
core::recti(354,87,442,118), 0, colors, true); core::recti(354,87,442,118), 0, colors, true);
font->draw( L"WXYZsSdDrRjJbB", core::rect<s32>(30,60,300,400), font->draw( L"WXYZsSdDrRjJbB", core::rect<s32>(30,60,300,400),
video::SColor(255,255,255,255) ); video::SColor(255,255,255,255) );
driver->endScene(); driver->endScene();
} }
font->drop(); font->drop();
...@@ -830,7 +830,7 @@ static bool addBlend2d(video::E_DRIVER_TYPE type) ...@@ -830,7 +830,7 @@ static bool addBlend2d(video::E_DRIVER_TYPE type)
device->run(); device->run();
device->drop(); device->drop();
return result; return result;
} }
// This test renders 4 times the same image. Two via IGUIImage, two via draw2DImage // This test renders 4 times the same image. Two via IGUIImage, two via draw2DImage
// 3 of the 4 images are filtered via 2dmaterial and bilinear filter, only the one // 3 of the 4 images are filtered via 2dmaterial and bilinear filter, only the one
...@@ -891,7 +891,7 @@ static bool moreFilterTests(video::E_DRIVER_TYPE type) ...@@ -891,7 +891,7 @@ static bool moreFilterTests(video::E_DRIVER_TYPE type)
device->run(); device->run();
device->drop(); device->drop();
return result; return result;
} }
bool twodmaterial() bool twodmaterial()
{ {
......
...@@ -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