fixing defective test case with bad rvalue / lvalue handling issue

[SVN r37819]
This commit is contained in:
Dan Marsden
2007-05-30 06:47:39 +00:00
parent 6097406ca1
commit da31732ca3
3 changed files with 70 additions and 7 deletions

View File

@ -1,5 +1,6 @@
/*============================================================================= /*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2007 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying 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) file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -11,6 +12,24 @@
#include <boost/lambda/lambda.hpp> #include <boost/lambda/lambda.hpp>
#include <boost/mpl/vector_c.hpp> #include <boost/mpl/vector_c.hpp>
namespace
{
struct search_for
{
explicit search_for(int search)
: search(search)
{}
template<typename T>
bool operator()(T const& v) const
{
return v == search;
}
int search;
};
}
int int
main() main()
{ {
@ -27,9 +46,11 @@ main()
} }
{ {
typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec; typedef boost::mpl::vector_c<int, 1> mpl_vec;
BOOST_TEST(boost::fusion::all(mpl_vec(), boost::lambda::_1 < 4)); // We cannot use lambda here as mpl vec iterators return
BOOST_TEST(!boost::fusion::all(mpl_vec(), boost::lambda::_1 == 2)); // 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(); return boost::report_errors();

View File

@ -1,6 +1,7 @@
/*============================================================================= /*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2005 Eric Niebler Copyright (c) 2005 Eric Niebler
Copyright (c) Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying 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) file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -12,6 +13,24 @@
#include <boost/lambda/lambda.hpp> #include <boost/lambda/lambda.hpp>
#include <boost/mpl/vector_c.hpp> #include <boost/mpl/vector_c.hpp>
namespace
{
struct search_for
{
explicit search_for(int search)
: search(search)
{}
template<typename T>
bool operator()(T const& v) const
{
return v == search;
}
int search;
};
}
int int
main() main()
{ {
@ -27,8 +46,10 @@ main()
{ {
typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec; typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec;
BOOST_TEST(boost::fusion::any(mpl_vec(), boost::lambda::_1 == 2)); // We cannot use lambda here as mpl vec iterators return
BOOST_TEST(!boost::fusion::any(mpl_vec(), boost::lambda::_1 == 4)); // 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(); return boost::report_errors();

View File

@ -1,5 +1,6 @@
/*============================================================================= /*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2007 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying 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) file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -11,6 +12,24 @@
#include <boost/lambda/lambda.hpp> #include <boost/lambda/lambda.hpp>
#include <boost/mpl/vector_c.hpp> #include <boost/mpl/vector_c.hpp>
namespace
{
struct search_for
{
explicit search_for(int search)
: search(search)
{}
template<typename T>
bool operator()(T const& v) const
{
return v == search;
}
int search;
};
}
int int
main() main()
{ {
@ -28,8 +47,10 @@ main()
{ {
typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec; typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec;
BOOST_TEST(boost::fusion::none(mpl_vec(), boost::lambda::_1 > 4)); // We cannot use lambda here as mpl vec iterators return
BOOST_TEST(!boost::fusion::none(mpl_vec(), boost::lambda::_1 != 2)); // 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(); return boost::report_errors();