Allowed solo entries in a flow map to be read as keys with null value

This commit is contained in:
Jesse Beder
2009-09-05 22:42:01 +00:00
parent 75477ade65
commit 91163d2296
7 changed files with 113 additions and 52 deletions

View File

@@ -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" };

View File

@@ -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);

View File

@@ -35,6 +35,8 @@ namespace Test {
bool FlowMap();
bool FlowMapWithOmittedKey();
bool FlowMapWithOmittedValue();
bool FlowMapWithSoloEntry();
bool FlowMapEndingWithSoloEntry();
bool QuotedSimpleKeys();
bool CompressedMapAndSeq();
bool NullBlockSeqEntry();