Finished refactoring of simple keys so that they can refer to multiple tokens at a single level

This commit is contained in:
Jesse Beder
2009-09-05 03:49:38 +00:00
parent 0e1638d7b5
commit 75477ade65
7 changed files with 126 additions and 44 deletions

View File

@@ -407,6 +407,54 @@ namespace Test
return true;
}
bool AnchorInSimpleKey()
{
std::string input = "- &a b: c\n- *a";
std::stringstream stream(input);
YAML::Parser parser(stream);
YAML::Node doc;
parser.GetNextDocument(doc);
if(doc.size() != 2)
return false;
std::string output;
doc[0]["b"] >> output;
if(output != "c")
return false;
doc[1] >> output;
if(output != "b")
return false;
return true;
}
bool AliasAsSimpleKey()
{
std::string input = "- &a b\n- *a: c";
std::stringstream stream(input);
YAML::Parser parser(stream);
YAML::Node doc;
parser.GetNextDocument(doc);
if(doc.size() != 2)
return false;
std::string output;
doc[0] >> output;
if(output != "b")
return false;
doc[1]["b"] >> output;
if(output != "c")
return false;
return true;
}
bool ExplicitDoc()
{
std::string input = "---\n- one\n- two";

View File

@@ -275,6 +275,8 @@ namespace Test
RunParserTest(&Parser::NullBlockMapValue, "null block map value", passed);
RunParserTest(&Parser::SimpleAlias, "simple alias", passed);
RunParserTest(&Parser::AliasWithNull, "alias with null", passed);
RunParserTest(&Parser::AnchorInSimpleKey, "anchor in simple key", passed);
RunParserTest(&Parser::AliasAsSimpleKey, "alias as simple key", passed);
RunParserTest(&Parser::ExplicitDoc, "explicit doc", passed);
RunParserTest(&Parser::MultipleDocs, "multiple docs", passed);
RunParserTest(&Parser::ExplicitEndDoc, "explicit end doc", passed);

View File

@@ -42,6 +42,8 @@ namespace Test {
bool NullBlockMapValue();
bool SimpleAlias();
bool AliasWithNull();
bool AnchorInSimpleKey();
bool AliasAsSimpleKey();
bool ExplicitDoc();
bool MultipleDocs();
bool ExplicitEndDoc();