This commit is contained in:
Milo Yip 2016-03-05 10:34:00 +08:00
parent 91fabf0461
commit 01b2d463f7
2 changed files with 4 additions and 1 deletions

View File

@ -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<float>(GetDouble());
}

View File

@ -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);