fix(JSON::Stringifier): JSON Serializing NAN #3251

This commit is contained in:
Alex Fabijanic
2022-06-22 13:44:00 +02:00
parent 5cbe30e199
commit cafd56a947
3 changed files with 15 additions and 0 deletions

View File

@@ -1586,6 +1586,17 @@ void JSONTest::testStringify()
}
void JSONTest::testStringifyNaN()
{
Object::Ptr o = new Object;
o->set("NaN", NAN);
o->set("Infinity", INFINITY);
std::ostringstream stream;
o->stringify(stream, 0);
assertEqual (stream.str(), std::string(R"({"Infinity":null,"NaN":null})"));
}
void JSONTest::testStringifyPreserveOrder()
{
Object presObj(Poco::JSON_PRESERVE_KEY_ORDER);
@@ -2361,6 +2372,7 @@ CppUnit::Test* JSONTest::suite()
CppUnit_addTest(pSuite, JSONTest, testComment);
CppUnit_addTest(pSuite, JSONTest, testPrintHandler);
CppUnit_addTest(pSuite, JSONTest, testStringify);
CppUnit_addTest(pSuite, JSONTest, testStringifyNaN);
CppUnit_addTest(pSuite, JSONTest, testStringifyPreserveOrder);
CppUnit_addTest(pSuite, JSONTest, testVarConvert);
CppUnit_addTest(pSuite, JSONTest, testValidJanssonFiles);