mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 04:41:16 +00:00
Include property nodes in the long key check (#1140)
This commit is contained in:
@@ -533,7 +533,8 @@ void Emitter::BlockMapPrepareNode(EmitterNodeType::value child) {
|
|||||||
if (m_pState->GetMapKeyFormat() == LongKey)
|
if (m_pState->GetMapKeyFormat() == LongKey)
|
||||||
m_pState->SetLongKey();
|
m_pState->SetLongKey();
|
||||||
if (child == EmitterNodeType::BlockSeq ||
|
if (child == EmitterNodeType::BlockSeq ||
|
||||||
child == EmitterNodeType::BlockMap)
|
child == EmitterNodeType::BlockMap ||
|
||||||
|
child == EmitterNodeType::Property)
|
||||||
m_pState->SetLongKey();
|
m_pState->SetLongKey();
|
||||||
|
|
||||||
if (m_pState->CurGroupLongKey())
|
if (m_pState->CurGroupLongKey())
|
||||||
|
@@ -431,6 +431,38 @@ TEST_F(EmitterTest, BlockMapAsKey) {
|
|||||||
ExpectEmit("? key: value\n next key: next value\n: total value");
|
ExpectEmit("? key: value\n next key: next value\n: total value");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(EmitterTest, TaggedBlockMapAsKey) {
|
||||||
|
out << BeginMap;
|
||||||
|
out << Key;
|
||||||
|
out << LocalTag("innerMap");
|
||||||
|
out << BeginMap;
|
||||||
|
out << Key << "key" << Value << "value";
|
||||||
|
out << EndMap;
|
||||||
|
out << Value;
|
||||||
|
out << "outerValue";
|
||||||
|
out << EndMap;
|
||||||
|
|
||||||
|
ExpectEmit(R"(? !innerMap
|
||||||
|
key: value
|
||||||
|
: outerValue)");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(EmitterTest, TaggedBlockListAsKey) {
|
||||||
|
out << BeginMap;
|
||||||
|
out << Key;
|
||||||
|
out << LocalTag("innerList");
|
||||||
|
out << BeginSeq;
|
||||||
|
out << "listItem";
|
||||||
|
out << EndSeq;
|
||||||
|
out << Value;
|
||||||
|
out << "outerValue";
|
||||||
|
out << EndMap;
|
||||||
|
|
||||||
|
ExpectEmit(R"(? !innerList
|
||||||
|
- listItem
|
||||||
|
: outerValue)");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(EmitterTest, AliasAndAnchor) {
|
TEST_F(EmitterTest, AliasAndAnchor) {
|
||||||
out << BeginSeq;
|
out << BeginSeq;
|
||||||
out << Anchor("fred");
|
out << Anchor("fred");
|
||||||
@@ -520,7 +552,7 @@ TEST_F(EmitterTest, VerbatimTagInBlockMap) {
|
|||||||
out << Value << VerbatimTag("!waz") << "baz";
|
out << Value << VerbatimTag("!waz") << "baz";
|
||||||
out << EndMap;
|
out << EndMap;
|
||||||
|
|
||||||
ExpectEmit("!<!foo> bar: !<!waz> baz");
|
ExpectEmit("? !<!foo> bar\n: !<!waz> baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(EmitterTest, VerbatimTagInFlowMap) {
|
TEST_F(EmitterTest, VerbatimTagInFlowMap) {
|
||||||
|
Reference in New Issue
Block a user