From 47c32eee6b485c93b048af7b18351f6b2d29283d Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Sun, 31 Aug 2014 18:55:08 +0200 Subject: [PATCH 1/2] valuetest: add test for Uint64 comparisons --- test/unittest/valuetest.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/unittest/valuetest.cpp b/test/unittest/valuetest.cpp index 9324813..e165452 100644 --- a/test/unittest/valuetest.cpp +++ b/test/unittest/valuetest.cpp @@ -135,6 +135,11 @@ TEST(Value, equalto_operator) { TestEqual(x, y); TestEqual(y, z); TestEqual(z, x); + + // Issue #129: compare Uint64 + x.SetUint64(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFF0)); + y.SetUint64(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFFF)); + TestUnequal(x, y); } template From fd2ba0bc44c97147694cce5c5e965bb7d2f370d5 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Sun, 31 Aug 2014 18:58:14 +0200 Subject: [PATCH 2/2] GenericValue: fix comparison of (Ui|I)nt64 numbers Some 64-bit integers cannot be represented losslessly as a double. Due to a typo in the operator==, the comparison has been performed after a double conversion in too many cases. --- include/rapidjson/document.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 92c7316..ec7f8a6 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -662,7 +662,7 @@ public: return StringEqual(rhs); case kNumberType: - if (IsDouble() || rhs.GetDouble()) + if (IsDouble() || rhs.IsDouble()) return GetDouble() == rhs.GetDouble(); // May convert one operand from integer to double. else return data_.n.u64 == rhs.data_.n.u64;