Adding a new test case for insert_range.

Tests whether insert_range works with set, set_c and map as it should.
This commit is contained in:
Bruno Dutra
2015-02-21 19:44:20 -02:00
parent f807edab2e
commit 77cda02d85

View File

@@ -15,9 +15,17 @@
#include <boost/mpl/find.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/set.hpp>
#include <boost/mpl/set_c.hpp>
#include <boost/mpl/map.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/logical.hpp>
#include <boost/mpl/contains.hpp>
#include <boost/mpl/joint_view.hpp>
#include <boost/mpl/aux_/test.hpp>
@@ -33,3 +41,33 @@ MPL_TEST_CASE()
typedef insert_range< list0<>,end< list0<> >::type,list1<int> >::type result2;
MPL_ASSERT_RELATION( size<result2>::value, ==, 1 );
}
template<typename A, typename B>
void test_associative()
{
typedef typename insert_range< A,typename end< A >::type,B >::type C;
MPL_ASSERT_RELATION( size<C>::value, <=, (size<A>::value + size<B>::value) );
MPL_ASSERT(( fold< joint_view< A,B >,true_,and_< _1,contains< C,_2 > > > ));
}
MPL_TEST_CASE()
{
typedef set3< short,int,long > signed_integers;
typedef set3< unsigned short,unsigned int,unsigned long > unsigned_integers;
test_associative<signed_integers, unsigned_integers>();
typedef set_c< int,1,3,5,7,9 > odds;
typedef set_c< int,0,2,4,6,8 > evens;
test_associative<odds, evens>();
typedef map2<
pair< void,void* >
, pair< int,int* >
> pointers;
typedef map2<
pair< void const,void const* >
, pair< int const,int const* >
> pointers_to_const;
test_associative<pointers, pointers_to_const>();
}