adding fusion docs and tests

[SVN r34920]
This commit is contained in:
Joel de Guzman
2006-08-22 15:57:13 +00:00
parent 75b9d13a88
commit c31253d8c1
351 changed files with 42280 additions and 0 deletions

80
test/algorithm/find.cpp Normal file
View File

@ -0,0 +1,80 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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/detail/lightweight_test.hpp>
#include <boost/fusion/sequence/container/vector/vector.hpp>
#include <boost/fusion/sequence/adapted/mpl.hpp>
#include <boost/fusion/sequence/container/set/set.hpp>
#include <boost/fusion/sequence/container/map/map.hpp>
#include <boost/fusion/algorithm/query/find.hpp>
#include <boost/fusion/iterator/deref.hpp>
#include <boost/mpl/vector.hpp>
#include <string>
struct X
{
operator int() const
{
return 12345;
}
};
int
main()
{
using namespace boost::fusion;
using boost::mpl::identity;
{
typedef vector<int, char, int, double> seq_type;
seq_type seq(12345, 'x', 678910, 3.36);
std::cout << *boost::fusion::find<char>(seq) << std::endl;
BOOST_TEST(*boost::fusion::find<char>(seq) == 'x');
std::cout << *boost::fusion::find<int>(seq) << std::endl;
BOOST_TEST(*boost::fusion::find<int>(seq) == 12345);
std::cout << *boost::fusion::find<double>(seq) << std::endl;
BOOST_TEST(*boost::fusion::find<double>(seq) == 3.36);
BOOST_TEST(boost::fusion::find<bool>(seq) == boost::fusion::end(seq));
}
{
typedef set<int, char, double> seq_type;
seq_type seq(12345, 'x', 3.36);
std::cout << *boost::fusion::find<char>(seq) << std::endl;
BOOST_TEST(*boost::fusion::find<char>(seq) == 'x');
BOOST_TEST(boost::fusion::find<bool>(seq) == boost::fusion::end(seq));
}
{
typedef map<
pair<int, char>
, pair<double, std::string> >
map_type;
map_type seq(
make_pair<int>('X')
, make_pair<double>("Men"));
std::cout << *boost::fusion::find<int>(seq) << std::endl;
std::cout << *boost::fusion::find<double>(seq) << std::endl;
BOOST_TEST((*boost::fusion::find<int>(seq)).second == 'X');
BOOST_TEST((*boost::fusion::find<double>(seq)).second == "Men");
BOOST_TEST(boost::fusion::find<bool>(seq) == boost::fusion::end(seq));
}
{
typedef boost::mpl::vector<int, char, X, double> mpl_vec;
BOOST_TEST((*boost::fusion::find<X>(mpl_vec()) == 12345));
BOOST_TEST(boost::fusion::find<bool>(mpl_vec()) == boost::fusion::end(mpl_vec()));
}
return boost::report_errors();
}