From da31732ca3874a12827d80b31376f0d7da71149e Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Wed, 30 May 2007 06:47:39 +0000 Subject: [PATCH] fixing defective test case with bad rvalue / lvalue handling issue [SVN r37819] --- test/algorithm/all.cpp | 27 ++++++++++++++++++++++++--- test/algorithm/any.cpp | 25 +++++++++++++++++++++++-- test/algorithm/none.cpp | 25 +++++++++++++++++++++++-- 3 files changed, 70 insertions(+), 7 deletions(-) diff --git a/test/algorithm/all.cpp b/test/algorithm/all.cpp index 31fff013..983059c8 100644 --- a/test/algorithm/all.cpp +++ b/test/algorithm/all.cpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2007 Dan Marsden Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -11,6 +12,24 @@ #include #include +namespace +{ + struct search_for + { + explicit search_for(int search) + : search(search) + {} + + template + bool operator()(T const& v) const + { + return v == search; + } + + int search; + }; +} + int main() { @@ -27,9 +46,11 @@ main() } { - typedef boost::mpl::vector_c mpl_vec; - BOOST_TEST(boost::fusion::all(mpl_vec(), boost::lambda::_1 < 4)); - BOOST_TEST(!boost::fusion::all(mpl_vec(), boost::lambda::_1 == 2)); + typedef boost::mpl::vector_c mpl_vec; + // We cannot use lambda here as mpl vec iterators return + // rvalues, and lambda needs lvalues. + BOOST_TEST(boost::fusion::all(mpl_vec(), search_for(1))); + BOOST_TEST(!boost::fusion::all(mpl_vec(), search_for(2))); } return boost::report_errors(); diff --git a/test/algorithm/any.cpp b/test/algorithm/any.cpp index 2c437f7b..71685ef2 100644 --- a/test/algorithm/any.cpp +++ b/test/algorithm/any.cpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman Copyright (c) 2005 Eric Niebler + Copyright (c) Dan Marsden Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,6 +13,24 @@ #include #include +namespace +{ + struct search_for + { + explicit search_for(int search) + : search(search) + {} + + template + bool operator()(T const& v) const + { + return v == search; + } + + int search; + }; +} + int main() { @@ -27,8 +46,10 @@ main() { typedef boost::mpl::vector_c mpl_vec; - BOOST_TEST(boost::fusion::any(mpl_vec(), boost::lambda::_1 == 2)); - BOOST_TEST(!boost::fusion::any(mpl_vec(), boost::lambda::_1 == 4)); + // We cannot use lambda here as mpl vec iterators return + // rvalues, and lambda needs lvalues. + BOOST_TEST(boost::fusion::any(mpl_vec(), search_for(2))); + BOOST_TEST(!boost::fusion::any(mpl_vec(), search_for(4))); } return boost::report_errors(); diff --git a/test/algorithm/none.cpp b/test/algorithm/none.cpp index 2e879cb9..5747494b 100644 --- a/test/algorithm/none.cpp +++ b/test/algorithm/none.cpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2007 Dan Marsden Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -11,6 +12,24 @@ #include #include +namespace +{ + struct search_for + { + explicit search_for(int search) + : search(search) + {} + + template + bool operator()(T const& v) const + { + return v == search; + } + + int search; + }; +} + int main() { @@ -28,8 +47,10 @@ main() { typedef boost::mpl::vector_c mpl_vec; - BOOST_TEST(boost::fusion::none(mpl_vec(), boost::lambda::_1 > 4)); - BOOST_TEST(!boost::fusion::none(mpl_vec(), boost::lambda::_1 != 2)); + // We cannot use lambda here as mpl vec iterators return + // rvalues, and lambda needs lvalues. + BOOST_TEST(boost::fusion::none(mpl_vec(), search_for(4))); + BOOST_TEST(!boost::fusion::none(mpl_vec(), search_for(3))); } return boost::report_errors();