Add ifdef to check if BOOST_FOREACH is defined, and disable tests that use it if it is not available

This commit is contained in:
Jesse Beder
2013-10-13 11:14:34 -05:00
parent 0305ad13e4
commit 25881c4f96

View File

@@ -1,8 +1,13 @@
#include "nodetests.h" #include "nodetests.h"
#include "yaml-cpp/yaml.h" #include "yaml-cpp/yaml.h"
#include <boost/foreach.hpp>
#include <iostream> #include <iostream>
#include <boost/version.hpp>
#if BOOST_VERSION >= 103400
#include <boost/foreach.hpp>
#endif
namespace { namespace {
struct TEST { struct TEST {
TEST(): ok(false) {} TEST(): ok(false) {}
@@ -382,7 +387,8 @@ namespace Test
YAML_ASSERT(i == 3); YAML_ASSERT(i == 3);
return true; return true;
} }
#ifdef BOOST_FOREACH
TEST ForEach() TEST ForEach()
{ {
YAML::Node node = YAML::Load("[1, 3, 5, 7]"); YAML::Node node = YAML::Load("[1, 3, 5, 7]");
@@ -403,6 +409,7 @@ namespace Test
} }
return true; return true;
} }
#endif
TEST CloneScalar() TEST CloneScalar()
{ {
@@ -568,8 +575,10 @@ namespace Test
RunNodeTest(&Node::Binary, "binary", passed, total); RunNodeTest(&Node::Binary, "binary", passed, total);
RunNodeTest(&Node::IterateSequence, "iterate sequence", passed, total); RunNodeTest(&Node::IterateSequence, "iterate sequence", passed, total);
RunNodeTest(&Node::IterateMap, "iterate map", passed, total); RunNodeTest(&Node::IterateMap, "iterate map", passed, total);
#ifdef BOOST_FOREACH
RunNodeTest(&Node::ForEach, "for each", passed, total); RunNodeTest(&Node::ForEach, "for each", passed, total);
RunNodeTest(&Node::ForEachMap, "for each map", passed, total); RunNodeTest(&Node::ForEachMap, "for each map", passed, total);
#endif
RunNodeTest(&Node::CloneScalar, "clone scalar", passed, total); RunNodeTest(&Node::CloneScalar, "clone scalar", passed, total);
RunNodeTest(&Node::CloneSeq, "clone seq", passed, total); RunNodeTest(&Node::CloneSeq, "clone seq", passed, total);
RunNodeTest(&Node::CloneMap, "clone map", passed, total); RunNodeTest(&Node::CloneMap, "clone map", passed, total);