Change IsDouble method: return true if value has integer type

This commit is contained in:
Oleg Korshul
2024-06-02 15:37:04 +03:00
parent 7a1a59a883
commit cd5ca284e1
2 changed files with 3 additions and 2 deletions

View File

@ -65,7 +65,7 @@ namespace NSJSON
bool CPrimitive::isDouble() const
{
return m_type == ptDouble;
return m_type == ptDouble || m_type == ptInteger;
}
bool CPrimitive::isStringA() const

View File

@ -247,7 +247,8 @@ TEST_F(CJSONTest, bool_)
TEST_F(CJSONTest, int_)
{
CValue val = 42;
EXPECT_FALSE(val.IsDouble());
EXPECT_TRUE(val.IsDouble());
EXPECT_TRUE(val.IsInt());
JSSmart<CJSValue> jsVal = CJSContext::createInt(42);
EXPECT_TRUE(compare(val, jsVal));
val = 100;