covering accumulate as part of fusion fold tests

[SVN r37807]
This commit is contained in:
Dan Marsden
2007-05-28 23:13:46 +00:00
parent b935ea84a9
commit 6097406ca1
2 changed files with 36 additions and 1 deletions

View File

@ -10,6 +10,7 @@
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/algorithm/iteration/fold.hpp>
#include <boost/fusion/algorithm/iteration/accumulate.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/next.hpp>
@ -104,6 +105,40 @@ main()
BOOST_TEST(n == 3);
}
{
typedef vector<int, char, int, double> vector_type;
vector_type v(12345, 'x', 678910, 3.36);
int result = accumulate(v, 0, add_ints_only());
std::cout << result << std::endl;
BOOST_TEST(result == 12345+678910);
}
{
typedef vector<int> vector_type;
vector_type v(12345);
int n = fusion::accumulate(v, int_<0>(), count_ints());
std::cout << n << std::endl;
BOOST_TEST(n == 1);
}
{
typedef vector<int, char, int, double, int> vector_type;
vector_type v(12345, 'x', 678910, 3.36, 8756);
int n = fusion::accumulate(v, int_<0>(), count_ints());
std::cout << n << std::endl;
BOOST_TEST(n == 3);
}
{
typedef boost::mpl::vector<int, char, int, double, int> mpl_vec;
int n = fusion::accumulate(mpl_vec(), int_<0>(), count_ints());
std::cout << n << std::endl;
BOOST_TEST(n == 3);
}
return boost::report_errors();
}