[Cppunit-cvs] cppunit2/src/cpput properties.cpp,1.11,1.12
Brought to you by:
blep
From: Baptiste L. <bl...@us...> - 2005-07-01 20:32:17
|
Update of /cvsroot/cppunit/cppunit2/src/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6317/src/cpput Modified Files: properties.cpp Log Message: * added more unit tests for serializer * fixed bugs * added strict operator == for Value and Properties. Index: properties.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpput/properties.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** properties.cpp 24 Jun 2005 19:45:49 -0000 1.11 --- properties.cpp 1 Jul 2005 20:32:04 -0000 1.12 *************** *** 461,464 **** --- 461,499 ---- + bool + 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; + return false; + } + } + + + bool + Value::operator !=( const Value &other ) const + { + return !( *this == other ); + } + + // Inline implementation of Property *************** *** 494,497 **** --- 529,546 ---- + bool + Property::operator ==( const Property &other ) const + { + return name_ == other.name_ && value_ == other.value_; + } + + + bool + Property::operator !=( const Property &other ) const + { + return !( *this == other ); + } + + // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// *************** *** 1140,1142 **** --- 1189,1225 ---- } + + bool + Properties::operator ==( const Properties &other ) const + { + if ( properties_.size() != other.properties_.size() + || indexedProperties_.size() != other.indexedProperties_.size() ) + return false; + + PropertyList::const_iterator it = properties_.begin(); + PropertyList::const_iterator itOther = other.properties_.begin(); + for ( ; it != properties_.end(); ++it, ++itOther ) + { + if ( !(*it == *itOther) ) + return false; + } + + IndexedProperties::const_iterator itIndexed = indexedProperties_.begin(); + IndexedProperties::const_iterator itIndexedOther = other.indexedProperties_.begin(); + for ( ; itIndexed != indexedProperties_.end(); ++itIndexed, ++itIndexedOther ) + { + if ( !(*itIndexed == *itIndexedOther) ) + return false; + } + return true; + } + + + bool + Properties::operator !=( const Properties &other ) const + { + return !( *this == other ); + } + + } // namespace OpenTest |