diff --git a/yaml-reader/parsertests.cpp b/yaml-reader/parsertests.cpp index d0342e2..3fbc457 100644 --- a/yaml-reader/parsertests.cpp +++ b/yaml-reader/parsertests.cpp @@ -418,5 +418,74 @@ namespace Test return true; } + + bool ExplicitEndDoc() + { + std::string input = "- one\n- two\n...\n..."; + + 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 != "one") + return false; + doc[1] >> output; + if(output != "two") + return false; + + return true; + } + + bool MultipleDocsWithSomeExplicitIndicators() + { + std::string input = + "- one\n- two\n...\n" + "---\nkey: value\n...\n...\n" + "- three\n- four\n" + "---\nkey: value"; + + std::stringstream stream(input); + YAML::Parser parser(stream); + YAML::Node doc; + std::string output; + + parser.GetNextDocument(doc); + if(doc.size() != 2) + return false; + doc[0] >> output; + if(output != "one") + return false; + doc[1] >> output; + if(output != "two") + return false; + + parser.GetNextDocument(doc); + doc["key"] >> output; + if(output != "value") + return false; + + parser.GetNextDocument(doc); + if(doc.size() != 2) + return false; + doc[0] >> output; + if(output != "three") + return false; + doc[1] >> output; + if(output != "four") + return false; + + parser.GetNextDocument(doc); + doc["key"] >> output; + if(output != "value") + return false; + + return true; + } } } diff --git a/yaml-reader/tests.cpp b/yaml-reader/tests.cpp index 9796b63..5193a90 100644 --- a/yaml-reader/tests.cpp +++ b/yaml-reader/tests.cpp @@ -271,6 +271,8 @@ namespace Test RunParserTest(&Parser::AliasWithNull, "alias with null", passed); RunParserTest(&Parser::ExplicitDoc, "explicit doc", passed); RunParserTest(&Parser::MultipleDocs, "multiple docs", passed); + RunParserTest(&Parser::ExplicitEndDoc, "explicit end doc", passed); + RunParserTest(&Parser::MultipleDocsWithSomeExplicitIndicators, "multiple docs with some explicit indicators", passed); RunEncodingTest(&EncodeToUtf8, false, "UTF-8, no BOM", passed); RunEncodingTest(&EncodeToUtf8, true, "UTF-8 with BOM", passed); diff --git a/yaml-reader/tests.h b/yaml-reader/tests.h index 91f7def..67e6361 100644 --- a/yaml-reader/tests.h +++ b/yaml-reader/tests.h @@ -42,6 +42,8 @@ namespace Test { bool AliasWithNull(); bool ExplicitDoc(); bool MultipleDocs(); + bool ExplicitEndDoc(); + bool MultipleDocsWithSomeExplicitIndicators(); } namespace Emitter {