From 6097406ca126620b703fdb20183604fa72306fbf Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Mon, 28 May 2007 23:13:46 +0000 Subject: [PATCH] covering accumulate as part of fusion fold tests [SVN r37807] --- test/Jamfile | 2 +- test/algorithm/fold.cpp | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/test/Jamfile b/test/Jamfile index 38dcd59f..3c186062 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -1,4 +1,4 @@ -#============================================================================== +##============================================================================== # Copyright (c) 2003-2006 Joel de Guzman # # Use, modification and distribution is subject to the Boost Software diff --git a/test/algorithm/fold.cpp b/test/algorithm/fold.cpp index 228204f1..adfc8ffb 100644 --- a/test/algorithm/fold.cpp +++ b/test/algorithm/fold.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -104,6 +105,40 @@ main() BOOST_TEST(n == 3); } + { + typedef vector 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 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 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 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(); }