mirror of
https://github.com/boostorg/range.git
synced 2025-07-31 13:27:31 +02:00
trac 6742 - unit test showing working phoenix combined with the transformed adaptor.
This commit is contained in:
@@ -44,6 +44,7 @@ test-suite range :
|
|||||||
[ range-test adaptor_test/sliced ]
|
[ range-test adaptor_test/sliced ]
|
||||||
[ range-test adaptor_test/strided ]
|
[ range-test adaptor_test/strided ]
|
||||||
[ range-test adaptor_test/strided2 ]
|
[ range-test adaptor_test/strided2 ]
|
||||||
|
[ range-test adaptor_test/ticket_6742_transformed_c4789_warning ]
|
||||||
[ range-test adaptor_test/ticket_8676_sliced_transformed ]
|
[ range-test adaptor_test/ticket_8676_sliced_transformed ]
|
||||||
[ range-test adaptor_test/ticket_9519_strided_reversed ]
|
[ range-test adaptor_test/ticket_9519_strided_reversed ]
|
||||||
[ range-test adaptor_test/tokenized ]
|
[ range-test adaptor_test/tokenized ]
|
||||||
|
69
test/adaptor_test/ticket_6742_transformed_c4789_warning.cpp
Normal file
69
test/adaptor_test/ticket_6742_transformed_c4789_warning.cpp
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
// Boost.Range library
|
||||||
|
//
|
||||||
|
// Copyright Neil Groves 2014. Use, modification and
|
||||||
|
// distribution is subject to 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)
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// For more information, see http://www.boost.org/libs/range/
|
||||||
|
//
|
||||||
|
#include <boost/phoenix/core.hpp>
|
||||||
|
#include <boost/phoenix/operator.hpp>
|
||||||
|
#include <boost/range/adaptor/transformed.hpp>
|
||||||
|
#include <boost/range/algorithm_ext/push_back.hpp>
|
||||||
|
#include <boost/test/test_tools.hpp>
|
||||||
|
#include <boost/test/unit_test.hpp>
|
||||||
|
#include <iterator>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
struct test_struct
|
||||||
|
{
|
||||||
|
double x;
|
||||||
|
double y;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct get_x
|
||||||
|
{
|
||||||
|
typedef double result_type;
|
||||||
|
double operator()(const test_struct& s) const
|
||||||
|
{
|
||||||
|
return s.x;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void range_transformed_warning()
|
||||||
|
{
|
||||||
|
using namespace boost::phoenix::arg_names;
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
|
||||||
|
test_struct t;
|
||||||
|
t.x = 2.0;
|
||||||
|
t.y = -4.0;
|
||||||
|
std::vector<test_struct> v(10u, t);
|
||||||
|
|
||||||
|
std::vector<double> output1;
|
||||||
|
boost::push_back(output1, v | transformed((&arg1)->*& test_struct::x));
|
||||||
|
|
||||||
|
std::vector<double> output2;
|
||||||
|
boost::push_back(output2, v | transformed(get_x()));
|
||||||
|
|
||||||
|
BOOST_CHECK_EQUAL_COLLECTIONS(
|
||||||
|
output1.begin(), output1.end(),
|
||||||
|
output2.begin(), output2.end());
|
||||||
|
}
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
|
boost::unit_test::test_suite*
|
||||||
|
init_unit_test_suite(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
boost::unit_test::test_suite* test
|
||||||
|
= BOOST_TEST_SUITE( "Range adaptors - transformed warning" );
|
||||||
|
|
||||||
|
test->add(BOOST_TEST_CASE(&range_transformed_warning));
|
||||||
|
|
||||||
|
return test;
|
||||||
|
}
|
Reference in New Issue
Block a user