mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Fixed null key/value bug, added tests
This commit is contained in:
@@ -247,5 +247,62 @@ namespace Test
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NullBlockSeqEntry()
|
||||
{
|
||||
std::string input = "- hello\n-\n- world";
|
||||
|
||||
std::stringstream stream(input);
|
||||
YAML::Parser parser(stream);
|
||||
YAML::Node doc;
|
||||
parser.GetNextDocument(doc);
|
||||
|
||||
std::string output;
|
||||
doc[0] >> output;
|
||||
if(output != "hello")
|
||||
return false;
|
||||
doc[1] >> output;
|
||||
if(output != "~")
|
||||
return false;
|
||||
doc[2] >> output;
|
||||
if(output != "world")
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NullBlockMapKey()
|
||||
{
|
||||
std::string input = ": empty key";
|
||||
|
||||
std::stringstream stream(input);
|
||||
YAML::Parser parser(stream);
|
||||
YAML::Node doc;
|
||||
parser.GetNextDocument(doc);
|
||||
|
||||
std::string output;
|
||||
doc[YAML::Null] >> output;
|
||||
if(output != "empty key")
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NullBlockMapValue()
|
||||
{
|
||||
std::string input = "empty value:";
|
||||
|
||||
std::stringstream stream(input);
|
||||
YAML::Parser parser(stream);
|
||||
YAML::Node doc;
|
||||
parser.GetNextDocument(doc);
|
||||
|
||||
std::string output;
|
||||
doc["empty value"] >> output;
|
||||
if(output != "~")
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -263,7 +263,10 @@ namespace Test
|
||||
RunParserTest(&Parser::FlowSeq, "flow seq", passed);
|
||||
RunParserTest(&Parser::FlowMap, "flow map", passed);
|
||||
RunParserTest(&Parser::QuotedSimpleKeys, "quoted simple keys", passed);
|
||||
|
||||
RunParserTest(&Parser::NullBlockSeqEntry, "null block seq entry", passed);
|
||||
RunParserTest(&Parser::NullBlockMapKey, "null block map key", passed);
|
||||
RunParserTest(&Parser::NullBlockMapValue, "null block map value", passed);
|
||||
|
||||
RunEncodingTest(&EncodeToUtf8, false, "UTF-8, no BOM", passed);
|
||||
RunEncodingTest(&EncodeToUtf8, true, "UTF-8 with BOM", passed);
|
||||
RunEncodingTest(&EncodeToUtf16LE, false, "UTF-16LE, no BOM", passed);
|
||||
|
@@ -34,6 +34,9 @@ namespace Test {
|
||||
bool FlowSeq();
|
||||
bool FlowMap();
|
||||
bool QuotedSimpleKeys();
|
||||
bool NullBlockSeqEntry();
|
||||
bool NullBlockMapKey();
|
||||
bool NullBlockMapValue();
|
||||
}
|
||||
|
||||
namespace Emitter {
|
||||
|
Reference in New Issue
Block a user