From 5be19ccbfdac823d214fb564d69349fb052ffbff Mon Sep 17 00:00:00 2001 From: Jesse Beder Date: Tue, 13 Sep 2011 14:20:32 -0500 Subject: [PATCH] Added 7.x and 8.x tests with tags - all that's left is multiple docs in stream --- test/new-api/spectests.cpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/test/new-api/spectests.cpp b/test/new-api/spectests.cpp index f07158a..13359c2 100644 --- a/test/new-api/spectests.cpp +++ b/test/new-api/spectests.cpp @@ -744,7 +744,21 @@ namespace Test } // 7.2 - TEST EmptyNodes() { return " not written yet"; } + TEST EmptyNodes() { + YAML::Node doc = YAML::Parse(ex7_2); + YAML_ASSERT(doc.size() == 2); + for(YAML::const_iterator it=doc.begin();it!=doc.end();++it) { + if(it->first.as() == "foo") { + YAML_ASSERT(it->second.Tag() == "tag:yaml.org,2002:str"); + YAML_ASSERT(it->second.as() == ""); + } else if(it->first.as() == "") { + YAML_ASSERT(it->first.Tag() == "tag:yaml.org,2002:str"); + YAML_ASSERT(it->second.as() == "bar"); + } else + return " unexpected key"; + } + return true; + } // 7.3 TEST CompletelyEmptyNodes() { @@ -975,7 +989,18 @@ namespace Test } // 7.24 - TEST FlowNodes() { return " not written yet"; } + TEST FlowNodes() { + YAML::Node doc = YAML::Parse(ex7_24); + YAML_ASSERT(doc.size() == 5); + YAML_ASSERT(doc[0].Tag() == "tag:yaml.org,2002:str"); + YAML_ASSERT(doc[0].as() == "a"); + YAML_ASSERT(doc[1].as() == 'b'); + YAML_ASSERT(doc[2].as() == "c"); + YAML_ASSERT(doc[3].as() == "c"); + YAML_ASSERT(doc[4].Tag() == "tag:yaml.org,2002:str"); + YAML_ASSERT(doc[4].as() == ""); + return true; + } // 8.1 TEST BlockScalarHeader() { @@ -1210,7 +1235,14 @@ namespace Test } // 8.21 - TEST BlockScalarNodes() { return " not written yet"; } + TEST BlockScalarNodes() { + YAML::Node doc = YAML::Parse(ex8_21); + YAML_ASSERT(doc.size() == 2); + YAML_ASSERT(doc["literal"].as() == "value"); // Note: I believe this is a bug in the YAML spec - it should be "value\n" + YAML_ASSERT(doc["folded"].as() == "value"); + YAML_ASSERT(doc["folded"].Tag() == "!foo"); + return true; + } // 8.22 TEST BlockCollectionNodes() {