Storage::TypedValue - big int equality bug fix
Reviewers: teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D293
This commit is contained in:
parent
c429923b31
commit
157327de48
@ -460,6 +460,10 @@ TypedValue operator==(const TypedValue &a, const TypedValue &b) {
|
||||
case TypedValue::Type::Bool:
|
||||
return a.Value<bool>() == b.Value<bool>();
|
||||
case TypedValue::Type::Int:
|
||||
if (b.type() == TypedValue::Type::Double)
|
||||
return ToDouble(a) == ToDouble(b);
|
||||
else
|
||||
return a.Value<int64_t>() == b.Value<int64_t>();
|
||||
case TypedValue::Type::Double:
|
||||
return ToDouble(a) == ToDouble(b);
|
||||
case TypedValue::Type::String:
|
||||
|
@ -80,6 +80,11 @@ TEST(TypedValue, Equals) {
|
||||
EXPECT_PROP_EQ(TypedValue(42), TypedValue(42));
|
||||
EXPECT_PROP_NE(TypedValue(0), TypedValue(1));
|
||||
|
||||
// compare two ints close to 2 ^ 62
|
||||
// this will fail if they are converted to float at any point
|
||||
EXPECT_PROP_NE(TypedValue(4611686018427387905),
|
||||
TypedValue(4611686018427387900));
|
||||
|
||||
EXPECT_PROP_NE(TypedValue(0.5), TypedValue(0.12));
|
||||
EXPECT_PROP_EQ(TypedValue(0.123), TypedValue(0.123));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user