3 libs/numeric/odeint/test/is_resizeable.cpp
6 This file tests is_resizeable meta-function of odeint.
9 Copyright 2012 Karsten Ahnert
10 Copyright 2012 Mario Mulansky
12 Distributed under the Boost Software License, Version 1.0.
13 (See accompanying file LICENSE_1_0.txt or
14 copy at http://www.boost.org/LICENSE_1_0.txt)
17 // disable checked iterator warning for msvc
18 #include <boost/config.hpp>
20 #pragma warning(disable:4996)
23 #define BOOST_TEST_MODULE odeint_is_resizeable
28 #include <boost/test/unit_test.hpp>
30 #include <boost/numeric/odeint/util/is_resizeable.hpp>
31 #include <boost/fusion/include/vector.hpp>
32 #include <boost/units/systems/si/length.hpp>
33 #include <boost/units/systems/si/time.hpp>
34 #include <boost/units/systems/si/velocity.hpp>
35 #include <boost/units/systems/si/acceleration.hpp>
36 #include <boost/units/systems/si/io.hpp>
39 using namespace boost::unit_test
;
40 using namespace boost::numeric::odeint
;
42 template< typename T
> struct my_seq1
{};
43 template< typename T
> struct my_seq2
{};
45 namespace boost
{ namespace fusion
{ namespace traits
{
47 template< typename T
> struct is_sequence
< my_seq1
< T
> > : boost::true_type
{};
48 template< typename T
> struct is_sequence
< my_seq2
< T
> > : boost::true_type
{};
49 } } } // boost::fusion::traits
51 namespace boost
{ namespace numeric
{ namespace odeint
{
53 template< typename T
>
54 struct is_resizeable
< my_seq2
< T
> > : boost::true_type
{};
56 } } } // boost::numeric::odeint
60 BOOST_AUTO_TEST_CASE( test_vector
)
62 BOOST_CHECK( is_resizeable
< std::vector
< int > >::value
);
65 BOOST_AUTO_TEST_CASE( test_double
)
67 BOOST_CHECK( !( is_resizeable
< double >::value
) );
70 BOOST_AUTO_TEST_CASE( test_fusion_vector_of_vector
)
72 typedef boost::fusion::vector
< std::vector
< double > , std::vector
< double > > state_type
;
73 BOOST_CHECK( is_resizeable
< state_type
>::value
);
76 BOOST_AUTO_TEST_CASE( test_fusion_vector_of_double
)
78 typedef boost::fusion::vector
< double , double > state_type
;
79 BOOST_CHECK( !( is_resizeable
< state_type
>::value
) );
82 BOOST_AUTO_TEST_CASE( test_fusion_vector_mixed1
)
84 typedef boost::fusion::vector
< double , std::vector
< double > > state_type
;
85 BOOST_CHECK( is_resizeable
< state_type
>::value
);
88 BOOST_AUTO_TEST_CASE( test_fusion_vector_mixed2
)
90 typedef boost::fusion::vector
< std::vector
< double > , double > state_type
;
91 BOOST_CHECK( is_resizeable
< state_type
>::value
);
94 BOOST_AUTO_TEST_CASE( test_fusion_quantity_sequence
)
96 namespace units
= boost::units
;
97 namespace si
= boost::units::si
;
99 typedef double value_type
;
100 typedef units::quantity
< si::time
, value_type
> time_type
;
101 typedef units::quantity
< si::length
, value_type
> length_type
;
102 typedef units::quantity
< si::velocity
, value_type
> velocity_type
;
103 typedef boost::fusion::vector
< length_type
, velocity_type
> state_type
;
105 BOOST_CHECK( !( is_resizeable
< state_type
>::value
) );
108 BOOST_AUTO_TEST_CASE( test_my_seq1
)
110 BOOST_CHECK( !is_resizeable
< my_seq1
< double > >::value
);
113 BOOST_AUTO_TEST_CASE( test_my_seq2
)
115 BOOST_CHECK( is_resizeable
< my_seq2
< double > >::value
);