mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 04:41:16 +00:00
Fix indentation of empty sequences and add test
This commit is contained in:

committed by
Jesse Beder

parent
9eb1142900
commit
c67d701ad8
@@ -213,6 +213,7 @@ void Emitter::EmitEndSeq() {
|
|||||||
if (m_pState->CurGroupFlowType() == FlowType::Flow) {
|
if (m_pState->CurGroupFlowType() == FlowType::Flow) {
|
||||||
if (m_stream.comment())
|
if (m_stream.comment())
|
||||||
m_stream << "\n";
|
m_stream << "\n";
|
||||||
|
if (originalType == FlowType::Block || m_pState->HasBegunNode())
|
||||||
m_stream << IndentTo(m_pState->CurIndent());
|
m_stream << IndentTo(m_pState->CurIndent());
|
||||||
if (originalType == FlowType::Block) {
|
if (originalType == FlowType::Block) {
|
||||||
m_stream << "[";
|
m_stream << "[";
|
||||||
|
@@ -176,6 +176,17 @@ TEST_F(EmitterTest, EmptyFlowSeqWithBegunContent) {
|
|||||||
]])");
|
]])");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(EmitterTest, EmptyFlowSeqInMap) {
|
||||||
|
out << BeginMap;
|
||||||
|
out << Key << Flow << BeginSeq << EndSeq;
|
||||||
|
out << Value << 1;
|
||||||
|
out << Key << 2;
|
||||||
|
out << Value << Flow << BeginSeq << EndSeq;
|
||||||
|
out << EndMap;
|
||||||
|
|
||||||
|
ExpectEmit("[]: 1\n2: []");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(EmitterTest, EmptyFlowMapWithBegunContent) {
|
TEST_F(EmitterTest, EmptyFlowMapWithBegunContent) {
|
||||||
out << Flow;
|
out << Flow;
|
||||||
out << BeginSeq;
|
out << BeginSeq;
|
||||||
|
Reference in New Issue
Block a user