File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,8 @@ struct as_if<std::string, S> {
110110 const Node& node;
111111
112112 std::string operator ()(const S& fallback) const {
113+ if (node.Type () == NodeType::Null)
114+ return " null" ;
113115 if (node.Type () != NodeType::Scalar)
114116 return fallback;
115117 return node.Scalar ();
@@ -138,6 +140,8 @@ struct as_if<std::string, void> {
138140 const Node& node;
139141
140142 std::string operator ()() const {
143+ if (node.Type () == NodeType::Null)
144+ return " null" ;
141145 if (node.Type () != NodeType::Scalar)
142146 throw TypedBadConversion<std::string>(node.Mark ());
143147 return node.Scalar ();
Original file line number Diff line number Diff line change @@ -314,6 +314,8 @@ TEST(NodeTest, IncorrectFlow) {
314314TEST (NodeTest, LoadTildeAsNull) {
315315 Node node = Load (" ~" );
316316 ASSERT_TRUE (node.IsNull ());
317+ EXPECT_EQ (node.as <std::string>(), " null" );
318+ EXPECT_EQ (node.as <std::string>(" ~" ), " null" );
317319}
318320
319321TEST (NodeTest, LoadNullWithStrTag) {
You can’t perform that action at this time.
0 commit comments