Emit the correct Alias on the key (#908) (#929)

This commit is contained in:
Chen
2020-07-28 02:49:04 +08:00
committed by GitHub
parent 1c9abc8fa4
commit 98acc5a887
4 changed files with 30 additions and 0 deletions

View File

@@ -430,6 +430,21 @@ TEST_F(EmitterTest, AliasAndAnchor) {
ExpectEmit("- &fred\n name: Fred\n age: 42\n- *fred");
}
TEST_F(EmitterTest, AliasOnKey) {
out << BeginSeq;
out << Anchor("name") << "Name";
out << BeginMap;
out << Key << Alias("name") << Value << "Fred";
out << EndMap;
out << Flow << BeginMap;
out << Key << Alias("name") << Value << "Mike";
out << EndMap;
out << EndSeq;
ExpectEmit(R"(- &name Name
- *name : Fred
- {*name : Mike})");
}
TEST_F(EmitterTest, AliasAndAnchorWithNull) {
out << BeginSeq;
out << Anchor("fred") << Null;