chore(JSON): add test for #2612

This commit is contained in:
Alex Fabijanic
2022-06-21 10:55:20 +02:00
parent aa71874f2c
commit c77f558d0e
2 changed files with 21 additions and 2 deletions

View File

@@ -2085,6 +2085,24 @@ void JSONTest::testNonEscapeUnicode()
Var longEscape = object->get("longEscape");
assertTrue (shortEscape.convert<std::string>() == shortEscapeStr);
assertTrue (longEscape.convert<std::string>() == longEscapeStr);
Poco::JSON::Object::Ptr json = new Poco::JSON::Object(Poco::JSON_PRESERVE_KEY_ORDER);
Poco::JSON::Object::Ptr json2 = new Poco::JSON::Object(Poco::JSON_PRESERVE_KEY_ORDER);
json->set("value", 15);
json->set("unit", "°C");
assertFalse (json->getEscapeUnicode());
assertFalse (json2->getEscapeUnicode());
json2->set("Temperature", json);
std::ostringstream buffer {};
json->stringify(buffer);
std::string str = buffer.str();
assertEqual (str, R"({"value":15,"unit":"°C"})");
std::ostringstream buffer2 {};
json2->stringify(buffer2);
std::string str2 = buffer2.str();
assertEqual (str2, R"({"Temperature":{"value":15,"unit":"°C"}})");
}