handle the empty Tag/Anchor properly.
This commit is contained in:
parent
2f3938e9fe
commit
683c4d8517
@ -160,6 +160,12 @@ void EmitterState::EndedGroup(GroupType::value type) {
|
|||||||
return SetError(ErrorMsg::UNEXPECTED_END_MAP);
|
return SetError(ErrorMsg::UNEXPECTED_END_MAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if have the unhandled Tag/Anchor, set the error message
|
||||||
|
if (m_hasTag)
|
||||||
|
SetError(ErrorMsg::INVALID_TAG);
|
||||||
|
if (m_hasAnchor)
|
||||||
|
SetError(ErrorMsg::INVALID_ANCHOR);
|
||||||
|
|
||||||
// get rid of the current group
|
// get rid of the current group
|
||||||
{
|
{
|
||||||
std::unique_ptr<Group> pFinishedGroup = std::move(m_groups.back());
|
std::unique_ptr<Group> pFinishedGroup = std::move(m_groups.back());
|
||||||
|
|||||||
@ -142,8 +142,6 @@ TEST_F(EmitterTest, EmptyBlockSeqWithBegunContent) {
|
|||||||
out << BeginSeq;
|
out << BeginSeq;
|
||||||
out << BeginSeq << Comment("comment") << EndSeq;
|
out << BeginSeq << Comment("comment") << EndSeq;
|
||||||
out << BeginSeq << Newline << EndSeq;
|
out << BeginSeq << Newline << EndSeq;
|
||||||
out << BeginSeq << Anchor("test") << EndSeq;
|
|
||||||
out << BeginSeq << VerbatimTag("foo") << EndSeq;
|
|
||||||
out << EndSeq;
|
out << EndSeq;
|
||||||
|
|
||||||
ExpectEmit(R"(-
|
ExpectEmit(R"(-
|
||||||
@ -151,27 +149,19 @@ TEST_F(EmitterTest, EmptyBlockSeqWithBegunContent) {
|
|||||||
[]
|
[]
|
||||||
-
|
-
|
||||||
|
|
||||||
[]
|
[])");
|
||||||
-
|
|
||||||
- &test[]
|
|
||||||
-
|
|
||||||
- !<foo>[])");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(EmitterTest, EmptyBlockMapWithBegunContent) {
|
TEST_F(EmitterTest, EmptyBlockMapWithBegunContent) {
|
||||||
out << BeginSeq;
|
out << BeginSeq;
|
||||||
out << BeginMap << Comment("comment") << EndMap;
|
out << BeginMap << Comment("comment") << EndMap;
|
||||||
out << BeginMap << Newline << EndMap;
|
out << BeginMap << Newline << EndMap;
|
||||||
out << BeginMap << Anchor("test") << EndMap;
|
|
||||||
out << BeginMap << VerbatimTag("foo") << EndMap;
|
|
||||||
out << EndSeq;
|
out << EndSeq;
|
||||||
|
|
||||||
ExpectEmit(R"(- # comment
|
ExpectEmit(R"(- # comment
|
||||||
{}
|
{}
|
||||||
-
|
-
|
||||||
{}
|
{})");
|
||||||
- &test{}
|
|
||||||
- !<foo>{})");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(EmitterTest, EmptyFlowSeqWithBegunContent) {
|
TEST_F(EmitterTest, EmptyFlowSeqWithBegunContent) {
|
||||||
@ -179,13 +169,11 @@ TEST_F(EmitterTest, EmptyFlowSeqWithBegunContent) {
|
|||||||
out << BeginSeq;
|
out << BeginSeq;
|
||||||
out << BeginSeq << Comment("comment") << EndSeq;
|
out << BeginSeq << Comment("comment") << EndSeq;
|
||||||
out << BeginSeq << Newline << EndSeq;
|
out << BeginSeq << Newline << EndSeq;
|
||||||
out << BeginSeq << Anchor("test") << EndSeq;
|
|
||||||
out << BeginSeq << VerbatimTag("foo") << EndSeq;
|
|
||||||
out << EndSeq;
|
out << EndSeq;
|
||||||
|
|
||||||
ExpectEmit(R"([[ # comment
|
ExpectEmit(R"([[ # comment
|
||||||
], [
|
], [
|
||||||
], [&test], [!<foo>]])");
|
]])");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(EmitterTest, EmptyFlowMapWithBegunContent) {
|
TEST_F(EmitterTest, EmptyFlowMapWithBegunContent) {
|
||||||
@ -193,13 +181,11 @@ TEST_F(EmitterTest, EmptyFlowMapWithBegunContent) {
|
|||||||
out << BeginSeq;
|
out << BeginSeq;
|
||||||
out << BeginMap << Comment("comment") << EndMap;
|
out << BeginMap << Comment("comment") << EndMap;
|
||||||
out << BeginMap << Newline << EndMap;
|
out << BeginMap << Newline << EndMap;
|
||||||
out << BeginMap << Anchor("test") << EndMap;
|
|
||||||
out << BeginMap << VerbatimTag("foo") << EndMap;
|
|
||||||
out << EndSeq;
|
out << EndSeq;
|
||||||
|
|
||||||
ExpectEmit(R"([{ # comment
|
ExpectEmit(R"([{ # comment
|
||||||
}, {
|
}, {
|
||||||
}, {&test}, {!<foo>}])");
|
}])");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(EmitterTest, NestedBlockSeq) {
|
TEST_F(EmitterTest, NestedBlockSeq) {
|
||||||
@ -1574,6 +1560,26 @@ TEST_F(EmitterErrorTest, BadLocalTag) {
|
|||||||
ExpectEmitError("invalid tag");
|
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) {
|
TEST_F(EmitterErrorTest, ExtraEndSeq) {
|
||||||
out << BeginSeq;
|
out << BeginSeq;
|
||||||
out << "Hello";
|
out << "Hello";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user