mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Finished refactoring of simple keys so that they can refer to multiple tokens at a single level
This commit is contained in:
@@ -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";
|
||||
|
@@ -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);
|
||||
|
@@ -42,6 +42,8 @@ namespace Test {
|
||||
bool NullBlockMapValue();
|
||||
bool SimpleAlias();
|
||||
bool AliasWithNull();
|
||||
bool AnchorInSimpleKey();
|
||||
bool AliasAsSimpleKey();
|
||||
bool ExplicitDoc();
|
||||
bool MultipleDocs();
|
||||
bool ExplicitEndDoc();
|
||||
|
Reference in New Issue
Block a user