mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-21 22:56:19 +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");
|
val.append("null");
|
||||||
}
|
}
|
||||||
|
else if (any.isString() && any.extract<std::string>().empty())
|
||||||
|
{
|
||||||
|
val.append("\"\"");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool isStr = wrap && isJSONString(any);
|
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()
|
void VarTest::testDynamicStructNoEscapeString()
|
||||||
{
|
{
|
||||||
DynamicStruct aStruct;
|
DynamicStruct aStruct;
|
||||||
@ -3139,6 +3148,7 @@ CppUnit::Test* VarTest::suite()
|
|||||||
CppUnit_addTest(pSuite, VarTest, testDynamicPair);
|
CppUnit_addTest(pSuite, VarTest, testDynamicPair);
|
||||||
CppUnit_addTest(pSuite, VarTest, testDynamicStructBasics);
|
CppUnit_addTest(pSuite, VarTest, testDynamicStructBasics);
|
||||||
CppUnit_addTest(pSuite, VarTest, testOrderedDynamicStructBasics);
|
CppUnit_addTest(pSuite, VarTest, testOrderedDynamicStructBasics);
|
||||||
|
CppUnit_addTest(pSuite, VarTest, testDynamicStructEmptyString);
|
||||||
CppUnit_addTest(pSuite, VarTest, testDynamicStructNoEscapeString);
|
CppUnit_addTest(pSuite, VarTest, testDynamicStructNoEscapeString);
|
||||||
CppUnit_addTest(pSuite, VarTest, testDynamicStructString);
|
CppUnit_addTest(pSuite, VarTest, testDynamicStructString);
|
||||||
CppUnit_addTest(pSuite, VarTest, testOrderedDynamicStructString);
|
CppUnit_addTest(pSuite, VarTest, testOrderedDynamicStructString);
|
||||||
|
@ -57,6 +57,7 @@ public:
|
|||||||
void testDynamicStructBasics();
|
void testDynamicStructBasics();
|
||||||
void testOrderedDynamicStructBasics();
|
void testOrderedDynamicStructBasics();
|
||||||
void testDynamicStructString();
|
void testDynamicStructString();
|
||||||
|
void testDynamicStructEmptyString();
|
||||||
void testDynamicStructNoEscapeString();
|
void testDynamicStructNoEscapeString();
|
||||||
void testOrderedDynamicStructString();
|
void testOrderedDynamicStructString();
|
||||||
void testDynamicStructInt();
|
void testDynamicStructInt();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user