File tree 2 files changed +6
-0
lines changed
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> {
110
110
const Node& node;
111
111
112
112
std::string operator ()(const S& fallback) const {
113
+ if (node.Type () == NodeType::Null)
114
+ return " null" ;
113
115
if (node.Type () != NodeType::Scalar)
114
116
return fallback;
115
117
return node.Scalar ();
@@ -138,6 +140,8 @@ struct as_if<std::string, void> {
138
140
const Node& node;
139
141
140
142
std::string operator ()() const {
143
+ if (node.Type () == NodeType::Null)
144
+ return " null" ;
141
145
if (node.Type () != NodeType::Scalar)
142
146
throw TypedBadConversion<std::string>(node.Mark ());
143
147
return node.Scalar ();
Original file line number Diff line number Diff line change @@ -314,6 +314,8 @@ TEST(NodeTest, IncorrectFlow) {
314
314
TEST (NodeTest, LoadTildeAsNull) {
315
315
Node node = Load (" ~" );
316
316
ASSERT_TRUE (node.IsNull ());
317
+ EXPECT_EQ (node.as <std::string>(), " null" );
318
+ EXPECT_EQ (node.as <std::string>(" ~" ), " null" );
317
319
}
318
320
319
321
TEST (NodeTest, LoadNullWithStrTag) {
You can’t perform that action at this time.
0 commit comments