resize.cpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. [auto_generated]
  3. libs/numeric/odeint/test/resize.cpp
  4. [begin_description]
  5. This file tests the resize 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_resize
  19. #include <vector>
  20. #include <cmath>
  21. #include <boost/test/unit_test.hpp>
  22. #include <boost/numeric/odeint/util/resize.hpp>
  23. #include <boost/fusion/include/vector.hpp>
  24. #include <boost/fusion/include/at.hpp>
  25. #include <boost/units/systems/si/length.hpp>
  26. #include <boost/units/systems/si/time.hpp>
  27. #include <boost/units/systems/si/velocity.hpp>
  28. #include <boost/units/systems/si/acceleration.hpp>
  29. #include <boost/units/systems/si/io.hpp>
  30. using namespace boost::unit_test;
  31. using namespace boost::numeric::odeint;
  32. BOOST_AUTO_TEST_CASE( test_vector )
  33. {
  34. std::vector< double > x1( 10 );
  35. std::vector< double > x2;
  36. resize( x2 , x1 );
  37. BOOST_CHECK( x2.size() == 10 );
  38. }
  39. BOOST_AUTO_TEST_CASE( test_fusion_vector_of_vector )
  40. {
  41. typedef boost::fusion::vector< std::vector< double > , std::vector< double > > state_type;
  42. state_type x1;
  43. boost::fusion::at_c< 0 >( x1 ).resize( 10 );
  44. boost::fusion::at_c< 1 >( x1 ).resize( 10 );
  45. state_type x2;
  46. resize( x2 , x1 );
  47. BOOST_CHECK( boost::fusion::at_c< 0 >( x2 ).size() == 10 );
  48. BOOST_CHECK( boost::fusion::at_c< 1 >( x2 ).size() == 10 );
  49. }
  50. BOOST_AUTO_TEST_CASE( test_fusion_vector_mixed1 )
  51. {
  52. typedef boost::fusion::vector< std::vector< double > , double > state_type;
  53. state_type x1;
  54. boost::fusion::at_c< 0 >( x1 ).resize( 10 );
  55. state_type x2;
  56. resize( x2 , x1 );
  57. BOOST_CHECK( boost::fusion::at_c< 0 >( x2 ).size() == 10 );
  58. }
  59. BOOST_AUTO_TEST_CASE( test_fusion_vector_mixed2 )
  60. {
  61. typedef boost::fusion::vector< double , std::vector< double > , double > state_type;
  62. state_type x1;
  63. boost::fusion::at_c< 1 >( x1 ).resize( 10 );
  64. state_type x2;
  65. resize( x2 , x1 );
  66. BOOST_CHECK( boost::fusion::at_c< 1 >( x2 ).size() == 10 );
  67. }
  68. BOOST_AUTO_TEST_CASE( test_fusion_quantity_sequence )
  69. {
  70. namespace units = boost::units;
  71. namespace si = boost::units::si;
  72. typedef double value_type;
  73. typedef units::quantity< si::time , value_type > time_type;
  74. typedef units::quantity< si::length , value_type > length_type;
  75. typedef units::quantity< si::velocity , value_type > velocity_type;
  76. typedef boost::fusion::vector< length_type , velocity_type > state_type;
  77. state_type x1 , x2;
  78. resize( x2 , x1 );
  79. }