Add convert tests for non-assoc containers.

This commit is contained in:
Kohei Takahashi
2015-08-25 23:36:32 +09:00
parent 1bde5c6fa3
commit 10d9f0ffba
8 changed files with 149 additions and 0 deletions

View File

@ -65,6 +65,12 @@ project
[ run sequence/boost_tuple.cpp : : : : ]
[ run sequence/boost_tuple_iterator.cpp : : : : ]
[ run sequence/cons.cpp : : : : ]
[ run sequence/convert_boost_tuple.cpp : : : : ]
[ run sequence/convert_deque.cpp : : : : ]
[ run sequence/convert_list.cpp : : : : ]
[ run sequence/convert_std_pair.cpp : : : : ]
[ run sequence/convert_std_tuple.cpp : : : : ]
[ run sequence/convert_vector.cpp : : : : ]
[ run sequence/filter_view.cpp : : : : ]
[ run sequence/hash.cpp : : : : ]
[ run sequence/io.cpp : : : : ]

51
test/sequence/convert.hpp Normal file
View File

@ -0,0 +1,51 @@
/*=============================================================================
Copyright (c) 2015 Kohei Takahashi
Use modification and distribution are subject to 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).
==============================================================================*/
#include <string>
#include <boost/config.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/fusion/include/convert.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/deque.hpp>
#include <boost/fusion/include/list.hpp>
#include <boost/fusion/include/boost_tuple.hpp>
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/fusion/include/std_tuple.hpp>
#endif
template <typename Tag>
void test(FUSION_SEQUENCE<int, std::string> const& seq)
{
typedef typename
boost::fusion::result_of::convert<
Tag
, FUSION_SEQUENCE<int, std::string>
>::type
type;
type v = boost::fusion::convert<Tag>(seq);
BOOST_TEST((boost::fusion::at_c<0>(v) == 123));
BOOST_TEST((boost::fusion::at_c<1>(v) == "Hola!!!"));
}
int main()
{
FUSION_SEQUENCE<int, std::string> seq(123, "Hola!!!");
test<boost::fusion::vector_tag>(seq);
test<boost::fusion::deque_tag>(seq);
test<boost::fusion::cons_tag>(seq);
test<boost::fusion::boost_tuple_tag>(seq);
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
test<boost::fusion::std_tuple_tag>(seq);
#endif
return boost::report_errors();
}

View File

@ -0,0 +1,14 @@
/*=============================================================================
Copyright (c) 2015 Kohei Takahashi
Use modification and distribution are subject to 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).
==============================================================================*/
#include <boost/tuple/tuple.hpp>
#include <boost/fusion/include/boost_tuple.hpp>
#define FUSION_SEQUENCE boost::tuples::tuple
#include "convert.hpp"

View File

@ -0,0 +1,13 @@
/*=============================================================================
Copyright (c) 2015 Kohei Takahashi
Use modification and distribution are subject to 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).
==============================================================================*/
#include <boost/fusion/include/deque.hpp>
#define FUSION_SEQUENCE boost::fusion::deque
#include "convert.hpp"

View File

@ -0,0 +1,13 @@
/*=============================================================================
Copyright (c) 2015 Kohei Takahashi
Use modification and distribution are subject to 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).
==============================================================================*/
#include <boost/fusion/include/list.hpp>
#define FUSION_SEQUENCE boost::fusion::list
#include "convert.hpp"

View File

@ -0,0 +1,14 @@
/*=============================================================================
Copyright (c) 2015 Kohei Takahashi
Use modification and distribution are subject to 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).
==============================================================================*/
#include <utility>
#include <boost/fusion/include/std_pair.hpp>
#define FUSION_SEQUENCE std::pair
#include "convert.hpp"

View File

@ -0,0 +1,25 @@
/*=============================================================================
Copyright (c) 2015 Kohei Takahashi
Use modification and distribution are subject to 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).
==============================================================================*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <tuple>
#include <boost/fusion/include/std_tuple.hpp>
#define FUSION_SEQUENCE std::tuple
#include "convert.hpp"
#else
int main()
{
}
#endif

View File

@ -0,0 +1,13 @@
/*=============================================================================
Copyright (c) 2015 Kohei Takahashi
Use modification and distribution are subject to 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).
==============================================================================*/
#include <boost/fusion/include/vector.hpp>
#define FUSION_SEQUENCE boost::fusion::vector
#include "convert.hpp"