From 8e9346051134113ff7d8cda408409bfc3efb3422 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Wed, 13 Jun 2007 20:30:30 +0000 Subject: [PATCH] tests covering defect in fusion::fold loop unrolling picked up by Christian Holmquist [SVN r37984] --- test/algorithm/fold.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/algorithm/fold.cpp b/test/algorithm/fold.cpp index 6cefb99d..627ca01f 100644 --- a/test/algorithm/fold.cpp +++ b/test/algorithm/fold.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -18,6 +19,8 @@ #include #include +#include + using boost::mpl::if_; using boost::mpl::int_; using boost::is_same; @@ -73,6 +76,16 @@ struct count_ints } }; +struct appender +{ + typedef std::string result_type; + + std::string operator()(char c, std::string const& str) const + { + return str + c; + } +}; + int main() { @@ -112,6 +125,11 @@ main() BOOST_TEST(n == 3); } + { + BOOST_TEST(fusion::fold(fusion::make_vector('a','b','c','d','e'), std::string(""), appender()) + == "abcde"); + } + { typedef vector vector_type; vector_type v(12345, 'x', 678910, 3.36); @@ -145,6 +163,10 @@ main() BOOST_TEST(n == 3); } + { + BOOST_TEST(fusion::accumulate(fusion::make_vector('a','b','c','d','e'), std::string(""), appender()) + == "abcde"); + } return boost::report_errors(); }