split.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. [auto_generated]
  3. libs/numeric/odeint/test/split.cpp
  4. [begin_description]
  5. Test the range split.
  6. [end_description]
  7. Copyright 2013 Karsten Ahnert
  8. Copyright 2013 Mario Mulansky
  9. Copyright 2013 Pascal Germroth
  10. Distributed under the Boost Software License, Version 1.0.
  11. (See accompanying file LICENSE_1_0.txt or
  12. copy at http://www.boost.org/LICENSE_1_0.txt)
  13. */
  14. #define BOOST_TEST_MODULE odeint_split
  15. #include <iostream>
  16. #include <boost/test/unit_test.hpp>
  17. #include <boost/numeric/odeint/util/split_adaptor.hpp>
  18. #include <boost/range/irange.hpp>
  19. template<class T>
  20. inline void dump_range(const T &r) {
  21. std::cout << '[';
  22. std::copy(boost::begin(r), boost::end(r), std::ostream_iterator<
  23. typename std::iterator_traits<
  24. typename boost::range_iterator<const T>::type
  25. >::value_type >(std::cout, " ") );
  26. std::cout << ']';
  27. }
  28. template<class A, class B>
  29. inline void check_equal_range(const A a, const B b) {
  30. BOOST_CHECK_EQUAL_COLLECTIONS( boost::begin(a), boost::end(a), boost::begin(b), boost::end(b) );
  31. }
  32. using namespace boost::unit_test;
  33. using namespace boost::numeric::odeint::detail;
  34. using namespace boost;
  35. BOOST_AUTO_TEST_CASE( test_eleven )
  36. {
  37. // 0 1 2 3 | 4 5 6 7 | 8 9 10 11
  38. check_equal_range( irange(0, 12) | split(0, 3), irange(0, 4) );
  39. check_equal_range( irange(0, 12) | split(1, 3), irange(4, 8) );
  40. check_equal_range( irange(0, 12) | split(2, 3), irange(8, 12) );
  41. }
  42. BOOST_AUTO_TEST_CASE( test_ten )
  43. {
  44. // 0 1 2 3 | 4 5 6 7 | 8 9 10
  45. check_equal_range( irange(0, 11) | split(0, 3), irange(0, 4) );
  46. check_equal_range( irange(0, 11) | split(1, 3), irange(4, 8) );
  47. check_equal_range( irange(0, 11) | split(2, 3), irange(8, 11) );
  48. }
  49. BOOST_AUTO_TEST_CASE( test_nine )
  50. {
  51. // 0 1 2 3 | 4 5 6 | 7 8 9
  52. check_equal_range( irange(0, 10) | split(0, 3), irange(0, 4) );
  53. check_equal_range( irange(0, 10) | split(1, 3), irange(4, 7) );
  54. check_equal_range( irange(0, 10) | split(2, 3), irange(7, 10) );
  55. }