Update of /cvsroot/cppunit/cppunit2/src/opentesttest
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6317/src/opentesttest
Modified Files:
serializertest.cpp serializertest.h
Log Message:
* added more unit tests for serializer
* fixed bugs
* added strict operator == for Value and Properties.
Index: serializertest.h
===================================================================
RCS file: /cvsroot/cppunit/cppunit2/src/opentesttest/serializertest.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** serializertest.h 1 Jul 2005 08:19:37 -0000 1.1
--- serializertest.h 1 Jul 2005 20:32:04 -0000 1.2
***************
*** 10,13 ****
--- 10,17 ----
CPPUT_TEST( testBasicInteger );
CPPUT_TEST( testMinMaxInteger );
+ CPPUT_TEST( testReal );
+ CPPUT_TEST( testString );
+ CPPUT_TEST( testBool );
+ CPPUT_TEST( testBasicValue );
CPPUT_TESTSUITE_END();
***************
*** 22,25 ****
--- 26,34 ----
void testBasicInteger();
void testMinMaxInteger();
+ void testReal();
+ void testString();
+ void testBool();
+ void testBasicValue();
+
private:
void prepareSerialize();
Index: serializertest.cpp
===================================================================
RCS file: /cvsroot/cppunit/cppunit2/src/opentesttest/serializertest.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** serializertest.cpp 1 Jul 2005 08:19:37 -0000 1.1
--- serializertest.cpp 1 Jul 2005 20:32:04 -0000 1.2
***************
*** 1,4 ****
--- 1,14 ----
#include "serializertest.h"
#include <cpput/assert.h>
+ #include <cpput/assertstring.h>
+
+ namespace CppUT {
+ // converter for assert equal
+ inline std::string convertToString( const OpenTest::Value &value )
+ {
+ return value.toString().c_str();
+ }
+
+ } // namespace CppUT {
***************
*** 72,73 ****
--- 82,143 ----
CPPUT_ASSERT_EQUAL( minInt, y );
}
+
+
+ void
+ SerializerTest::testReal()
+ {
+ double x1 = 1.23456789;
+ double x2 = 12345678.9;
+ streamOut_ << x1 << x2;
+ prepareUnserialize();
+ double x, y;
+ streamIn_ >> x >> y;
+ CPPUT_ASSERT_EQUAL( x1, x );
+ CPPUT_ASSERT_EQUAL( x2, y );
+ }
+
+
+ void
+ SerializerTest::testString()
+ {
+ OpenTest::String empty;
+ OpenTest::String text = "abcdefhjk.123798+-,_()[]\"'";
+ streamOut_ << text << empty;
+ prepareUnserialize();
+ OpenTest::String s1, s2;
+ streamIn_ >> s1 >> s2;
+ CPPUT_ASSERTSTR_EQUAL( text, s1 );
+ CPPUT_ASSERTSTR_EQUAL( empty, s2 );
+ }
+
+
+ void
+ SerializerTest::testBool()
+ {
+ streamOut_ << true << false;
+ prepareUnserialize();
+ bool x, y;
+ streamIn_ >> x >> y;
+ CPPUT_ASSERT_EQUAL( true, x );
+ CPPUT_ASSERT_EQUAL( false, y );
+ }
+
+
+ void
+ SerializerTest::testBasicValue()
+ {
+ OpenTest::Value vEmpty;
+ OpenTest::Value vUInt( 123456789 );
+ OpenTest::Value vInt( -123456789 );
+ OpenTest::Value vDouble( 1.2345678 );
+ OpenTest::Value vString( "abcdefghijklmnopqrstuvwxyz" );
+ streamOut_ << vEmpty << vUInt << vInt << vDouble << vString;
+ prepareUnserialize();
+ OpenTest::Value v1, v2, v3, v4, v5;
+ streamIn_ >> v1 >> v2 >> v3 >> v4 >> v5;
+ CPPUT_ASSERT_EQUAL( vEmpty, v1 );
+ CPPUT_ASSERT_EQUAL( vUInt, v2 );
+ CPPUT_ASSERT_EQUAL( vInt, v3 );
+ CPPUT_ASSERT_EQUAL( vDouble, v4 );
+ CPPUT_ASSERT_EQUAL( vString, v5 );
+ }
|