Commit 01b2d463 authored by Milo Yip's avatar Milo Yip

Fix #573

parent 91fabf04
...@@ -1649,7 +1649,6 @@ public: ...@@ -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. /*! \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 { float GetFloat() const {
RAPIDJSON_ASSERT(IsFloat());
return static_cast<float>(GetDouble()); return static_cast<float>(GetDouble());
} }
......
...@@ -652,6 +652,10 @@ TEST(Value, Float) { ...@@ -652,6 +652,10 @@ TEST(Value, Float) {
z.SetFloat(12.34f); z.SetFloat(12.34f);
EXPECT_NEAR(12.34f, z.GetFloat(), 0.0f); EXPECT_NEAR(12.34f, z.GetFloat(), 0.0f);
// Issue 573
z.SetInt(0);
EXPECT_EQ(0.0f, z.GetFloat());
z = 56.78f; z = 56.78f;
EXPECT_NEAR(56.78f, z.GetFloat(), 0.0f); EXPECT_NEAR(56.78f, z.GetFloat(), 0.0f);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment