From 01b2d463f745e6019ad32ea2e0e8e3d51def0d38 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Sat, 5 Mar 2016 10:34:00 +0800 Subject: [PATCH] Fix #573 --- include/rapidjson/document.h | 1 - test/unittest/valuetest.cpp | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index d1f1b6f..855543e 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -1649,7 +1649,6 @@ public: /*! \note If the value is 64-bit integer type, it may lose precision. Use \c IsLosslessFloat() to check whether the converison is lossless. */ float GetFloat() const { - RAPIDJSON_ASSERT(IsFloat()); return static_cast(GetDouble()); } diff --git a/test/unittest/valuetest.cpp b/test/unittest/valuetest.cpp index 9d3609d..d6c7492 100644 --- a/test/unittest/valuetest.cpp +++ b/test/unittest/valuetest.cpp @@ -652,6 +652,10 @@ TEST(Value, Float) { z.SetFloat(12.34f); EXPECT_NEAR(12.34f, z.GetFloat(), 0.0f); + // Issue 573 + z.SetInt(0); + EXPECT_EQ(0.0f, z.GetFloat()); + z = 56.78f; EXPECT_NEAR(56.78f, z.GetFloat(), 0.0f);