mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-16 05:42:20 +02:00
adding tests for variant as adapted sequence
[SVN r36015]
This commit is contained in:
@ -69,6 +69,7 @@ import testing ;
|
||||
[ run sequence/single_view.cpp : : : : ]
|
||||
[ run sequence/std_pair.cpp : : : : ]
|
||||
[ run sequence/array.cpp : : : : ]
|
||||
[ run sequence/variant.cpp : : : : ]
|
||||
[ run sequence/tuple_comparison.cpp : : : : ]
|
||||
[ run sequence/tuple_construction.cpp : : : : ]
|
||||
[ run sequence/tuple_copy.cpp : : : : ]
|
||||
|
46
test/sequence/variant.cpp
Normal file
46
test/sequence/variant.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
Use, modification and distribution is 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/sequence/adapted/variant.hpp>
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
#include <boost/fusion/iterator/prior.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
#include <boost/fusion/iterator/distance.hpp>
|
||||
#include <boost/fusion/iterator/value_of.hpp>
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
int main()
|
||||
{
|
||||
namespace fusion = boost::fusion;
|
||||
typedef boost::variant<double, std::string> var_type;
|
||||
var_type var = "hello";
|
||||
BOOST_TEST(fusion::size(var) == 2);
|
||||
BOOST_TEST(fusion::distance(fusion::begin(var), fusion::end(var)) == 2);
|
||||
BOOST_TEST(*fusion::next(fusion::begin(var)) == "hello");
|
||||
BOOST_TEST(fusion::next(fusion::next(fusion::begin(var))) == fusion::end(var));
|
||||
BOOST_MPL_ASSERT((boost::is_same<
|
||||
fusion::result_of::value_of<fusion::result_of::begin<var_type>::type>::type,
|
||||
double>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<
|
||||
fusion::result_of::value_of<fusion::result_of::next<fusion::result_of::begin<var_type>::type>::type>::type,
|
||||
std::string>));
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user