Fixed null key/value bug, added tests

This commit is contained in:
Jesse Beder
2009-07-30 06:49:09 +00:00
parent 382f1ba3c7
commit 7a89920441
8 changed files with 87 additions and 16 deletions

View File

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

View File

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

View File

@@ -34,6 +34,9 @@ namespace Test {
bool FlowSeq();
bool FlowMap();
bool QuotedSimpleKeys();
bool NullBlockSeqEntry();
bool NullBlockMapKey();
bool NullBlockMapValue();
}
namespace Emitter {