File: resize.cpp

package info (click to toggle)
boost1.74 1.74.0%2Bds1-21
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 463,588 kB
  • sloc: cpp: 3,338,117; xml: 131,293; python: 33,088; ansic: 14,292; asm: 4,038; sh: 3,353; makefile: 1,193; perl: 1,036; yacc: 478; php: 212; ruby: 102; lisp: 24; sql: 13; csh: 6
file content (98 lines) | stat: -rw-r--r-- 2,774 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
 [auto_generated]
 libs/numeric/odeint/test/resize.cpp

 [begin_description]
 This file tests the resize function of odeint.
 [end_description]

 Copyright 2012 Karsten Ahnert
 Copyright 2012 Mario Mulansky

 Distributed under the Boost Software License, Version 1.0.
 (See accompanying file LICENSE_1_0.txt or
 copy at http://www.boost.org/LICENSE_1_0.txt)
 */

// disable checked iterator warning for msvc
#include <boost/config.hpp>
#ifdef BOOST_MSVC
    #pragma warning(disable:4996)
#endif

#define BOOST_TEST_MODULE odeint_resize

#include <vector>
#include <cmath>

#include <boost/test/unit_test.hpp>

#include <boost/numeric/odeint/util/resize.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/units/systems/si/length.hpp>
#include <boost/units/systems/si/time.hpp>
#include <boost/units/systems/si/velocity.hpp>
#include <boost/units/systems/si/acceleration.hpp>
#include <boost/units/systems/si/io.hpp>


using namespace boost::unit_test;
using namespace boost::numeric::odeint;

BOOST_AUTO_TEST_CASE( test_vector )
{
    std::vector< double > x1( 10 );
    std::vector< double > x2;
    resize( x2 , x1 );
    BOOST_CHECK( x2.size() == 10 );
}


BOOST_AUTO_TEST_CASE( test_fusion_vector_of_vector )
{
    typedef boost::fusion::vector< std::vector< double > , std::vector< double > > state_type;
    state_type x1;
    boost::fusion::at_c< 0 >( x1 ).resize( 10 );
    boost::fusion::at_c< 1 >( x1 ).resize( 10 );
    state_type x2;
    resize( x2 , x1 );
    BOOST_CHECK( boost::fusion::at_c< 0 >( x2 ).size() == 10 );
    BOOST_CHECK( boost::fusion::at_c< 1 >( x2 ).size() == 10 );
}


BOOST_AUTO_TEST_CASE( test_fusion_vector_mixed1 )
{
    typedef boost::fusion::vector< std::vector< double > , double > state_type;
    state_type x1;
    boost::fusion::at_c< 0 >( x1 ).resize( 10 );
    state_type x2;
    resize( x2 , x1 );
    BOOST_CHECK( boost::fusion::at_c< 0 >( x2 ).size() == 10 );
}

BOOST_AUTO_TEST_CASE( test_fusion_vector_mixed2 )
{
    typedef boost::fusion::vector< double , std::vector< double > , double > state_type;
    state_type x1;
    boost::fusion::at_c< 1 >( x1 ).resize( 10 );
    state_type x2;
    resize( x2 , x1 );
    BOOST_CHECK( boost::fusion::at_c< 1 >( x2 ).size() == 10 );
}

BOOST_AUTO_TEST_CASE( test_fusion_quantity_sequence )
{
    namespace units = boost::units;
    namespace si = boost::units::si;

    typedef double value_type;
    typedef units::quantity< si::time , value_type > time_type;
    typedef units::quantity< si::length , value_type > length_type;
    typedef units::quantity< si::velocity , value_type > velocity_type;
    typedef boost::fusion::vector< length_type , velocity_type > state_type;

    state_type x1 , x2;
    resize( x2 , x1 );
}