/* Copyright 2016 Joaquin M Lopez Munoz. * Distributed under 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) * * See http://www.boost.org/libs/poly_collection for library home page. */ #include "test_emplacement.hpp" #include #include "any_types.hpp" #include "base_types.hpp" #include "function_types.hpp" #include "test_utilities.hpp" using namespace test_utilities; template void test_emplacement() { { using type=first_of< constraints< is_constructible_from_int,is_not_copy_constructible, is_not_copy_assignable, is_equality_comparable >, Types... >; using iterator=typename PolyCollection::iterator; using local_base_iterator=typename PolyCollection::local_base_iterator; using local_iterator= typename PolyCollection::template local_iterator; PolyCollection p; iterator it=p.template emplace(4); BOOST_TEST(*p.template begin()==type{4}); BOOST_TEST(&*it==&*p.begin(typeid(type))); iterator it2=p.template emplace_hint(it,3); BOOST_TEST(*p.template begin()==type{3}); BOOST_TEST(&*it2==&*p.begin(typeid(type))); iterator it3=p.template emplace_hint(p.cend(),5); BOOST_TEST(*(p.template end()-1)==type{5}); BOOST_TEST(&*it3==&*(p.end(typeid(type))-1)); local_base_iterator lbit= p.template emplace_pos(p.begin(typeid(type)),2); BOOST_TEST(*static_cast(lbit)==type{2}); BOOST_TEST(lbit==p.begin(typeid(type))); local_base_iterator lbit2= p.template emplace_pos(p.cend(typeid(type)),6); BOOST_TEST(*static_cast(lbit2)==type{6}); BOOST_TEST(lbit2==p.end(typeid(type))-1); local_iterator lit=p.emplace_pos(p.template begin(),1); BOOST_TEST(*lit==type{1}); BOOST_TEST(lit==p.template begin()); local_iterator lit2=p.emplace_pos(p.template cend(),7); BOOST_TEST(*lit2==type{7}); BOOST_TEST(lit2==p.template end()-1); } { using type=first_of< constraints, Types... >; PolyCollection p; p.template emplace(); p.template emplace_hint(p.begin()); p.template emplace_hint(p.cend()); p.template emplace_pos(p.begin(typeid(type))); p.template emplace_pos(p.cend(typeid(type))); p.emplace_pos(p.template begin()); p.emplace_pos(p.template cend()); BOOST_TEST(p.size()==7); } { using type=first_of< constraints, Types... >; PolyCollection p; ValueFactory v; p.template emplace(v.template make()); p.template emplace_hint(p.begin(),v.template make()); p.template emplace_hint(p.cend(),v.template make()); p.template emplace_pos( p.begin(typeid(type)),v.template make()); p.template emplace_pos( p.cend(typeid(type)),v.template make()); p.emplace_pos(p.template begin(),v.template make()); p.emplace_pos(p.template cend(),v.template make()); BOOST_TEST(p.size()==7); } } void test_emplacement() { test_emplacement< any_types::collection,auto_increment, any_types::t1,any_types::t2,any_types::t3, any_types::t4,any_types::t5>(); test_emplacement< base_types::collection,auto_increment, base_types::t1,base_types::t2,base_types::t3, base_types::t4,base_types::t5>(); test_emplacement< function_types::collection,auto_increment, function_types::t1,function_types::t2,function_types::t3, function_types::t4,function_types::t5>(); }