is_resizeable.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. [auto_generated]
  3. libs/numeric/odeint/test/is_resizeable.cpp
  4. [begin_description]
  5. This file tests is_resizeable meta-function of odeint.
  6. [end_description]
  7. Copyright 2012 Karsten Ahnert
  8. Copyright 2012 Mario Mulansky
  9. Distributed under the Boost Software License, Version 1.0.
  10. (See accompanying file LICENSE_1_0.txt or
  11. copy at http://www.boost.org/LICENSE_1_0.txt)
  12. */
  13. // disable checked iterator warning for msvc
  14. #include <boost/config.hpp>
  15. #ifdef BOOST_MSVC
  16. #pragma warning(disable:4996)
  17. #endif
  18. #define BOOST_TEST_MODULE odeint_is_resizeable
  19. #include <vector>
  20. #include <cmath>
  21. #include <boost/test/unit_test.hpp>
  22. #include <boost/numeric/odeint/util/is_resizeable.hpp>
  23. #include <boost/fusion/include/vector.hpp>
  24. #include <boost/units/systems/si/length.hpp>
  25. #include <boost/units/systems/si/time.hpp>
  26. #include <boost/units/systems/si/velocity.hpp>
  27. #include <boost/units/systems/si/acceleration.hpp>
  28. #include <boost/units/systems/si/io.hpp>
  29. using namespace boost::unit_test;
  30. using namespace boost::numeric::odeint;
  31. template< typename T > struct my_seq1 {};
  32. template< typename T > struct my_seq2 {};
  33. namespace boost { namespace fusion { namespace traits {
  34. template< typename T > struct is_sequence< my_seq1< T > > : boost::true_type {};
  35. template< typename T > struct is_sequence< my_seq2< T > > : boost::true_type {};
  36. } } } // boost::fusion::traits
  37. namespace boost { namespace numeric { namespace odeint {
  38. template< typename T >
  39. struct is_resizeable< my_seq2< T > > : boost::true_type {};
  40. } } } // boost::numeric::odeint
  41. BOOST_AUTO_TEST_CASE( test_vector )
  42. {
  43. BOOST_CHECK( is_resizeable< std::vector< int > >::value );
  44. }
  45. BOOST_AUTO_TEST_CASE( test_double )
  46. {
  47. BOOST_CHECK( !( is_resizeable< double >::value ) );
  48. }
  49. BOOST_AUTO_TEST_CASE( test_fusion_vector_of_vector )
  50. {
  51. typedef boost::fusion::vector< std::vector< double > , std::vector< double > > state_type;
  52. BOOST_CHECK( is_resizeable< state_type >::value );
  53. }
  54. BOOST_AUTO_TEST_CASE( test_fusion_vector_of_double )
  55. {
  56. typedef boost::fusion::vector< double , double > state_type;
  57. BOOST_CHECK( !( is_resizeable< state_type >::value ) );
  58. }
  59. BOOST_AUTO_TEST_CASE( test_fusion_vector_mixed1 )
  60. {
  61. typedef boost::fusion::vector< double , std::vector< double > > state_type;
  62. BOOST_CHECK( is_resizeable< state_type >::value);
  63. }
  64. BOOST_AUTO_TEST_CASE( test_fusion_vector_mixed2 )
  65. {
  66. typedef boost::fusion::vector< std::vector< double > , double > state_type;
  67. BOOST_CHECK( is_resizeable< state_type >::value );
  68. }
  69. BOOST_AUTO_TEST_CASE( test_fusion_quantity_sequence )
  70. {
  71. namespace units = boost::units;
  72. namespace si = boost::units::si;
  73. typedef double value_type;
  74. typedef units::quantity< si::time , value_type > time_type;
  75. typedef units::quantity< si::length , value_type > length_type;
  76. typedef units::quantity< si::velocity , value_type > velocity_type;
  77. typedef boost::fusion::vector< length_type , velocity_type > state_type;
  78. BOOST_CHECK( !( is_resizeable< state_type >::value ) );
  79. }
  80. BOOST_AUTO_TEST_CASE( test_my_seq1 )
  81. {
  82. BOOST_CHECK( !is_resizeable< my_seq1< double > >::value );
  83. }
  84. BOOST_AUTO_TEST_CASE( test_my_seq2 )
  85. {
  86. BOOST_CHECK( is_resizeable< my_seq2< double > >::value );
  87. }