Support kinds of emitter format-setting for YAML::Null. (#906)

* Support kinds of emitter format-setting for YAML::Null.

* update the code and test cases

* add the comment //fallthrough
This commit is contained in:
Chen
2020-06-29 12:31:53 +08:00
committed by GitHub
parent 27d8a0e302
commit 08aa252611
7 changed files with 86 additions and 1 deletions

View File

@@ -1047,6 +1047,45 @@ TEST_F(EmitterTest, BoolFormatting) {
"- Y\n- Y\n- y\n- N\n- N\n- n");
}
TEST_F(EmitterTest, GlobalNullFormatting) {
out << Flow << BeginSeq;
out.SetNullFormat(LowerNull);
out << Null;
out.SetNullFormat(UpperNull);
out << Null;
out.SetNullFormat(CamelNull);
out << Null;
out.SetNullFormat(TildeNull);
out << Null;
out << EndSeq;
ExpectEmit("[null, NULL, Null, ~]");
}
TEST_F(EmitterTest, NullFormatting) {
out << Flow << BeginSeq;
out << LowerNull << Null;
out << UpperNull << Null;
out << CamelNull << Null;
out << TildeNull << Null;
out << EndSeq;
ExpectEmit("[null, NULL, Null, ~]");
}
TEST_F(EmitterTest, NullFormattingOnNode) {
Node n(Load("null"));
out << Flow << BeginSeq;
out.SetNullFormat(LowerNull);
out << n;
out.SetNullFormat(UpperNull);
out << n;
out.SetNullFormat(CamelNull);
out << n;
out.SetNullFormat(TildeNull);
out << n;
out << EndSeq;
ExpectEmit("[null, NULL, Null, ~]");
}
// TODO: Fix this test.
// TEST_F(EmitterTest, DocStartAndEnd) {
// out << BeginDoc;