- XML-reader now preserves all whitespace. So even newlines are now returned as EXN_TEXT nodes. Old behavior was dropping those, but it handled unix-style newlines badly and should rather have preserved all whitespace or none. Preserving no whitespace could be useful feature for the future.

- XML documentation updated where documentation and implementation had been different.
- c::b Linux now compiling engine with -fno-exceptions like the Makefile. Should probably use no-rtti as well, but haven't figured out how to do that without getting warnings for every c-file.
- tests now compiling with -fno-exceptions and defines _IRR_STATIC_LIB_ plus _DEBUG
- new function xmlCompareFiles in testUtils to replace binaryCompareFiles for tests with xml-files as binaries always broke with different wchar_t sizes.
- test ioScene now working on Linux-32


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4092 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2012-02-20 19:43:51 +00:00
parent 8b70f7fff4
commit 86e5345306
12 changed files with 219 additions and 38 deletions

View File

@ -1,5 +1,9 @@
Changes in 1.8 (??.??.2011)
- XML-reader now preserves all whitespace. So even newlines are now returned as EXN_TEXT nodes.
- CXMLReader initializes IsEmptyElement now.
- line2d::intersectWith and and line2d::getClosestPoint work now also with integers.
- line2d::getMiddle and line3d::getMiddle work now also with integers. But can be slower for compilers which are not optimizing division by 2 to multiplication by 0.5 for floats.
@ -317,7 +321,7 @@ Changes in 1.7.3 (20.02.2012)
- Additional keymappings for X11 (tested with german and us keyboards which seem to work now in all cases).
- Fix crash in multiline editbox when pasting several lines into it on Windows.
- Fix crash in multiline editbox when pasting several lines into it on Windows (found by Reiko)
- example 09.Meshviewer no longer catches keys while a modal dialog is open

View File

@ -189,7 +189,8 @@ namespace io
//! End of an xml element such as </foo>
EXN_ELEMENT_END,
//! Text within an xml element: <foo> this is the text. <foo>
//! Text within an xml element: <foo> this is the text. </foo>
//! Also text between 2 xml elements: </foo> this is the text. <foo>
EXN_TEXT,
//! An xml comment like <!-- I am a comment --> or a DTD definition.
@ -338,13 +339,13 @@ namespace io
virtual float getAttributeValueAsFloat(int idx) const = 0;
//! Returns the name of the current node.
/** Only non null, if the node type is EXN_ELEMENT.
/** Only valid, if the node type is EXN_ELEMENT.
\return Name of the current node or 0 if the node has no name. */
virtual const char_type* getNodeName() const = 0;
//! Returns data of the current node.
/** Only non null if the node has some
data and it is of type EXN_TEXT or EXN_UNKNOWN. */
/** Only valid if the node has some
data and it is of type EXN_TEXT, EXN_COMMENT, EXN_CDATA or EXN_UNKNOWN. */
virtual const char_type* getNodeData() const = 0;
//! Returns if an element is an empty element, like <foo />

View File

@ -265,9 +265,11 @@ private:
//! sets the state that text was found. Returns true if set should be set
bool setText(char_type* start, char_type* end)
{
// check if text is more than 2 characters, and if not, check if there is
// only white space, so that this text won't be reported
if (end - start < 3)
// By default xml preserves all whitespace.
// We could add evaluation of xml:space commands some day or maybe add
// a flag to preserve/ignore whitespace.
/* This removes text-nodes which are whitespace only:
{
char_type* p = start;
for(; p != end; ++p)
@ -277,6 +279,7 @@ private:
if (p == end)
return false;
}
*/
// set current text to the parsed text, and replace xml special characters
core::string<char_type> s(start, (int)(end - start));
@ -801,7 +804,7 @@ private:
ETEXT_FORMAT SourceFormat; // source format of the xml file
ETEXT_FORMAT TargetFormat; // output format of this parser
core::string<char_type> NodeName; // name of the node currently in
core::string<char_type> NodeName; // name of the node currently in - also used for text
core::string<char_type> EmptyString; // empty string to be returned by getSafe() methods
bool IsEmptyElement; // is the currently parsed node empty?

View File

@ -8,7 +8,7 @@
<Build>
<Target title="Win32 - Debug - dll">
<Option platforms="Windows;" />
<Option output="../../lib/Win32-gcc/libIrrlicht" prefix_auto="1" extension_auto="1" />
<Option output="../../lib/Win32-gcc/Irrlicht" prefix_auto="1" extension_auto="1" />
<Option object_output="../obj/win32-gcc-debug-dll" />
<Option type="3" />
<Option compiler="gcc" />
@ -52,7 +52,7 @@
</Target>
<Target title="Win32 - Release - accurate math - dll">
<Option platforms="Windows;" />
<Option output="../../lib/Win32-gcc/libIrrlicht" prefix_auto="1" extension_auto="1" />
<Option output="../../lib/Win32-gcc/Irrlicht" prefix_auto="1" extension_auto="1" />
<Option object_output="../obj/win32-gcc-release-dll" />
<Option type="3" />
<Option compiler="gcc" />
@ -94,7 +94,7 @@
</Target>
<Target title="Win32 - Release - fast math - dll">
<Option platforms="Windows;" />
<Option output="../../lib/Win32-gcc/libIrrlicht" prefix_auto="1" extension_auto="1" />
<Option output="../../lib/Win32-gcc/Irrlicht" prefix_auto="1" extension_auto="1" />
<Option object_output="../obj/win32-gcc-release-fast-dll" />
<Option type="3" />
<Option compiler="gcc" />
@ -137,7 +137,7 @@
</Target>
<Target title="Win32 - Debug - static">
<Option platforms="Windows;" />
<Option output="../../lib/Win32-gcc/libIrrlicht" prefix_auto="1" extension_auto="1" />
<Option output="../../lib/Win32-gcc/Irrlicht" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option object_output="../obj/win32-gcc-debug-static" />
<Option type="2" />
@ -176,7 +176,7 @@
</Target>
<Target title="Win32 - Release - accurate math - static">
<Option platforms="Windows;" />
<Option output="../../lib/Win32-gcc/libIrrlicht" prefix_auto="1" extension_auto="1" />
<Option output="../../lib/Win32-gcc/Irrlicht" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option object_output="../obj/win32-gcc-release-dll" />
<Option type="2" />
@ -216,7 +216,7 @@
</Target>
<Target title="Win32 - Release - fast math - static">
<Option platforms="Windows;" />
<Option output="../../lib/Win32-gcc/libIrrlicht" prefix_auto="1" extension_auto="1" />
<Option output="../../lib/Win32-gcc/Irrlicht" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option object_output="../obj/win32-gcc-release-fast-static" />
<Option type="2" />
@ -264,13 +264,14 @@
<Option createDefFile="1" />
<Option createStaticLib="1" />
<Compiler>
<Add option="-W" />
<Add option="-Wextra" />
<Add option="-Wall" />
<Add option="-g" />
<Add option="-W" />
<Add option="-O0" />
<Add option="-Wextra" />
<Add option="-Wno-unused-parameter" />
<Add option="-fPIC" />
<Add option="-fno-exceptions" />
<Add option="-D_DEBUG" />
<Add directory="../../include" />
<Add directory="zlib" />
@ -294,10 +295,11 @@
<Option createStaticLib="1" />
<Compiler>
<Add option="-O3" />
<Add option="-W" />
<Add option="-Wextra" />
<Add option="-W" />
<Add option="-Wno-unused-parameter" />
<Add option="-fPIC" />
<Add option="-fno-exceptions" />
<Add directory="../../include" />
<Add directory="zlib" />
<Add directory="libpng" />
@ -320,10 +322,11 @@
<Option createStaticLib="1" />
<Compiler>
<Add option="-O3" />
<Add option="-W" />
<Add option="-Wextra" />
<Add option="-W" />
<Add option="-Wno-unused-parameter" />
<Add option="-ffast-math" />
<Add option="-fno-exceptions" />
<Add directory="../../include" />
<Add directory="zlib" />
<Add directory="libpng" />
@ -345,13 +348,13 @@
<Option compiler="gcc" />
<Option createDefFile="1" />
<Compiler>
<Add option="-W" />
<Add option="-Wextra" />
<Add option="-Wall" />
<Add option="-g" />
<Add option="-W" />
<Add option="-O0" />
<Add option="-Wextra" />
<Add option="-Wno-unused-parameter" />
<Add option="-fPIC" />
<Add option="-fno-exceptions" />
<Add option="-D_IRR_STATIC_LIB_" />
<Add option="-D_DEBUG" />
<Add directory="../../include" />
@ -375,10 +378,10 @@
<Option createDefFile="1" />
<Compiler>
<Add option="-O3" />
<Add option="-W" />
<Add option="-Wextra" />
<Add option="-W" />
<Add option="-Wno-unused-parameter" />
<Add option="-fPIC" />
<Add option="-fno-exceptions" />
<Add option="-D_IRR_STATIC_LIB_" />
<Add directory="../../include" />
<Add directory="zlib" />
@ -401,11 +404,11 @@
<Option createDefFile="1" />
<Compiler>
<Add option="-O3" />
<Add option="-W" />
<Add option="-Wextra" />
<Add option="-W" />
<Add option="-Wno-unused-parameter" />
<Add option="-ffast-math" />
<Add option="-fPIC" />
<Add option="-fno-exceptions" />
<Add option="-D_IRR_STATIC_LIB_" />
<Add directory="../../include" />
<Add directory="zlib" />

View File

@ -4,7 +4,7 @@ Sources = $(wildcard *.cpp)
CPPFLAGS = -I../include -I/usr/X11R6/include -pipe
# CXXFLAGS += -O3
CXXFLAGS += -Wall -ansi -pedantic -O0 -g -D_DEBUG
CXXFLAGS += -Wall -ansi -pedantic -O0 -g -D_DEBUG -fno-exceptions
ifeq ($(HOSTTYPE), x86_64)
LIBSELECT=64

View File

@ -60,11 +60,11 @@ static bool saveScene(void)
logTestString("Test scene.irr");
smgr->saveScene("results/scene.irr");
bool result = binaryCompareFiles("results/scene.irr", "media/scene.irr");
bool result = xmlCompareFiles(device->getFileSystem(), "results/scene.irr", "media/scene.irr");
logTestString("Test scene2.irr");
smgr->saveScene("results/scene2.irr", 0, node3);
result &= binaryCompareFiles("results/scene2.irr", "media/scene2.irr");
result &= xmlCompareFiles(device->getFileSystem(), "results/scene2.irr", "media/scene2.irr");
device->closeDevice();
device->run();

View File

@ -50,7 +50,6 @@ int main(int argumentCount, char * arguments[])
// (temporarily) to the beginning of the list, since each test runs in its own
// process.
TEST(disambiguateTextures); // Normally you should run this first, since it validates the working directory.
// Now the simple tests without device
TEST(testIrrArray);

View File

@ -278,7 +278,7 @@ bool getClosestPoint(void)
irr::core::vector2di p2 = line.getClosestPoint( irr::core::vector2di(135,372) );
if( p1 == p2 )
{
logTestString("\getClosestPoint failed\n");
logTestString("getClosestPoint failed\n");
return false;
}

View File

@ -49,7 +49,7 @@ bool binaryCompareFiles(const char * fileName1, const char * fileName2)
const size_t file2Size = ftell(file2);
if(file1Size != file2Size)
{
logTestString("binaryCompareFiles: Files are different sizes: %d vs %d\n",
logTestString("binaryCompareFiles: Files are different sizes: %d vs %d\n",
file1Size, file2Size);
(void)fclose(file1);
(void)fclose(file2);
@ -86,6 +86,167 @@ bool binaryCompareFiles(const char * fileName1, const char * fileName2)
return filesAreIdentical;
}
bool xmlCompareFiles(irr::io::IFileSystem * fs, const char * fileName1, const char * fileName2)
{
if(!fileName1 || !fileName2)
return false;
io::IXMLReaderUTF8* reader1 = fs->createXMLReaderUTF8(fileName1);
if (!reader1)
{
logTestString("xmlCompareFiles: Could not create a XML reader for '%s'\n", fileName1);
return false;
}
io::IXMLReaderUTF8* reader2 = fs->createXMLReaderUTF8(fileName2);
if (!reader2)
{
logTestString("xmlCompareFiles: Could not create a XML reader for '%s'\n", fileName2);
reader1->drop();
return false;
}
bool different = false;
bool read1 = reader1->read();
bool read2 = reader2->read();
if ( !read1 && !read2 )
{
logTestString("xmlCompareFiles: Both files have no nodes: '%s' %s - is this ok?\n", fileName1, fileName2);
reader1->drop();
reader2->drop();
return true;
}
while (read1 && read2)
{
io::EXML_NODE type1 = reader1->getNodeType();
io::EXML_NODE type2 = reader2->getNodeType();
if ( type1 != type2 )
{
const c8* name1 = reader1->getNodeName();
const c8* name2 = reader2->getNodeName();
logTestString("xmlCompareFiles: file '%s' has different nodes than %s in nodes \"%s\" and \"%s\"\n"
, fileName1, fileName2, name1 ? name1 : "NULL", name2 ? name2 : "NULL");
different = true;
break;
}
if ( reader1->isEmptyElement() != reader2->isEmptyElement() )
{
logTestString("xmlCompareFiles: file '%s' has different empty elements than %s\n", fileName1, fileName2);
different = true;
break;
}
switch ( type1 )
{
case io::EXN_NONE:
case io::EXN_ELEMENT_END:
break;
case io::EXN_ELEMENT:
{
core::stringc name1(reader1->getNodeName());
core::stringc name2(reader2->getNodeName());
if ( name1 != name2 )
{
logTestString("xmlCompareFiles: %s has node %s where %s has node %s\n"
, fileName1, name1.c_str(), fileName2, name2.c_str() );
different = true;
break;
}
unsigned int numAttributes1 = reader1->getAttributeCount();
unsigned int numAttributes2 = reader2->getAttributeCount();
if ( numAttributes1 != numAttributes2 )
{
logTestString("xmlCompareFiles: %s node %s has %d attributes where %s node %s has %d attributes\n"
, fileName1, name1.c_str(), numAttributes1
, fileName2, name2.c_str(), numAttributes2);
different = true;
break;
}
for ( unsigned int i=0; i < numAttributes1; ++i )
{
core::stringc attribName1(reader1->getAttributeName(int(i)));
core::stringc attribName2(reader2->getAttributeName(int(i)));
if ( attribName1 != attribName2 )
{
logTestString("xmlCompareFiles: %s node %s has attribute-name \"%s\" where %s node %s has name \"%s\"\n"
, fileName1, name1.c_str(), attribName1.c_str()
, fileName2, name2.c_str(), attribName2.c_str());
different = true;
break;
}
core::stringc attribVal1(reader1->getAttributeValue(int(i)));
core::stringc attribVal2(reader2->getAttributeValue(int(i)));
if ( attribName1 != attribName2 )
{
logTestString("xmlCompareFiles: %s node %s has attribute-value \"%s\" where %s node %s has value \"%s\"\n"
, fileName1, name1.c_str(), attribVal1.c_str()
, fileName2, name2.c_str(), attribVal2.c_str());
different = true;
break;
}
}
break;
}
case io::EXN_TEXT:
case io::EXN_UNKNOWN:
case io::EXN_COMMENT:
case io::EXN_CDATA:
{
core::stringc nodeData1( reader1->getNodeData() );
core::stringc nodeData2( reader1->getNodeData() );
// removeChars('\r') needed because irrXML doesn't do that (as it probably should)
nodeData1.removeChars(core::stringc('\r'));
nodeData2.removeChars(core::stringc('\r'));
if ( nodeData1 != nodeData2 )
{
logTestString("xmlCompareFiles: %s has data \"%s\" where %s has data \"%s\"\n"
, fileName1, nodeData1.c_str()
, fileName2, nodeData2.c_str());
different = true;
}
break;
}
}
if ( different )
break;
read1 = reader1->read();
read2 = reader2->read();
}
if ( !different && !read1 && !read2 )
{
reader1->drop();
reader2->drop();
return true;
}
if ( !different && read1 )
{
logTestString("xmlCompareFiles: file '%s' has more nodes than %s\n", fileName1, fileName2);
}
if ( !different && read2 )
{
logTestString("xmlCompareFiles: file '%s' has more nodes than %s\n", fileName2, fileName1);
}
reader1->drop();
reader2->drop();
return false;
}
//! Compare two images, returning the degree to which they match.
/** \param image1 The first image to compare.
@ -178,7 +339,7 @@ bool takeScreenshotAndCompareAgainstReference(irr::video::IVideoDriver * driver,
}
irr::core::stringc driverName = driver->getName();
// For OpenGL and Burning, chop the version number out. Other drivers have more stable version numbers.
// TA: Sorry Rogerborg. burnings video also has the version number inside;-)
// maybe you sould take the getDriverType Info for this

View File

@ -20,6 +20,13 @@
\return true if the files are identical, false on any error or difference. */
extern bool binaryCompareFiles(const char * fileName1, const char * fileName2);
//! Compare two xml-files (which can have different types of text-encoding)
/** \param fs Filesystem which should be used.
\param fileName1 The first file for comparison.
\param fileName2 The second file for comparison.
\return true if the files are identical, false on any error or difference. */
extern bool xmlCompareFiles(irr::io::IFileSystem * fs, const char * fileName1, const char * fileName2);
//! Take a screenshot and compare it against a reference screenshot in the tests/media subdirectory
/** \param driver The Irrlicht video driver.
\param fileName The unique filename suffix that will be appended to the name of the video driver.

View File

@ -1,4 +1,4 @@
Tests finished. 2 tests of 2 passed.
Compiled as DEBUG
Test suite pass at GMT Mon Feb 20 17:07:07 2012
Tests finished. 1 test of 1 passed.
Compiled as DEBUG
Test suite pass at GMT Mon Feb 20 19:21:21 2012

View File

@ -38,6 +38,9 @@
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
<Add option="-fno-exceptions" />
<Add option="-D_IRR_STATIC_LIB_" />
<Add option="-D_DEBUG" />
</Compiler>
<Linker>
<Add library="Xxf86vm" />
@ -83,7 +86,6 @@
<Unit filename="irrString.cpp" />
<Unit filename="lightMaps.cpp" />
<Unit filename="lights.cpp" />
<Unit filename="testLine2d.cpp" />
<Unit filename="loadTextures.cpp" />
<Unit filename="main.cpp" />
<Unit filename="makeColorKeyTexture.cpp" />
@ -106,6 +108,7 @@
<Unit filename="terrainSceneNode.cpp" />
<Unit filename="testDimension2d.cpp" />
<Unit filename="testGeometryCreator.cpp" />
<Unit filename="testLine2d.cpp" />
<Unit filename="testQuaternion.cpp" />
<Unit filename="testS3DVertex.cpp" />
<Unit filename="testUtils.cpp" />