Added proper typedefs for BOOST_FOREACH to work

This commit is contained in:
beder
2012-05-08 12:20:28 -05:00
parent b1a1f8ce2d
commit 485afcb633
3 changed files with 19 additions and 0 deletions

View File

@@ -30,6 +30,8 @@ namespace YAML
template<typename> friend class iterator_base;
struct enabler {};
typedef typename iterator_base::base_type base_type;
public:
typedef typename iterator_base::value_type value_type;
public:

View File

@@ -24,6 +24,9 @@ namespace YAML
template<typename> friend class detail::iterator_base;
template<typename T, typename S> friend struct as_if;
typedef iterator iterator;
typedef const_iterator const_iterator;
Node();
explicit Node(NodeType::value type);
template<typename T> explicit Node(const T& rhs);

View File

@@ -1,5 +1,6 @@
#include "nodetests.h"
#include "yaml-cpp/yaml.h"
#include <boost/foreach.hpp>
#include <iostream>
namespace {
@@ -324,6 +325,18 @@ namespace Test
YAML_ASSERT(node[1].as<YAML::Binary>() == YAML::Binary(reinterpret_cast<const unsigned char*>("Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.\n"), 270));
return true;
}
TEST ForEach()
{
YAML::Node node = YAML::Load("[1, 3, 5, 7]");
int seq[] = {1, 3, 5, 7};
int i = 0;
BOOST_FOREACH(const YAML::Node &item, node) {
int x = seq[i++];
YAML_ASSERT(item.as<int>() == x);
}
return true;
}
}
void RunNodeTest(TEST (*test)(), const std::string& name, int& passed, int& total) {
@@ -373,6 +386,7 @@ namespace Test
RunNodeTest(&Node::FallbackValues, "fallback values", passed, total);
RunNodeTest(&Node::NumericConversion, "numeric conversion", passed, total);
RunNodeTest(&Node::Binary, "binary", passed, total);
RunNodeTest(&Node::ForEach, "for each", passed, total);
std::cout << "Node tests: " << passed << "/" << total << " passed\n";
return passed == total;