blob: db40f4bfe00be82a22a86ef97fa23a8dff3753d6 [file] [log] [blame]
Brian Silverman7c33ab22018-08-04 17:14:51 -07001/*
2 [auto_generated]
3 libs/numeric/odeint/test/resize.cpp
4
5 [begin_description]
6 This file tests the resize function of odeint.
7 [end_description]
8
9 Copyright 2012 Karsten Ahnert
10 Copyright 2012 Mario Mulansky
11
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)
15 */
16
17// disable checked iterator warning for msvc
18#include <boost/config.hpp>
19#ifdef BOOST_MSVC
20 #pragma warning(disable:4996)
21#endif
22
23#define BOOST_TEST_MODULE odeint_resize
24
25#include <vector>
26#include <cmath>
27
28#include <boost/test/unit_test.hpp>
29
30#include <boost/numeric/odeint/util/resize.hpp>
31#include <boost/fusion/include/vector.hpp>
32#include <boost/fusion/include/at.hpp>
33#include <boost/units/systems/si/length.hpp>
34#include <boost/units/systems/si/time.hpp>
35#include <boost/units/systems/si/velocity.hpp>
36#include <boost/units/systems/si/acceleration.hpp>
37#include <boost/units/systems/si/io.hpp>
38
39
40using namespace boost::unit_test;
41using namespace boost::numeric::odeint;
42
43BOOST_AUTO_TEST_CASE( test_vector )
44{
45 std::vector< double > x1( 10 );
46 std::vector< double > x2;
47 resize( x2 , x1 );
48 BOOST_CHECK( x2.size() == 10 );
49}
50
51
52BOOST_AUTO_TEST_CASE( test_fusion_vector_of_vector )
53{
54 typedef boost::fusion::vector< std::vector< double > , std::vector< double > > state_type;
55 state_type x1;
56 boost::fusion::at_c< 0 >( x1 ).resize( 10 );
57 boost::fusion::at_c< 1 >( x1 ).resize( 10 );
58 state_type x2;
59 resize( x2 , x1 );
60 BOOST_CHECK( boost::fusion::at_c< 0 >( x2 ).size() == 10 );
61 BOOST_CHECK( boost::fusion::at_c< 1 >( x2 ).size() == 10 );
62}
63
64
65BOOST_AUTO_TEST_CASE( test_fusion_vector_mixed1 )
66{
67 typedef boost::fusion::vector< std::vector< double > , double > state_type;
68 state_type x1;
69 boost::fusion::at_c< 0 >( x1 ).resize( 10 );
70 state_type x2;
71 resize( x2 , x1 );
72 BOOST_CHECK( boost::fusion::at_c< 0 >( x2 ).size() == 10 );
73}
74
75BOOST_AUTO_TEST_CASE( test_fusion_vector_mixed2 )
76{
77 typedef boost::fusion::vector< double , std::vector< double > , double > state_type;
78 state_type x1;
79 boost::fusion::at_c< 1 >( x1 ).resize( 10 );
80 state_type x2;
81 resize( x2 , x1 );
82 BOOST_CHECK( boost::fusion::at_c< 1 >( x2 ).size() == 10 );
83}
84
85BOOST_AUTO_TEST_CASE( test_fusion_quantity_sequence )
86{
87 namespace units = boost::units;
88 namespace si = boost::units::si;
89
90 typedef double value_type;
91 typedef units::quantity< si::time , value_type > time_type;
92 typedef units::quantity< si::length , value_type > length_type;
93 typedef units::quantity< si::velocity , value_type > velocity_type;
94 typedef boost::fusion::vector< length_type , velocity_type > state_type;
95
96 state_type x1 , x2;
97 resize( x2 , x1 );
98}