mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Allowed solo entries in a flow map to be read as keys with null value
This commit is contained in:
@@ -235,7 +235,7 @@ namespace Test
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool FlowMapWithOmittedValue()
|
||||
{
|
||||
std::string input = "{a: b, c:, d:}";
|
||||
@@ -256,6 +256,45 @@ namespace Test
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FlowMapWithSoloEntry()
|
||||
{
|
||||
std::string input = "{a: b, c, d: e}";
|
||||
std::stringstream stream(input);
|
||||
YAML::Parser parser(stream);
|
||||
YAML::Node doc;
|
||||
parser.GetNextDocument(doc);
|
||||
|
||||
std::string output;
|
||||
doc["a"] >> output;
|
||||
if(output != "b")
|
||||
return false;
|
||||
if(!IsNull(doc["c"]))
|
||||
return false;
|
||||
doc["d"] >> output;
|
||||
if(output != "e")
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FlowMapEndingWithSoloEntry()
|
||||
{
|
||||
std::string input = "{a: b, c}";
|
||||
std::stringstream stream(input);
|
||||
YAML::Parser parser(stream);
|
||||
YAML::Node doc;
|
||||
parser.GetNextDocument(doc);
|
||||
|
||||
std::string output;
|
||||
doc["a"] >> output;
|
||||
if(output != "b")
|
||||
return false;
|
||||
if(!IsNull(doc["c"]))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QuotedSimpleKeys()
|
||||
{
|
||||
std::string KeyValue[3] = { "\"double\": double\n", "'single': single\n", "plain: plain\n" };
|
||||
|
@@ -268,6 +268,8 @@ namespace Test
|
||||
RunParserTest(&Parser::FlowMap, "flow map", passed);
|
||||
RunParserTest(&Parser::FlowMapWithOmittedKey, "flow map with omitted key", passed);
|
||||
RunParserTest(&Parser::FlowMapWithOmittedValue, "flow map with omitted value", passed);
|
||||
RunParserTest(&Parser::FlowMapWithSoloEntry, "flow map with solo entry", passed);
|
||||
RunParserTest(&Parser::FlowMapEndingWithSoloEntry, "flow map ending with solo entry", passed);
|
||||
RunParserTest(&Parser::QuotedSimpleKeys, "quoted simple keys", passed);
|
||||
RunParserTest(&Parser::CompressedMapAndSeq, "compressed map and seq", passed);
|
||||
RunParserTest(&Parser::NullBlockSeqEntry, "null block seq entry", passed);
|
||||
|
@@ -35,6 +35,8 @@ namespace Test {
|
||||
bool FlowMap();
|
||||
bool FlowMapWithOmittedKey();
|
||||
bool FlowMapWithOmittedValue();
|
||||
bool FlowMapWithSoloEntry();
|
||||
bool FlowMapEndingWithSoloEntry();
|
||||
bool QuotedSimpleKeys();
|
||||
bool CompressedMapAndSeq();
|
||||
bool NullBlockSeqEntry();
|
||||
|
Reference in New Issue
Block a user