mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-20 22:31:23 +01:00
fix(DynamicStruct): toString not wrapping empty strings #3835
This commit is contained in:
parent
a2c09c29d8
commit
9c8a92da3d
@ -72,6 +72,10 @@ void appendJSONValue(std::string& val, const Var& any, bool wrap)
|
||||
{
|
||||
val.append("null");
|
||||
}
|
||||
else if (any.isString() && any.extract<std::string>().empty())
|
||||
{
|
||||
val.append("\"\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isStr = wrap && isJSONString(any);
|
||||
|
@ -2286,6 +2286,15 @@ void VarTest::testOrderedDynamicStructBasics()
|
||||
}
|
||||
|
||||
|
||||
void VarTest::testDynamicStructEmptyString()
|
||||
{
|
||||
DynamicStruct aStruct;
|
||||
aStruct["Empty"] = "";
|
||||
aStruct["Space"] = " ";
|
||||
assertEqual(aStruct.toString(false), "{ \"Empty\": \"\", \"Space\": \" \" }");
|
||||
}
|
||||
|
||||
|
||||
void VarTest::testDynamicStructNoEscapeString()
|
||||
{
|
||||
DynamicStruct aStruct;
|
||||
@ -3139,6 +3148,7 @@ CppUnit::Test* VarTest::suite()
|
||||
CppUnit_addTest(pSuite, VarTest, testDynamicPair);
|
||||
CppUnit_addTest(pSuite, VarTest, testDynamicStructBasics);
|
||||
CppUnit_addTest(pSuite, VarTest, testOrderedDynamicStructBasics);
|
||||
CppUnit_addTest(pSuite, VarTest, testDynamicStructEmptyString);
|
||||
CppUnit_addTest(pSuite, VarTest, testDynamicStructNoEscapeString);
|
||||
CppUnit_addTest(pSuite, VarTest, testDynamicStructString);
|
||||
CppUnit_addTest(pSuite, VarTest, testOrderedDynamicStructString);
|
||||
|
@ -57,6 +57,7 @@ public:
|
||||
void testDynamicStructBasics();
|
||||
void testOrderedDynamicStructBasics();
|
||||
void testDynamicStructString();
|
||||
void testDynamicStructEmptyString();
|
||||
void testDynamicStructNoEscapeString();
|
||||
void testOrderedDynamicStructString();
|
||||
void testDynamicStructInt();
|
||||
|
Loading…
x
Reference in New Issue
Block a user