"...composable_kernel.git" did not exist on "f6c211681a9eeab7b97d3b42aa1640f9e673ab9e"
Unverified Commit 72fe73a1 authored by Chen's avatar Chen Committed by GitHub
Browse files

fix issue752: generate right long keys (#879)

* fix issue752: generate right long keys

* Improve the readability of test cases

* update to raw string literal
parent a7a7908d
...@@ -556,6 +556,8 @@ void Emitter::BlockMapPrepareLongKey(EmitterNodeType::value child) { ...@@ -556,6 +556,8 @@ void Emitter::BlockMapPrepareLongKey(EmitterNodeType::value child) {
break; break;
case EmitterNodeType::BlockSeq: case EmitterNodeType::BlockSeq:
case EmitterNodeType::BlockMap: case EmitterNodeType::BlockMap:
if (m_pState->HasBegunContent())
m_stream << "\n";
break; break;
} }
} }
...@@ -579,8 +581,12 @@ void Emitter::BlockMapPrepareLongKeyValue(EmitterNodeType::value child) { ...@@ -579,8 +581,12 @@ void Emitter::BlockMapPrepareLongKeyValue(EmitterNodeType::value child) {
case EmitterNodeType::Scalar: case EmitterNodeType::Scalar:
case EmitterNodeType::FlowSeq: case EmitterNodeType::FlowSeq:
case EmitterNodeType::FlowMap: case EmitterNodeType::FlowMap:
SpaceOrIndentTo(true, curIndent + 1);
break;
case EmitterNodeType::BlockSeq: case EmitterNodeType::BlockSeq:
case EmitterNodeType::BlockMap: case EmitterNodeType::BlockMap:
if (m_pState->HasBegunContent())
m_stream << "\n";
SpaceOrIndentTo(true, curIndent + 1); SpaceOrIndentTo(true, curIndent + 1);
break; break;
} }
......
...@@ -686,6 +686,52 @@ TEST_F(EmitterTest, SimpleGlobalSettings) { ...@@ -686,6 +686,52 @@ TEST_F(EmitterTest, SimpleGlobalSettings) {
ExpectEmit("- ? key 1\n : value 1\n ? key 2\n : [a, b, c]"); ExpectEmit("- ? key 1\n : value 1\n ? key 2\n : [a, b, c]");
} }
TEST_F(EmitterTest, GlobalLongKeyOnSeq) {
out.SetMapFormat(LongKey);
out << BeginMap;
out << Key << Anchor("key");
out << BeginSeq << "a"
<< "b" << EndSeq;
out << Value << Anchor("value");
out << BeginSeq << "c"
<< "d" << EndSeq;
out << Key << Alias("key") << Value << Alias("value");
out << EndMap;
ExpectEmit(R"(? &key
- a
- b
: &value
- c
- d
? *key
: *value)");
}
TEST_F(EmitterTest, GlobalLongKeyOnMap) {
out.SetMapFormat(LongKey);
out << BeginMap;
out << Key << Anchor("key");
out << BeginMap << "a"
<< "b" << EndMap;
out << Value << Anchor("value");
out << BeginMap << "c"
<< "d" << EndMap;
out << Key << Alias("key") << Value << Alias("value");
out << EndMap;
ExpectEmit(R"(? &key
? a
: b
: &value
? c
: d
? *key
: *value)");
}
TEST_F(EmitterTest, ComplexGlobalSettings) { TEST_F(EmitterTest, ComplexGlobalSettings) {
out << BeginSeq; out << BeginSeq;
out << Block; out << Block;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment