mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Added proper typedefs for BOOST_FOREACH to work
This commit is contained in:
@@ -30,6 +30,8 @@ namespace YAML
|
|||||||
template<typename> friend class iterator_base;
|
template<typename> friend class iterator_base;
|
||||||
struct enabler {};
|
struct enabler {};
|
||||||
typedef typename iterator_base::base_type base_type;
|
typedef typename iterator_base::base_type base_type;
|
||||||
|
|
||||||
|
public:
|
||||||
typedef typename iterator_base::value_type value_type;
|
typedef typename iterator_base::value_type value_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@@ -24,6 +24,9 @@ namespace YAML
|
|||||||
template<typename> friend class detail::iterator_base;
|
template<typename> friend class detail::iterator_base;
|
||||||
template<typename T, typename S> friend struct as_if;
|
template<typename T, typename S> friend struct as_if;
|
||||||
|
|
||||||
|
typedef iterator iterator;
|
||||||
|
typedef const_iterator const_iterator;
|
||||||
|
|
||||||
Node();
|
Node();
|
||||||
explicit Node(NodeType::value type);
|
explicit Node(NodeType::value type);
|
||||||
template<typename T> explicit Node(const T& rhs);
|
template<typename T> explicit Node(const T& rhs);
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#include "nodetests.h"
|
#include "nodetests.h"
|
||||||
#include "yaml-cpp/yaml.h"
|
#include "yaml-cpp/yaml.h"
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace {
|
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));
|
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;
|
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) {
|
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::FallbackValues, "fallback values", passed, total);
|
||||||
RunNodeTest(&Node::NumericConversion, "numeric conversion", passed, total);
|
RunNodeTest(&Node::NumericConversion, "numeric conversion", passed, total);
|
||||||
RunNodeTest(&Node::Binary, "binary", passed, total);
|
RunNodeTest(&Node::Binary, "binary", passed, total);
|
||||||
|
RunNodeTest(&Node::ForEach, "for each", passed, total);
|
||||||
|
|
||||||
std::cout << "Node tests: " << passed << "/" << total << " passed\n";
|
std::cout << "Node tests: " << passed << "/" << total << " passed\n";
|
||||||
return passed == total;
|
return passed == total;
|
||||||
|
Reference in New Issue
Block a user