adding tests for variant as adapted sequence

[SVN r36015]
This commit is contained in:
Dan Marsden
2006-11-12 23:08:59 +00:00
parent 2a652e5424
commit 6860872d7b
2 changed files with 47 additions and 0 deletions

View File

@ -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
View 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();
}