testing fusion transform and fold work with free functions now that only Boost.ResultOf support is required

[SVN r38063]
This commit is contained in:
Dan Marsden
2007-06-22 18:02:58 +00:00
parent 09a6da1f80
commit 996a4da2d6
2 changed files with 26 additions and 0 deletions

View File

@ -115,6 +115,11 @@ struct lvalue_adder
} }
}; };
int add(int lhs, int rhs)
{
return lhs + rhs;
}
int int
main() main()
{ {
@ -164,6 +169,11 @@ main()
BOOST_TEST(fusion::fold(vec, 0, lvalue_adder()) == 3); BOOST_TEST(fusion::fold(vec, 0, lvalue_adder()) == 3);
} }
{
vector<int, int> vec(1,2);
BOOST_TEST(fusion::fold(vec, 0, add) == 3);
}
{ {
typedef vector<int, char, int, double> vector_type; typedef vector<int, char, int, double> vector_type;
vector_type v(12345, 'x', 678910, 3.36); vector_type v(12345, 'x', 678910, 3.36);
@ -202,6 +212,11 @@ main()
== "abcde"); == "abcde");
} }
{
vector<int, int> vec(1,2);
BOOST_TEST(fusion::accumulate(vec, 0, add) == 3);
}
return boost::report_errors(); return boost::report_errors();
} }

View File

@ -71,6 +71,11 @@ struct unary_lvalue_transform
} }
}; };
int twice(int v)
{
return v*2;
}
struct binary_lvalue_transform struct binary_lvalue_transform
{ {
template<typename Sig> template<typename Sig>
@ -141,6 +146,12 @@ main()
BOOST_TEST(*begin(transform(tup1, tup2, binary_lvalue_transform())) == &at_c<0>(tup1)); BOOST_TEST(*begin(transform(tup1, tup2, binary_lvalue_transform())) == &at_c<0>(tup1));
} }
{
vector<int, int, int> tup1(1, 2, 3);
BOOST_TEST(transform(tup1, twice) == make_vector(2,4,6));
}
return boost::report_errors(); return boost::report_errors();
} }