Update of /cvsroot/eas-dev/eas-dev/libs/libsxmlstream/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv15952/tests
Modified Files:
BinaryStreamTest.h Makefile.am
Log Message:
bugfix in binary serialization, binary output test fixed
Index: BinaryStreamTest.h
===================================================================
RCS file: /cvsroot/eas-dev/eas-dev/libs/libsxmlstream/tests/BinaryStreamTest.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- BinaryStreamTest.h 3 Feb 2003 18:59:39 -0000 1.3
+++ BinaryStreamTest.h 4 Feb 2003 04:13:52 -0000 1.4
@@ -10,9 +10,28 @@
#include <cxxtest/TestSuite.h>
#include <sxmlstream.hxx>
+#include <config.h>
+#include <glib.h>
+
using namespace std;
using namespace openeas::sxmlstream;
+#define BIN_LBRACKET "("
+#define BIN_RBRACKET ")"
+
+#define BIN_SIGN_ATTR "@"
+#define BIN_SIGN_NS "!"
+#define BIN_SIGN_CHAR "C"
+#define BIN_SIGN "*"
+
+#if (SIZEOF_SIZE_T == 4) && (G_BYTE_ORDER == G_LITTLE_ENDIAN)
+#define BIN_PORTABLE_SIZE(x) x
+#elif (SIZEOF_SIZE_T == 4) && (G_BYTE_ORDER == G_LITTLE_ENDIAN)
+#define BIN_PORTABLE_SIZE(x) GINT32_TO_LE(x)
+#elif (SIZEOF_SIZE_T == 8)
+#error "64 bit architecture is currently unsupported by libsxmlstream. To be fixed."
+#endif
+
class BinaryStreamTest: public CxxTest::TestSuite
{
SXmlBinaryStream * _stream;
@@ -32,6 +51,7 @@
void test_output()
{
stringstream _output("");
+ stringstream _output_ex("");
// Prepare structures
SXmlNode top = SXmlNode::Element("test");
@@ -41,8 +61,14 @@
_stream->push(top);
_output << (*_stream);
+ _output_ex << BIN_LBRACKET << BIN_SIGN << BIN_PORTABLE_SIZE(strlen("test"))
+ << "test"
+ << BIN_LBRACKET << BIN_SIGN_ATTR << BIN_LBRACKET
+ << BIN_PORTABLE_SIZE(strlen("attr")) << "attr"
+ << BIN_PORTABLE_SIZE(strlen("value")) << "value"
+ << BIN_RBRACKET << BIN_RBRACKET << BIN_RBRACKET;
- TS_ASSERT_EQUALS(_output.str(), "(test (@ (attr \"value\")))");
+ TS_ASSERT_EQUALS(_output.str(), _output_ex.str());
}
};
Index: Makefile.am
===================================================================
RCS file: /cvsroot/eas-dev/eas-dev/libs/libsxmlstream/tests/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Makefile.am 2 Feb 2003 06:59:11 -0000 1.1
+++ Makefile.am 4 Feb 2003 04:13:52 -0000 1.2
@@ -1,8 +1,9 @@
bin_PROGRAMS = runTests
runTests_SOURCES = runTests.cxx
-INCLUDES = -I../include
+INCLUDES = -I../include -I$(top_srcdir)
runTests_LDFLAGS = -L../src/
runTests_LDADD = @GLIB_LIBS@ -lsxmlstream
+CXXFLAGS = @GLIB_CFLAGS@
CLEANFILES = runTests.cxx
|