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