Value::compare() is now const and has an actual implementation with unit tests.

This commit is contained in:
Baptiste Lepilleur
2011-05-02 20:11:48 +00:00
parent e3cc0f004b
commit 1837a1c508
4 changed files with 38 additions and 29 deletions

View File

@@ -524,35 +524,16 @@ Value::type() const
int
Value::compare( const Value &other )
Value::compare( const Value &other ) const
{
/*
int typeDelta = other.type_ - type_;
switch ( type_ )
{
case nullValue:
return other.type_ == type_;
case intValue:
if ( other.type_.isNumeric()
case uintValue:
case realValue:
case booleanValue:
break;
case stringValue,
break;
case arrayValue:
delete value_.array_;
break;
case objectValue:
delete value_.map_;
default:
JSON_ASSERT_UNREACHABLE;
}
*/
return 0; // unreachable
if ( *this < other )
return -1;
if ( *this > other )
return 1;
return 0;
}
bool
Value::operator <( const Value &other ) const
{
@@ -594,7 +575,7 @@ Value::operator <( const Value &other ) const
default:
JSON_ASSERT_UNREACHABLE;
}
return 0; // unreachable
return false; // unreachable
}
bool
@@ -656,7 +637,7 @@ Value::operator ==( const Value &other ) const
default:
JSON_ASSERT_UNREACHABLE;
}
return 0; // unreachable
return false; // unreachable
}
bool