Update of /cvsroot/cppunit/cppunit2/src/opentest
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6317/src/opentest
Modified Files:
serializer.cpp
Log Message:
* added more unit tests for serializer
* fixed bugs
* added strict operator == for Value and Properties.
Index: serializer.cpp
===================================================================
RCS file: /cvsroot/cppunit/cppunit2/src/opentest/serializer.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** serializer.cpp 1 Jul 2005 08:19:36 -0000 1.4
--- serializer.cpp 1 Jul 2005 20:32:04 -0000 1.5
***************
*** 41,45 ****
ccNegativeReal = 0x2f, // '/'
ccIntegerZero = 0x30, // integer shift for encoding
! ccIntegerBaseShift = 6 // power of 2 for encoding base (0x40 = 1 << 6)
};
--- 41,47 ----
ccNegativeReal = 0x2f, // '/'
ccIntegerZero = 0x30, // integer shift for encoding
! ccIntegerBaseShift = 6, // power of 2 for encoding base (0x40 = 1 << 6)
! ccRealWithinPlusSign = 0x5e, // '^'
! ccRealWithinMinusSign = 0x5f, // '_'
};
***************
*** 428,438 ****
char buffer[precision * 2 + 32];
int length = sprintf(buffer, "%.*g", precision, value);
char *end = buffer + length;
! for ( char *current = &buffer[0]; current != end; ++current )
{
if ( *current == ccPositiveInteger )
! *current = ccPositiveReal;
else if ( *current == ccNegativeInteger )
! *current = ccNegativeReal;
else if ( *current == ccRealDot )
{ // do nothing
--- 430,443 ----
char buffer[precision * 2 + 32];
int length = sprintf(buffer, "%.*g", precision, value);
+ if ( length == 0)
+ return setError( "Failed to serialize double value (empty string)" );
+ char *current = &buffer[0];
char *end = buffer + length;
! for ( ; current != end; ++current )
{
if ( *current == ccPositiveInteger )
! *current = ccRealWithinPlusSign;
else if ( *current == ccNegativeInteger )
! *current = ccRealWithinMinusSign;
else if ( *current == ccRealDot )
{ // do nothing
***************
*** 444,448 ****
}
}
! if ( buffer[0] == ccNegativeReal )
{
write( ccNegativeReal );
--- 449,453 ----
}
}
! if ( buffer[0] == ccRealWithinMinusSign )
{
write( ccNegativeReal );
***************
*** 452,456 ****
{
write( ccPositiveReal );
! write( buffer, length );
}
return *this;
--- 457,464 ----
{
write( ccPositiveReal );
! if ( buffer[0] == ccRealWithinPlusSign )
! write( buffer + 1, length-1 );
! else
! write( buffer, length );
}
return *this;
***************
*** 462,465 ****
--- 470,474 ----
{
doSerializeInteger( ccString, str.length() );
+ write( ccString );
write( str.c_str(), str.length() );
return *this;
***************
*** 594,600 ****
{
unsigned char digit = readNextByte();
! if ( digit == ccPositiveReal )
buffer += "+";
! else if ( digit == ccNegativeReal )
buffer += "-";
else if ( digit == ccRealDot || digit >= ccIntegerZero )
--- 603,609 ----
{
unsigned char digit = readNextByte();
! if ( digit == ccRealWithinPlusSign )
buffer += "+";
! else if ( digit == ccRealWithinMinusSign )
buffer += "-";
else if ( digit == ccRealDot || digit >= ccIntegerZero )
***************
*** 660,664 ****
LargestUnsignedInt length;
doUnserializeInteger( length );
! if ( length <= sizeof(stringBuffer_) )
{
read( stringBuffer_, length );
--- 669,676 ----
LargestUnsignedInt length;
doUnserializeInteger( length );
! unsigned char control = readNextByte();
! if ( control != ccString )
! setError( "Expected string." );
! else if ( length <= sizeof(stringBuffer_) )
{
read( stringBuffer_, length );
|