diff --git a/test/deque_test.cpp b/test/deque_test.cpp index b226f8f..86173db 100644 --- a/test/deque_test.cpp +++ b/test/deque_test.cpp @@ -35,20 +35,6 @@ using namespace boost::container; -namespace boost { -namespace container { - -//Explicit instantiation to detect compilation errors -template class boost::container::deque - < test::movable_and_copyable_int - , test::simple_allocator >; - -template class boost::container::deque - < test::movable_and_copyable_int - , allocator >; - -}} - //Function to check if both sets are equal template bool deque_copyable_only(V1 &, V2 &, dtl::false_type) diff --git a/test/explicit_inst_deque_test.cpp b/test/explicit_inst_deque_test.cpp index 77163db..6fec811 100644 --- a/test/explicit_inst_deque_test.cpp +++ b/test/explicit_inst_deque_test.cpp @@ -9,6 +9,10 @@ ////////////////////////////////////////////////////////////////////////////// #include +#include +#include "movable_int.hpp" +#include "dummy_test_allocator.hpp" + struct empty { @@ -18,9 +22,25 @@ struct empty template class ::boost::container::deque; +volatile ::boost::container::deque dummy; + +namespace boost { +namespace container { + +//Explicit instantiation to detect compilation errors +template class boost::container::deque + < test::movable_and_copyable_int + , test::simple_allocator >; + +template class boost::container::deque + < test::movable_and_copyable_int + , allocator >; + +} //namespace boost { +} //namespace container { + int main() { - ::boost::container::deque dummy; - (void)dummy; return 0; } + diff --git a/test/explicit_inst_flat_map_test.cpp b/test/explicit_inst_flat_map_test.cpp index 77925d8..3a8ff6f 100644 --- a/test/explicit_inst_flat_map_test.cpp +++ b/test/explicit_inst_flat_map_test.cpp @@ -9,6 +9,13 @@ ////////////////////////////////////////////////////////////////////////////// #include +#include +#include "movable_int.hpp" +#include "dummy_test_allocator.hpp" +#include +#include +#include +#include struct empty { @@ -19,10 +26,69 @@ struct empty template class ::boost::container::flat_map; template class ::boost::container::flat_multimap; +volatile ::boost::container::flat_map dummy; +volatile ::boost::container::flat_multimap dummy2; + +namespace boost { +namespace container { + +//Explicit instantiation to detect compilation errors + +//flat_map +typedef std::pair test_pair_t; + +template class flat_map + < test::movable_and_copyable_int + , test::movable_and_copyable_int + , std::less + , small_vector< test_pair_t, 10, std::allocator< test_pair_t > > + >; + +//flat_multimap +template class flat_multimap + < test::movable_and_copyable_int + , test::movable_and_copyable_int + , std::less + , stable_vector< test_pair_t, allocator< test_pair_t > > + >; + +template class flat_multimap + < test::movable_and_copyable_int + , test::movable_and_copyable_int + , std::less + , deque > + >; + +template class flat_multimap + < test::movable_and_copyable_int + , test::movable_and_copyable_int + , std::less + , static_vector + >; + +//As flat container iterators are typedefs for vector::[const_]iterator, +//no need to explicit instantiate them + +}} //boost::container + +#if (__cplusplus > 201103L) +#include + +namespace boost{ +namespace container{ + +template class flat_map + < test::movable_and_copyable_int + , test::movable_and_copyable_int + , std::less + , std::vector +>; + +}} //boost::container + +#endif + int main() { - ::boost::container::flat_map dummy; - ::boost::container::flat_multimap dummy2; - (void)dummy; (void)dummy2; return 0; } diff --git a/test/explicit_inst_flat_set_test.cpp b/test/explicit_inst_flat_set_test.cpp index a9c482f..eeb8366 100644 --- a/test/explicit_inst_flat_set_test.cpp +++ b/test/explicit_inst_flat_set_test.cpp @@ -19,10 +19,70 @@ struct empty template class ::boost::container::flat_set; template class ::boost::container::flat_multiset; +volatile ::boost::container::flat_set dummy; +volatile ::boost::container::flat_multiset dummy2; + +#include +#include "movable_int.hpp" +#include "dummy_test_allocator.hpp" +#include +#include +#include +#include + +namespace boost { +namespace container { + +//Explicit instantiation to detect compilation errors + +//flat_set +template class flat_set + < test::movable_and_copyable_int + , std::less + , small_vector > + >; + +//flat_multiset +template class flat_multiset + < test::movable_and_copyable_int + , std::less + , stable_vector > + >; + +template class flat_multiset + < test::movable_and_copyable_int + , std::less + , deque > + >; + +template class flat_multiset + < test::movable_and_copyable_int + , std::less + , static_vector + >; + +//As flat container iterators are typedefs for vector::[const_]iterator, +//no need to explicit instantiate them + +}} //boost::container + +#if (__cplusplus > 201103L) +#include + +namespace boost{ +namespace container{ + +template class flat_set + < test::movable_and_copyable_int + , std::less + , std::vector +>; + +}} //boost::container + +#endif + int main() { - ::boost::container::flat_set dummy; - ::boost::container::flat_multiset dummy2; - (void)dummy; (void)dummy2; return 0; } diff --git a/test/explicit_inst_list_test.cpp b/test/explicit_inst_list_test.cpp index b038594..4faeaeb 100644 --- a/test/explicit_inst_list_test.cpp +++ b/test/explicit_inst_list_test.cpp @@ -21,6 +21,5 @@ template class ::boost::container::list; int main() { ::boost::container::list dummy; - (void)dummy; return 0; } diff --git a/test/explicit_inst_map_test.cpp b/test/explicit_inst_map_test.cpp index 4a19429..5a4a2b4 100644 --- a/test/explicit_inst_map_test.cpp +++ b/test/explicit_inst_map_test.cpp @@ -19,10 +19,38 @@ struct empty template class ::boost::container::map; template class ::boost::container::multimap; +volatile ::boost::container::map dummy; +volatile ::boost::container::multimap dummy2; + +#include +#include +#include "movable_int.hpp" +#include "dummy_test_allocator.hpp" + +namespace boost { +namespace container { + +typedef std::pair pair_t; + +//Explicit instantiation to detect compilation errors + +//map +template class map + < test::movable_and_copyable_int + , test::movable_and_copyable_int + , std::less + , test::simple_allocator< pair_t > + >; + +template class map + < test::movable_and_copyable_int + , test::movable_and_copyable_int + , std::less + , adaptive_pool< pair_t > + >; +}} //boost::container + int main() { - ::boost::container::map dummy; - ::boost::container::multimap dummy2; - (void)dummy; (void)dummy2; return 0; } diff --git a/test/explicit_inst_set_test.cpp b/test/explicit_inst_set_test.cpp index 7116c96..fa03123 100644 --- a/test/explicit_inst_set_test.cpp +++ b/test/explicit_inst_set_test.cpp @@ -19,10 +19,36 @@ struct empty template class ::boost::container::set; template class ::boost::container::multiset; +volatile ::boost::container::set dummy; +volatile ::boost::container::multiset dummy2; + +#include +#include +#include "movable_int.hpp" +#include "dummy_test_allocator.hpp" + +namespace boost { +namespace container { + +//Explicit instantiation to detect compilation errors + +//set +template class set + < test::movable_and_copyable_int + , std::less + , test::simple_allocator + >; + +//multiset +template class multiset + < test::movable_and_copyable_int + , std::less + , adaptive_pool + >; + +}} //boost::container + int main() { - ::boost::container::set dummy; - ::boost::container::multiset dummy2; - (void)dummy; (void)dummy2; return 0; } diff --git a/test/explicit_inst_slist_test.cpp b/test/explicit_inst_slist_test.cpp index ed4b5ae..f825c10 100644 --- a/test/explicit_inst_slist_test.cpp +++ b/test/explicit_inst_slist_test.cpp @@ -17,10 +17,28 @@ struct empty }; template class ::boost::container::slist; +volatile ::boost::container::slist dummy; + +#include +#include +#include "movable_int.hpp" +#include "dummy_test_allocator.hpp" + +namespace boost { +namespace container { + +//Explicit instantiation to detect compilation errors +template class boost::container::slist + < test::movable_and_copyable_int + , test::simple_allocator >; + +template class boost::container::slist + < test::movable_and_copyable_int + , node_allocator >; + +}} int main() { - ::boost::container::slist dummy; - (void)dummy; return 0; } diff --git a/test/explicit_inst_small_vector_test.cpp b/test/explicit_inst_small_vector_test.cpp index 65d9815..6259aae 100644 --- a/test/explicit_inst_small_vector_test.cpp +++ b/test/explicit_inst_small_vector_test.cpp @@ -17,10 +17,40 @@ struct empty }; template class ::boost::container::small_vector; +volatile ::boost::container::small_vector dummy; + +#include +#include "movable_int.hpp" +#include "dummy_test_allocator.hpp" + +namespace boost { +namespace container { + +template class small_vector; +template class small_vector; +template class small_vector; +template class small_vector; + +template class small_vector; +template class small_vector; +template class small_vector; +template class small_vector; + +//Explicit instantiation to detect compilation errors +template class boost::container::small_vector + < test::movable_and_copyable_int + , 10 + , test::simple_allocator >; + +template class boost::container::small_vector + < test::movable_and_copyable_int + , 10 + , allocator >; + +}} + int main() { - ::boost::container::small_vector dummy; - (void)dummy; return 0; } diff --git a/test/explicit_inst_stable_vector_test.cpp b/test/explicit_inst_stable_vector_test.cpp index cdd3bdd..b11b4c6 100644 --- a/test/explicit_inst_stable_vector_test.cpp +++ b/test/explicit_inst_stable_vector_test.cpp @@ -17,10 +17,29 @@ struct empty }; template class ::boost::container::stable_vector; +volatile ::boost::container::stable_vector dummy; + +#include +#include "movable_int.hpp" +#include "dummy_test_allocator.hpp" + +namespace boost { +namespace container { + +//Explicit instantiation to detect compilation errors +template class stable_vector >; + +template class stable_vector + < test::movable_and_copyable_int + , node_allocator >; + +template class stable_vector_iterator; +template class stable_vector_iterator; + +}} int main() { - ::boost::container::stable_vector dummy; - (void)dummy; return 0; } diff --git a/test/explicit_inst_static_vector_test.cpp b/test/explicit_inst_static_vector_test.cpp index 6681f7c..081775d 100644 --- a/test/explicit_inst_static_vector_test.cpp +++ b/test/explicit_inst_static_vector_test.cpp @@ -17,10 +17,17 @@ struct empty }; template class ::boost::container::static_vector; +volatile ::boost::container::static_vector dummy; + +namespace boost { +namespace container { + +//Explicit instantiation to detect compilation errors +template class boost::container::static_vector; + +}} int main() { - ::boost::container::static_vector dummy; - (void)dummy; return 0; } diff --git a/test/map_test.hpp b/test/map_test.hpp index 2ac3efd..3d26e3a 100644 --- a/test/map_test.hpp +++ b/test/map_test.hpp @@ -31,6 +31,8 @@ BOOST_INTRUSIVE_HAS_MEMBER_FUNC_CALLED(has_member_rebalance, rebalance) }}} +const int MaxElem = 50; + template bool operator ==(std::pair &p1, std::pair &p2) { @@ -68,8 +70,6 @@ int map_test_copyable(boost::container::dtl::true_type) typedef dtl::pair IntPairType; typedef typename MyStdMap::value_type StdPairType; - const int MaxElem = 50; - ::boost::movelib::unique_ptr const pboostmap = ::boost::movelib::make_unique(); ::boost::movelib::unique_ptr const pstdmap = ::boost::movelib::make_unique(); ::boost::movelib::unique_ptr const pboostmultimap = ::boost::movelib::make_unique(); @@ -133,17 +133,14 @@ template -int map_test() +int map_test_range() { typedef typename MyBoostMap::key_type IntType; typedef dtl::pair IntPairType; - typedef typename MyStdMap::value_type StdPairType; - const int MaxElem = 50; typedef typename MyStdMap::value_type StdValueType; typedef typename MyStdMap::key_type StdKeyType; typedef typename MyStdMap::mapped_type StdMappedType; - //Test construction from a range { IntPairType aux_vect[MaxElem]; @@ -213,15 +210,18 @@ int map_test() (&aux_vect2[0], &aux_vect2[0] + MaxElem, typename MyStdMap::key_compare()); if(!CheckEqualContainers(*pboostmultimap, *pstdmultimap)) return 1; } + return 0; +} - ::boost::movelib::unique_ptr const pboostmap = ::boost::movelib::make_unique(); - ::boost::movelib::unique_ptr const pstdmap = ::boost::movelib::make_unique(); - ::boost::movelib::unique_ptr const pboostmultimap = ::boost::movelib::make_unique(); - ::boost::movelib::unique_ptr const pstdmultimap = ::boost::movelib::make_unique(); - MyBoostMap &boostmap = *pboostmap; - MyStdMap &stdmap = *pstdmap; - MyBoostMultiMap &boostmultimap = *pboostmultimap; - MyStdMultiMap &stdmultimap = *pstdmultimap; + +template +int map_test_step(MyBoostMap &, MyStdMap &, MyBoostMultiMap &, MyStdMultiMap &) +{ + typedef typename MyBoostMap::key_type IntType; + typedef dtl::pair IntPairType; { //This is really nasty, but we have no other simple choice @@ -265,6 +265,8 @@ int map_test() if(!CheckEqualContainers(boostmap2, stdmap2)) return 1; if(!CheckEqualContainers(boostmultimap2, stdmultimap2)) return 1; + + //ordered range insertion //This is really nasty, but we have no other simple choice for(int i = 0; i < MaxElem; ++i){ @@ -342,6 +344,19 @@ int map_test() stdmap2[0] = 1; if(!CheckEqualContainers(boostmap2, stdmap2)) return 1; } + return 0; +} + +template +int map_test_insert(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &boostmultimap, MyStdMultiMap &stdmultimap) +{ + typedef typename MyBoostMap::key_type IntType; + typedef dtl::pair IntPairType; + typedef typename MyStdMap::value_type StdPairType; + { //This is really nasty, but we have no other simple choice IntPairType aux_vect[MaxElem]; @@ -401,6 +416,19 @@ int map_test() if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; } + return 0; +} + +template +int map_test_erase(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &boostmultimap, MyStdMultiMap &stdmultimap) +{ + typedef typename MyBoostMap::key_type IntType; + typedef dtl::pair IntPairType; + typedef typename MyStdMap::value_type StdPairType; + //Insertion from other container //Initialize values { @@ -489,165 +517,189 @@ int map_test() if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; } + return 0; +} + +template +int map_test_insert2(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &boostmultimap, MyStdMultiMap &stdmultimap) +{ + typedef typename MyBoostMap::key_type IntType; + typedef dtl::pair IntPairType; + typedef typename MyStdMap::value_type StdPairType; + + //This is really nasty, but we have no other simple choice + IntPairType aux_vect[MaxElem]; + for(int i = 0; i < MaxElem; ++i){ + IntType i1(i); + IntType i2(i); + new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2)); + } + IntPairType aux_vect3[MaxElem]; + for(int i = 0; i < MaxElem; ++i){ + IntType i1(i); + IntType i2(i); + new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2)); + } + + for(int i = 0; i < MaxElem; ++i){ + boostmap.insert(boost::move(aux_vect[i])); + stdmap.insert(StdPairType(i, i)); + boostmultimap.insert(boost::move(aux_vect3[i])); + stdmultimap.insert(StdPairType(i, i)); + } + + if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; + if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; + + for(int i = 0; i < MaxElem; ++i){ + IntPairType intpair; + { + IntType i1(i); + IntType i2(i); + new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); + } + boostmap.insert(boostmap.begin(), boost::move(intpair)); + stdmap.insert(stdmap.begin(), StdPairType(i, i)); + //PrintContainers(boostmap, stdmap); + { + IntType i1(i); + IntType i2(i); + new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); + } + boostmultimap.insert(boostmultimap.begin(), boost::move(intpair)); + stdmultimap.insert(stdmultimap.begin(), StdPairType(i, i)); + //PrintContainers(boostmultimap, stdmultimap); + if(!CheckEqualPairContainers(boostmap, stdmap)) + return 1; + if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) + return 1; + { + IntType i1(i); + IntType i2(i); + new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); + } + boostmap.insert(boostmap.end(), boost::move(intpair)); + stdmap.insert(stdmap.end(), StdPairType(i, i)); + { + IntType i1(i); + IntType i2(i); + new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); + } + boostmultimap.insert(boostmultimap.end(), boost::move(intpair)); + stdmultimap.insert(stdmultimap.end(), StdPairType(i, i)); + if(!CheckEqualPairContainers(boostmap, stdmap)) + return 1; + if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) + return 1; + { + IntType i1(i); + IntType i2(i); + new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); + } + IntType k(i); + boostmap.insert(boostmap.lower_bound(k), boost::move(intpair)); + stdmap.insert(stdmap.lower_bound(i), StdPairType(i, i)); + //PrintContainers(boostmap, stdmap); + { + IntType i1(i); + IntType i2(i); + new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); + } + { + IntType i1(i); + boostmultimap.insert(boostmultimap.lower_bound(boost::move(i1)), boost::move(intpair)); + stdmultimap.insert(stdmultimap.lower_bound(i), StdPairType(i, i)); + } + + //PrintContainers(boostmultimap, stdmultimap); + if(!CheckEqualPairContainers(boostmap, stdmap)) + return 1; + if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) + return 1; + { //Check equal_range + std::pair bret = + boostmultimap.equal_range(boostmultimap.begin()->first); + + std::pair sret = + stdmultimap.equal_range(stdmultimap.begin()->first); + + if( boost::container::iterator_distance(bret.first, bret.second) != + boost::container::iterator_distance(sret.first, sret.second) ){ + return 1; + } + } + { + IntType i1(i); + boostmap.insert(boostmap.upper_bound(boost::move(i1)), boost::move(intpair)); + stdmap.insert(stdmap.upper_bound(i), StdPairType(i, i)); + } + //PrintContainers(boostmap, stdmap); + { + IntType i1(i); + IntType i2(i); + new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); + } + { + IntType i1(i); + boostmultimap.insert(boostmultimap.upper_bound(boost::move(i1)), boost::move(intpair)); + stdmultimap.insert(stdmultimap.upper_bound(i), StdPairType(i, i)); + } + //PrintContainers(boostmultimap, stdmultimap); + if(!CheckEqualPairContainers(boostmap, stdmap)) + return 1; + if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) + return 1; + + map_test_rebalanceable(boostmap + , dtl::bool_::value>()); + if(!CheckEqualContainers(boostmap, stdmap)){ + std::cout << "Error in boostmap.rebalance()" << std::endl; + return 1; + } + map_test_rebalanceable(boostmultimap + , dtl::bool_::value>()); + if(!CheckEqualContainers(boostmultimap, stdmultimap)){ + std::cout << "Error in boostmultimap.rebalance()" << std::endl; + return 1; + } + } + return 0; +} + + +template +int map_test_search(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &boostmultimap, MyStdMultiMap &stdmultimap) +{ + typedef typename MyBoostMap::key_type IntType; + typedef dtl::pair IntPairType; + + //Compare count/contains with std containers + for(int i = 0; i < MaxElem; ++i){ + IntType k(i); + if(boostmap.count(k) != stdmap.count(i)){ + return -1; + } + + if(boostmap.contains(k) != (stdmap.find(i) != stdmap.end())){ + return -1; + } + + if(boostmultimap.count(k) != stdmultimap.count(i)){ + return -1; + } + + if(boostmultimap.contains(k) != (stdmultimap.find(i) != stdmultimap.end())){ + return -1; + } + } { - //This is really nasty, but we have no other simple choice - IntPairType aux_vect[MaxElem]; - for(int i = 0; i < MaxElem; ++i){ - IntType i1(i); - IntType i2(i); - new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2)); - } - IntPairType aux_vect3[MaxElem]; - for(int i = 0; i < MaxElem; ++i){ - IntType i1(i); - IntType i2(i); - new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2)); - } - - for(int i = 0; i < MaxElem; ++i){ - boostmap.insert(boost::move(aux_vect[i])); - stdmap.insert(StdPairType(i, i)); - boostmultimap.insert(boost::move(aux_vect3[i])); - stdmultimap.insert(StdPairType(i, i)); - } - - if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; - if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; - - for(int i = 0; i < MaxElem; ++i){ - IntPairType intpair; - { - IntType i1(i); - IntType i2(i); - new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); - } - boostmap.insert(boostmap.begin(), boost::move(intpair)); - stdmap.insert(stdmap.begin(), StdPairType(i, i)); - //PrintContainers(boostmap, stdmap); - { - IntType i1(i); - IntType i2(i); - new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); - } - boostmultimap.insert(boostmultimap.begin(), boost::move(intpair)); - stdmultimap.insert(stdmultimap.begin(), StdPairType(i, i)); - //PrintContainers(boostmultimap, stdmultimap); - if(!CheckEqualPairContainers(boostmap, stdmap)) - return 1; - if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) - return 1; - { - IntType i1(i); - IntType i2(i); - new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); - } - boostmap.insert(boostmap.end(), boost::move(intpair)); - stdmap.insert(stdmap.end(), StdPairType(i, i)); - { - IntType i1(i); - IntType i2(i); - new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); - } - boostmultimap.insert(boostmultimap.end(), boost::move(intpair)); - stdmultimap.insert(stdmultimap.end(), StdPairType(i, i)); - if(!CheckEqualPairContainers(boostmap, stdmap)) - return 1; - if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) - return 1; - { - IntType i1(i); - IntType i2(i); - new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); - } - IntType k(i); - boostmap.insert(boostmap.lower_bound(k), boost::move(intpair)); - stdmap.insert(stdmap.lower_bound(i), StdPairType(i, i)); - //PrintContainers(boostmap, stdmap); - { - IntType i1(i); - IntType i2(i); - new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); - } - { - IntType i1(i); - boostmultimap.insert(boostmultimap.lower_bound(boost::move(i1)), boost::move(intpair)); - stdmultimap.insert(stdmultimap.lower_bound(i), StdPairType(i, i)); - } - - //PrintContainers(boostmultimap, stdmultimap); - if(!CheckEqualPairContainers(boostmap, stdmap)) - return 1; - if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) - return 1; - { //Check equal_range - std::pair bret = - boostmultimap.equal_range(boostmultimap.begin()->first); - - std::pair sret = - stdmultimap.equal_range(stdmultimap.begin()->first); - - if( boost::container::iterator_distance(bret.first, bret.second) != - boost::container::iterator_distance(sret.first, sret.second) ){ - return 1; - } - } - { - IntType i1(i); - boostmap.insert(boostmap.upper_bound(boost::move(i1)), boost::move(intpair)); - stdmap.insert(stdmap.upper_bound(i), StdPairType(i, i)); - } - //PrintContainers(boostmap, stdmap); - { - IntType i1(i); - IntType i2(i); - new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); - } - { - IntType i1(i); - boostmultimap.insert(boostmultimap.upper_bound(boost::move(i1)), boost::move(intpair)); - stdmultimap.insert(stdmultimap.upper_bound(i), StdPairType(i, i)); - } - //PrintContainers(boostmultimap, stdmultimap); - if(!CheckEqualPairContainers(boostmap, stdmap)) - return 1; - if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) - return 1; - - map_test_rebalanceable(boostmap - , dtl::bool_::value>()); - if(!CheckEqualContainers(boostmap, stdmap)){ - std::cout << "Error in boostmap.rebalance()" << std::endl; - return 1; - } - map_test_rebalanceable(boostmultimap - , dtl::bool_::value>()); - if(!CheckEqualContainers(boostmultimap, stdmultimap)){ - std::cout << "Error in boostmultimap.rebalance()" << std::endl; - return 1; - } - } - - //Compare count/contains with std containers - for(int i = 0; i < MaxElem; ++i){ - IntType k(i); - if(boostmap.count(k) != stdmap.count(i)){ - return -1; - } - - if(boostmap.contains(k) != (stdmap.find(i) != stdmap.end())){ - return -1; - } - - if(boostmultimap.count(k) != stdmultimap.count(i)){ - return -1; - } - - if(boostmultimap.contains(k) != (stdmultimap.find(i) != stdmultimap.end())){ - return -1; - } - } - //Now do count exercise boostmap.erase(boostmap.begin(), boostmap.end()); boostmultimap.erase(boostmultimap.begin(), boostmultimap.end()); @@ -675,6 +727,18 @@ int map_test() } } + return 0; +} + +template +int map_test_indexing(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &boostmultimap, MyStdMultiMap &stdmultimap) +{ + typedef typename MyBoostMap::key_type IntType; + typedef dtl::pair IntPairType; + { //operator[] test boostmap.clear(); boostmultimap.clear(); @@ -696,6 +760,19 @@ int map_test() if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; } + return 0; +} + + + +template +int map_test_insert_or_assign(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &boostmultimap, MyStdMultiMap &stdmultimap) +{ + typedef typename MyBoostMap::key_type IntType; + typedef dtl::pair IntPairType; { //insert_or_assign test boostmap.clear(); @@ -733,8 +810,19 @@ int map_test() if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; } + return 0; +} - { //try_emplace +template< class MyBoostMap + , class MyStdMap + , class MyBoostMultiMap + , class MyStdMultiMap> +int map_test_try_emplace(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &boostmultimap, MyStdMultiMap &stdmultimap) +{ + typedef typename MyBoostMap::key_type IntType; + typedef dtl::pair IntPairType; + + { //try_emplace boostmap.clear(); boostmultimap.clear(); stdmap.clear(); @@ -802,7 +890,20 @@ int map_test() if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; } + return 0; +} + +template< class MyBoostMap + , class MyStdMap + , class MyBoostMultiMap + , class MyStdMultiMap> +int map_test_merge(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &boostmultimap, MyStdMultiMap &stdmultimap) +{ + typedef typename MyBoostMap::key_type IntType; + typedef dtl::pair IntPairType; + typedef typename MyStdMap::value_type StdPairType; + { //merge ::boost::movelib::unique_ptr const pboostmap2 = ::boost::movelib::make_unique(); ::boost::movelib::unique_ptr const pboostmultimap2 = ::boost::movelib::make_unique(); @@ -904,6 +1005,56 @@ int map_test() boostmultimap.merge(boostmap2); if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; } + return 0; +} + + +template +int map_test() +{ + typedef typename MyBoostMap::key_type IntType; + + if(map_test_range()) + return 1; + + ::boost::movelib::unique_ptr const pboostmap = ::boost::movelib::make_unique(); + ::boost::movelib::unique_ptr const pstdmap = ::boost::movelib::make_unique(); + ::boost::movelib::unique_ptr const pboostmultimap = ::boost::movelib::make_unique(); + ::boost::movelib::unique_ptr const pstdmultimap = ::boost::movelib::make_unique(); + MyBoostMap &boostmap = *pboostmap; + MyStdMap &stdmap = *pstdmap; + MyBoostMultiMap &boostmultimap = *pboostmultimap; + MyStdMultiMap &stdmultimap = *pstdmultimap; + + if (map_test_step(boostmap, stdmap, boostmultimap, stdmultimap)) + return 1; + + if (map_test_insert(boostmap, stdmap, boostmultimap, stdmultimap)) + return 1; + + if (map_test_erase(boostmap, stdmap, boostmultimap, stdmultimap)) + return 1; + + if (map_test_insert2(boostmap, stdmap, boostmultimap, stdmultimap)) + return 1; + + if (map_test_search(boostmap, stdmap, boostmultimap, stdmultimap)) + return 1; + + if (map_test_indexing(boostmap, stdmap, boostmultimap, stdmultimap)) + return 1; + + if (map_test_insert_or_assign(boostmap, stdmap, boostmultimap, stdmultimap)) + return 1; + + if (map_test_try_emplace(boostmap, stdmap, boostmultimap, stdmultimap)) + return 1; + + if (map_test_merge(boostmap, stdmap, boostmultimap, stdmultimap)) + return 1; if(map_test_copyable (dtl::bool_::value>())){