ticket_5544_terminate_irange.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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/irange.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. void test_irange_termination()
  21. {
  22. std::vector<int> reference;
  23. for (int i = 0; i < 9; i += 2)
  24. reference.push_back(i);
  25. std::vector<int> actual;
  26. boost::push_back(actual, boost::irange(0,9,2));
  27. BOOST_CHECK_EQUAL_COLLECTIONS(actual.begin(), actual.end(),
  28. reference.begin(), reference.end());
  29. }
  30. }
  31. }
  32. boost::unit_test::test_suite*
  33. init_unit_test_suite(int argc, char* argv[])
  34. {
  35. boost::unit_test::test_suite* test
  36. = BOOST_TEST_SUITE( "RangeTestSuite.ticket_5544" );
  37. test->add( BOOST_TEST_CASE( &boost::test_irange_termination ) );
  38. return test;
  39. }