2
0
mirror of https://github.com/boostorg/odeint.git synced 2026-01-22 05:22:25 +00:00
Files
odeint/test/is_resizeable.cpp
2023-12-22 05:45:45 -05:00

139 lines
3.9 KiB
C++

/*
[auto_generated]
libs/numeric/odeint/test/is_resizeable.cpp
[begin_description]
This file tests is_resizeable meta-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
// Need this PR to be merged to actually fix the issue: https://github.com/boostorg/ublas/pull/153
#if defined(__clang__) && __clang_major__ >= 13 && !defined(__APPLE__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-copy-with-user-provided-copy"
#elif defined(__clang__) && __clang_major__ >= 10
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-copy"
#elif defined(__GNUC__) && __GNUC__ >= 9
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-copy"
#elif defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable : 5267)
#endif
#define BOOST_TEST_MODULE odeint_is_resizeable
#include <vector>
#include <cmath>
#include <boost/test/unit_test.hpp>
#include <boost/numeric/odeint/util/is_resizeable.hpp>
#include <boost/fusion/include/vector.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;
template< typename T > struct my_seq1 {};
template< typename T > struct my_seq2 {};
namespace boost { namespace fusion { namespace traits {
template< typename T > struct is_sequence< my_seq1< T > > : boost::true_type {};
template< typename T > struct is_sequence< my_seq2< T > > : boost::true_type {};
} } } // boost::fusion::traits
namespace boost { namespace numeric { namespace odeint {
template< typename T >
struct is_resizeable< my_seq2< T > > : boost::true_type {};
} } } // boost::numeric::odeint
BOOST_AUTO_TEST_CASE( test_vector )
{
BOOST_CHECK( is_resizeable< std::vector< int > >::value );
}
BOOST_AUTO_TEST_CASE( test_double )
{
BOOST_CHECK( !( is_resizeable< double >::value ) );
}
BOOST_AUTO_TEST_CASE( test_fusion_vector_of_vector )
{
typedef boost::fusion::vector< std::vector< double > , std::vector< double > > state_type;
BOOST_CHECK( is_resizeable< state_type >::value );
}
BOOST_AUTO_TEST_CASE( test_fusion_vector_of_double )
{
typedef boost::fusion::vector< double , double > state_type;
BOOST_CHECK( !( is_resizeable< state_type >::value ) );
}
BOOST_AUTO_TEST_CASE( test_fusion_vector_mixed1 )
{
typedef boost::fusion::vector< double , std::vector< double > > state_type;
BOOST_CHECK( is_resizeable< state_type >::value);
}
BOOST_AUTO_TEST_CASE( test_fusion_vector_mixed2 )
{
typedef boost::fusion::vector< std::vector< double > , double > state_type;
BOOST_CHECK( is_resizeable< state_type >::value );
}
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::length , value_type > length_type;
typedef units::quantity< si::velocity , value_type > velocity_type;
typedef boost::fusion::vector< length_type , velocity_type > state_type;
BOOST_CHECK( !( is_resizeable< state_type >::value ) );
}
BOOST_AUTO_TEST_CASE( test_my_seq1 )
{
BOOST_CHECK( !is_resizeable< my_seq1< double > >::value );
}
BOOST_AUTO_TEST_CASE( test_my_seq2 )
{
BOOST_CHECK( is_resizeable< my_seq2< double > >::value );
}
#if defined(__clang__) && __clang_major__ >= 10
#pragma clang diagnostic pop
#elif defined(__GNUC__) && __GNUC__ >= 9
#pragma GCC diagnostic pop
#elif defined(_MSC_VER)
#pragma warning(pop)
#endif