mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-08 12:21:17 +00:00
fix issue743: handle the empty content of flow sep/map correctly during emitting. (#921)
* fix issue743: handle the empty content of flow sep/map correctly during emitting. * handle the empty Tag/Anchor properly. * delete comment
This commit is contained in:
@@ -138,6 +138,56 @@ TEST_F(EmitterTest, EmptyFlowSeq) {
|
||||
ExpectEmit("[]");
|
||||
}
|
||||
|
||||
TEST_F(EmitterTest, EmptyBlockSeqWithBegunContent) {
|
||||
out << BeginSeq;
|
||||
out << BeginSeq << Comment("comment") << EndSeq;
|
||||
out << BeginSeq << Newline << EndSeq;
|
||||
out << EndSeq;
|
||||
|
||||
ExpectEmit(R"(-
|
||||
# comment
|
||||
[]
|
||||
-
|
||||
|
||||
[])");
|
||||
}
|
||||
|
||||
TEST_F(EmitterTest, EmptyBlockMapWithBegunContent) {
|
||||
out << BeginSeq;
|
||||
out << BeginMap << Comment("comment") << EndMap;
|
||||
out << BeginMap << Newline << EndMap;
|
||||
out << EndSeq;
|
||||
|
||||
ExpectEmit(R"(- # comment
|
||||
{}
|
||||
-
|
||||
{})");
|
||||
}
|
||||
|
||||
TEST_F(EmitterTest, EmptyFlowSeqWithBegunContent) {
|
||||
out << Flow;
|
||||
out << BeginSeq;
|
||||
out << BeginSeq << Comment("comment") << EndSeq;
|
||||
out << BeginSeq << Newline << EndSeq;
|
||||
out << EndSeq;
|
||||
|
||||
ExpectEmit(R"([[ # comment
|
||||
], [
|
||||
]])");
|
||||
}
|
||||
|
||||
TEST_F(EmitterTest, EmptyFlowMapWithBegunContent) {
|
||||
out << Flow;
|
||||
out << BeginSeq;
|
||||
out << BeginMap << Comment("comment") << EndMap;
|
||||
out << BeginMap << Newline << EndMap;
|
||||
out << EndSeq;
|
||||
|
||||
ExpectEmit(R"([{ # comment
|
||||
}, {
|
||||
}])");
|
||||
}
|
||||
|
||||
TEST_F(EmitterTest, NestedBlockSeq) {
|
||||
out << BeginSeq;
|
||||
out << "item 1";
|
||||
@@ -1553,6 +1603,26 @@ TEST_F(EmitterErrorTest, BadLocalTag) {
|
||||
ExpectEmitError("invalid tag");
|
||||
}
|
||||
|
||||
TEST_F(EmitterErrorTest, BadTagAndTag) {
|
||||
out << VerbatimTag("!far") << VerbatimTag("!foo") << "bar";
|
||||
ExpectEmitError(ErrorMsg::INVALID_TAG);
|
||||
}
|
||||
|
||||
TEST_F(EmitterErrorTest, BadAnchorAndAnchor) {
|
||||
out << Anchor("far") << Anchor("foo") << "bar";
|
||||
ExpectEmitError(ErrorMsg::INVALID_ANCHOR);
|
||||
}
|
||||
|
||||
TEST_F(EmitterErrorTest, BadEmptyAnchorOnGroup) {
|
||||
out << BeginSeq << "bar" << Anchor("foo") << EndSeq;
|
||||
ExpectEmitError(ErrorMsg::INVALID_ANCHOR);
|
||||
}
|
||||
|
||||
TEST_F(EmitterErrorTest, BadEmptyTagOnGroup) {
|
||||
out << BeginSeq << "bar" << VerbatimTag("!foo") << EndSeq;
|
||||
ExpectEmitError(ErrorMsg::INVALID_TAG);
|
||||
}
|
||||
|
||||
TEST_F(EmitterErrorTest, ExtraEndSeq) {
|
||||
out << BeginSeq;
|
||||
out << "Hello";
|
||||
|
Reference in New Issue
Block a user