Update of /cvsroot/cppunit/cppunit2/src/cpput
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5777/src/cpput
Modified Files:
properties.cpp
Log Message:
Made Value operator == deal nicely with int/unsigned int value comparison.
Index: properties.cpp
===================================================================
RCS file: /cvsroot/cppunit/cppunit2/src/cpput/properties.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** properties.cpp 1 Jul 2005 20:32:04 -0000 1.12
--- properties.cpp 2 Jul 2005 09:19:06 -0000 1.13
***************
*** 464,485 ****
Value::operator ==( const Value &other ) const
{
! if ( type() != other.type() )
! return false;
switch ( type() )
{
case vtNone:
! return true;
case vtBoolean:
! return asBool() == other.asBool();
case vtSignedInteger:
! return guts_.intValue_ == other.guts_.intValue_;
case vtUnsignedInteger:
! return guts_.uintValue_ == other.guts_.uintValue_;
case vtReal:
! return guts_.realValue_ == other.guts_.realValue_;
case vtString:
! return asString() == other.asString();
case vtProperties:
! return asProperties() == other.asProperties();
default: // unreachable
CPPTL_DEBUG_ASSERT_UNREACHABLE;
--- 464,502 ----
Value::operator ==( const Value &other ) const
{
! const StorageUInt maxInt = StorageUInt(-1) >> 1;
switch ( type() )
{
case vtNone:
! return type() == other.type();
case vtBoolean:
! return type() == other.type()
! && asBool() == other.asBool();
case vtSignedInteger:
! {
! if ( type() == other.type() && guts_.intValue_ == other.guts_.intValue_ )
! return true;
!
! if ( other.type() == vtUnsignedInteger && other.guts_.uintValue_ <= maxInt )
! return guts_.intValue_ == other.guts_.intValue_;
! return false;
! }
case vtUnsignedInteger:
! {
! if ( type() == other.type() && guts_.uintValue_ == other.guts_.uintValue_ )
! return true;
!
! if ( other.type() == vtSignedInteger && guts_.uintValue_ <= maxInt )
! return guts_.intValue_ == other.guts_.intValue_;
! return false;
! }
case vtReal:
! return type() == other.type()
! && guts_.realValue_ == other.guts_.realValue_;
case vtString:
! return type() == other.type()
! && asString() == other.asString();
case vtProperties:
! return type() == other.type()
! && asProperties() == other.asProperties();
default: // unreachable
CPPTL_DEBUG_ASSERT_UNREACHABLE;
|