ticket_5486.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Boost.Range library
  2. //
  3. // Copyright Neil Groves 2011. Use, modification and
  4. // distribution is subject to the Boost Software License, Version
  5. // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. //
  9. // For more information, see http://www.boost.org/libs/range/
  10. //
  11. #include <boost/range/adaptor/adjacent_filtered.hpp>
  12. #include <boost/range/algorithm_ext/push_back.hpp>
  13. #include <boost/test/test_tools.hpp>
  14. #include <boost/test/unit_test.hpp>
  15. #include <vector>
  16. namespace boost
  17. {
  18. namespace
  19. {
  20. class TestTicket5486Pred
  21. {
  22. public:
  23. typedef int first_argument_type;
  24. typedef int second_argument_type;
  25. typedef bool result_type;
  26. explicit TestTicket5486Pred(int x) {}
  27. bool operator()(int,int) const { return true; }
  28. private:
  29. TestTicket5486Pred();
  30. };
  31. // Ticket 5486 - pertained to predicates erroneous
  32. // requiring default construction
  33. void test_ticket_5486()
  34. {
  35. std::vector<int> v;
  36. boost::push_back(v, v | boost::adaptors::adjacent_filtered(TestTicket5486Pred(1)));
  37. BOOST_CHECK_EQUAL_COLLECTIONS( v.begin(), v.end(),
  38. v.begin(), v.end() );
  39. }
  40. }
  41. }
  42. boost::unit_test::test_suite*
  43. init_unit_test_suite(int argc, char* argv[])
  44. {
  45. boost::unit_test::test_suite* test
  46. = BOOST_TEST_SUITE( "RangeTestSuite.ticket_5486" );
  47. test->add( BOOST_TEST_CASE( &boost::test_ticket_5486 ) );
  48. return test;
  49. }