Updated tests to avoid manual memory management. Replaced with unique_ptr and a reference. Normalized CheckEqualContainers to use references instead of pointers.

This commit is contained in:
Ion Gaztañaga
2014-09-23 17:30:31 +02:00
parent 4d5b9a80cf
commit e697122a2c
11 changed files with 1233 additions and 1381 deletions

View File

@@ -17,6 +17,7 @@
#include <functional> #include <functional>
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
#include <boost/move/unique_ptr.hpp>
namespace boost{ namespace boost{
namespace container { namespace container {
@@ -60,15 +61,15 @@ bool CheckEqual( const Pair1 &pair1, const Pair2 &pair2
//Function to check if both containers are equal //Function to check if both containers are equal
template<class MyBoostCont template<class MyBoostCont
,class MyStdCont> ,class MyStdCont>
bool CheckEqualContainers(const MyBoostCont *boostcont, const MyStdCont *stdcont) bool CheckEqualContainers(const MyBoostCont &boostcont, const MyStdCont &stdcont)
{ {
if(boostcont->size() != stdcont->size()) if(boostcont.size() != stdcont.size())
return false; return false;
typename MyBoostCont::const_iterator itboost(boostcont->begin()), itboostend(boostcont->end()); typename MyBoostCont::const_iterator itboost(boostcont.begin()), itboostend(boostcont.end());
typename MyStdCont::const_iterator itstd(stdcont->begin()); typename MyStdCont::const_iterator itstd(stdcont.begin());
typename MyStdCont::size_type dist = (typename MyStdCont::size_type)std::distance(itboost, itboostend); typename MyStdCont::size_type dist = (typename MyStdCont::size_type)std::distance(itboost, itboostend);
if(dist != boostcont->size()){ if(dist != boostcont.size()){
return false; return false;
} }
std::size_t i = 0; std::size_t i = 0;
@@ -81,16 +82,16 @@ bool CheckEqualContainers(const MyBoostCont *boostcont, const MyStdCont *stdcont
template<class MyBoostCont template<class MyBoostCont
,class MyStdCont> ,class MyStdCont>
bool CheckEqualPairContainers(const MyBoostCont *boostcont, const MyStdCont *stdcont) bool CheckEqualPairContainers(const MyBoostCont &boostcont, const MyStdCont &stdcont)
{ {
if(boostcont->size() != stdcont->size()) if(boostcont.size() != stdcont.size())
return false; return false;
typedef typename MyBoostCont::key_type key_type; typedef typename MyBoostCont::key_type key_type;
typedef typename MyBoostCont::mapped_type mapped_type; typedef typename MyBoostCont::mapped_type mapped_type;
typename MyBoostCont::const_iterator itboost(boostcont->begin()), itboostend(boostcont->end()); typename MyBoostCont::const_iterator itboost(boostcont.begin()), itboostend(boostcont.end());
typename MyStdCont::const_iterator itstd(stdcont->begin()); typename MyStdCont::const_iterator itstd(stdcont.begin());
for(; itboost != itboostend; ++itboost, ++itstd){ for(; itboost != itboostend; ++itboost, ++itstd){
if(itboost->first != key_type(itstd->first)) if(itboost->first != key_type(itstd->first))
return false; return false;

View File

@@ -70,58 +70,58 @@ template class boost::container::deque
//Function to check if both sets are equal //Function to check if both sets are equal
template<class V1, class V2> template<class V1, class V2>
bool deque_copyable_only(V1 *, V2 *, container_detail::false_type) bool deque_copyable_only(V1 &, V2 &, container_detail::false_type)
{ {
return true; return true;
} }
//Function to check if both sets are equal //Function to check if both sets are equal
template<class V1, class V2> template<class V1, class V2>
bool deque_copyable_only(V1 *cntdeque, V2 *stddeque, container_detail::true_type) bool deque_copyable_only(V1 &cntdeque, V2 &stddeque, container_detail::true_type)
{ {
typedef typename V1::value_type IntType; typedef typename V1::value_type IntType;
std::size_t size = cntdeque->size(); std::size_t size = cntdeque.size();
stddeque->insert(stddeque->end(), 50, 1); stddeque.insert(stddeque.end(), 50, 1);
cntdeque->insert(cntdeque->end(), 50, IntType(1)); cntdeque.insert(cntdeque.end(), 50, IntType(1));
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
{ {
IntType move_me(1); IntType move_me(1);
stddeque->insert(stddeque->begin()+size/2, 50, 1); stddeque.insert(stddeque.begin()+size/2, 50, 1);
cntdeque->insert(cntdeque->begin()+size/2, 50, boost::move(move_me)); cntdeque.insert(cntdeque.begin()+size/2, 50, boost::move(move_me));
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
} }
{ {
IntType move_me(2); IntType move_me(2);
cntdeque->assign(cntdeque->size()/2, boost::move(move_me)); cntdeque.assign(cntdeque.size()/2, boost::move(move_me));
stddeque->assign(stddeque->size()/2, 2); stddeque.assign(stddeque.size()/2, 2);
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
} }
{ {
IntType move_me(1); IntType move_me(1);
stddeque->clear(); stddeque.clear();
cntdeque->clear(); cntdeque.clear();
stddeque->insert(stddeque->begin(), 50, 1); stddeque.insert(stddeque.begin(), 50, 1);
cntdeque->insert(cntdeque->begin(), 50, boost::move(move_me)); cntdeque.insert(cntdeque.begin(), 50, boost::move(move_me));
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
stddeque->insert(stddeque->begin()+20, 50, 1); stddeque.insert(stddeque.begin()+20, 50, 1);
cntdeque->insert(cntdeque->begin()+20, 50, boost::move(move_me)); cntdeque.insert(cntdeque.begin()+20, 50, boost::move(move_me));
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
stddeque->insert(stddeque->begin()+20, 20, 1); stddeque.insert(stddeque.begin()+20, 20, 1);
cntdeque->insert(cntdeque->begin()+20, 20, boost::move(move_me)); cntdeque.insert(cntdeque.begin()+20, 20, boost::move(move_me));
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
} }
{ {
IntType move_me(1); IntType move_me(1);
stddeque->clear(); stddeque.clear();
cntdeque->clear(); cntdeque.clear();
stddeque->insert(stddeque->end(), 50, 1); stddeque.insert(stddeque.end(), 50, 1);
cntdeque->insert(cntdeque->end(), 50, boost::move(move_me)); cntdeque.insert(cntdeque.end(), 50, boost::move(move_me));
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
stddeque->insert(stddeque->end()-20, 50, 1); stddeque.insert(stddeque.end()-20, 50, 1);
cntdeque->insert(cntdeque->end()-20, 50, boost::move(move_me)); cntdeque.insert(cntdeque.end()-20, 50, boost::move(move_me));
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
stddeque->insert(stddeque->end()-20, 20, 1); stddeque.insert(stddeque.end()-20, 20, 1);
cntdeque->insert(cntdeque->end()-20, 20, boost::move(move_me)); cntdeque.insert(cntdeque.end()-20, 20, boost::move(move_me));
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
} }
@@ -165,33 +165,35 @@ bool do_test()
typedef deque<IntType> MyCntDeque; typedef deque<IntType> MyCntDeque;
typedef std::deque<int> MyStdDeque; typedef std::deque<int> MyStdDeque;
const int max = 100; const int max = 100;
BOOST_TRY{ {
MyCntDeque *cntdeque = new MyCntDeque; ::boost::movelib::unique_ptr<MyCntDeque> const pcntdeque = ::boost::movelib::make_unique<MyCntDeque>();
MyStdDeque *stddeque = new MyStdDeque; ::boost::movelib::unique_ptr<MyStdDeque> const pstddeque = ::boost::movelib::make_unique<MyStdDeque>();
MyCntDeque &cntdeque = *pcntdeque;
MyStdDeque &stddeque = *pstddeque;
for(int i = 0; i < max*100; ++i){ for(int i = 0; i < max*100; ++i){
IntType move_me(i); IntType move_me(i);
cntdeque->insert(cntdeque->end(), boost::move(move_me)); cntdeque.insert(cntdeque.end(), boost::move(move_me));
stddeque->insert(stddeque->end(), i); stddeque.insert(stddeque.end(), i);
} }
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
cntdeque->clear(); cntdeque.clear();
stddeque->clear(); stddeque.clear();
for(int i = 0; i < max*100; ++i){ for(int i = 0; i < max*100; ++i){
IntType move_me(i); IntType move_me(i);
cntdeque->push_back(boost::move(move_me)); cntdeque.push_back(boost::move(move_me));
stddeque->push_back(i); stddeque.push_back(i);
} }
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
cntdeque->clear(); cntdeque.clear();
stddeque->clear(); stddeque.clear();
for(int i = 0; i < max*100; ++i){ for(int i = 0; i < max*100; ++i){
IntType move_me(i); IntType move_me(i);
cntdeque->push_front(boost::move(move_me)); cntdeque.push_front(boost::move(move_me));
stddeque->push_front(i); stddeque.push_front(i);
} }
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
@@ -199,12 +201,12 @@ bool do_test()
typename MyCntDeque::const_iterator cit = it; typename MyCntDeque::const_iterator cit = it;
(void)cit; (void)cit;
cntdeque->erase(cntdeque->begin()++); cntdeque.erase(cntdeque.begin()++);
stddeque->erase(stddeque->begin()++); stddeque.erase(stddeque.begin()++);
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
cntdeque->erase(cntdeque->begin()); cntdeque.erase(cntdeque.begin());
stddeque->erase(stddeque->begin()); stddeque.erase(stddeque.begin());
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
{ {
@@ -219,10 +221,10 @@ bool do_test()
aux_vect2[i] = -1; aux_vect2[i] = -1;
} }
cntdeque->insert(cntdeque->end() cntdeque.insert(cntdeque.end()
,boost::make_move_iterator(&aux_vect[0]) ,boost::make_move_iterator(&aux_vect[0])
,boost::make_move_iterator(aux_vect + 50)); ,boost::make_move_iterator(aux_vect + 50));
stddeque->insert(stddeque->end(), aux_vect2, aux_vect2 + 50); stddeque.insert(stddeque.end(), aux_vect2, aux_vect2 + 50);
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
for(int i = 0; i < 50; ++i){ for(int i = 0; i < 50; ++i){
@@ -233,15 +235,15 @@ bool do_test()
aux_vect2[i] = i; aux_vect2[i] = i;
} }
cntdeque->insert(cntdeque->begin()+cntdeque->size() cntdeque.insert(cntdeque.begin()+cntdeque.size()
,boost::make_move_iterator(&aux_vect[0]) ,boost::make_move_iterator(&aux_vect[0])
,boost::make_move_iterator(aux_vect + 50)); ,boost::make_move_iterator(aux_vect + 50));
stddeque->insert(stddeque->begin()+stddeque->size(), aux_vect2, aux_vect2 + 50); stddeque.insert(stddeque.begin()+stddeque.size(), aux_vect2, aux_vect2 + 50);
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
for(int i = 0, j = static_cast<int>(cntdeque->size()); i < j; ++i){ for(int i = 0, j = static_cast<int>(cntdeque.size()); i < j; ++i){
cntdeque->erase(cntdeque->begin()); cntdeque.erase(cntdeque.begin());
stddeque->erase(stddeque->begin()); stddeque.erase(stddeque.begin());
} }
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
} }
@@ -255,10 +257,10 @@ bool do_test()
for(int i = 0; i < 50; ++i){ for(int i = 0; i < 50; ++i){
aux_vect2[i] = -1; aux_vect2[i] = -1;
} }
cntdeque->insert(cntdeque->begin() cntdeque.insert(cntdeque.begin()
,boost::make_move_iterator(&aux_vect[0]) ,boost::make_move_iterator(&aux_vect[0])
,boost::make_move_iterator(aux_vect + 50)); ,boost::make_move_iterator(aux_vect + 50));
stddeque->insert(stddeque->begin(), aux_vect2, aux_vect2 + 50); stddeque.insert(stddeque.begin(), aux_vect2, aux_vect2 + 50);
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
} }
@@ -267,47 +269,37 @@ bool do_test()
return false; return false;
} }
cntdeque->erase(cntdeque->begin()); cntdeque.erase(cntdeque.begin());
stddeque->erase(stddeque->begin()); stddeque.erase(stddeque.begin());
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
for(int i = 0; i < max; ++i){ for(int i = 0; i < max; ++i){
IntType move_me(i); IntType move_me(i);
cntdeque->insert(cntdeque->begin(), boost::move(move_me)); cntdeque.insert(cntdeque.begin(), boost::move(move_me));
stddeque->insert(stddeque->begin(), i); stddeque.insert(stddeque.begin(), i);
} }
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
//Test insertion from list //Test insertion from list
{ {
std::list<int> l(50, int(1)); std::list<int> l(50, int(1));
cntdeque->insert(cntdeque->begin(), l.begin(), l.end()); cntdeque.insert(cntdeque.begin(), l.begin(), l.end());
stddeque->insert(stddeque->begin(), l.begin(), l.end()); stddeque.insert(stddeque.begin(), l.begin(), l.end());
if(!test::CheckEqualContainers(cntdeque, stddeque)) return 1; if(!test::CheckEqualContainers(cntdeque, stddeque)) return 1;
cntdeque->assign(l.begin(), l.end()); cntdeque.assign(l.begin(), l.end());
stddeque->assign(l.begin(), l.end()); stddeque.assign(l.begin(), l.end());
if(!test::CheckEqualContainers(cntdeque, stddeque)) return 1; if(!test::CheckEqualContainers(cntdeque, stddeque)) return 1;
} }
cntdeque->resize(100); cntdeque.resize(100);
stddeque->resize(100); stddeque.resize(100);
if(!test::CheckEqualContainers(cntdeque, stddeque)) return 1; if(!test::CheckEqualContainers(cntdeque, stddeque)) return 1;
cntdeque->resize(200); cntdeque.resize(200);
stddeque->resize(200); stddeque.resize(200);
if(!test::CheckEqualContainers(cntdeque, stddeque)) return 1; if(!test::CheckEqualContainers(cntdeque, stddeque)) return 1;
delete cntdeque;
delete stddeque;
} }
BOOST_CATCH(std::exception &ex){
#ifndef BOOST_NO_EXCEPTIONS
std::cout << ex.what() << std::endl;
#endif
return false;
}
BOOST_CATCH_END
std::cout << std::endl << "Test OK!" << std::endl; std::cout << std::endl << "Test OK!" << std::endl;
return true; return true;

View File

@@ -21,114 +21,6 @@
namespace boost { namespace container { namespace test { namespace boost { namespace container { namespace test {
template<class T>
struct value_holder
{
explicit value_holder(T val) : m_value(val)
{ ++count; }
value_holder(): m_value(0)
{ ++count; }
value_holder(const value_holder &other)
: m_value(other.m_value)
{ ++count; }
value_holder &operator=(const value_holder&other)
{ m_value = other.m_value; return *this; }
value_holder &operator=(T val)
{ m_value = val; return *this; }
~value_holder()
{ m_value = 0; --count; }
bool operator == (const value_holder &other) const
{ return m_value == other.m_value; }
bool operator != (const value_holder &other) const
{ return m_value != other.m_value; }
T m_value;
static unsigned count;
};
template<class T>
unsigned value_holder<T>::count = 0;
template<class T>
struct triple_value_holder
{
explicit triple_value_holder(T val)
: m_value1(val)
, m_value2(val)
, m_value3(val)
{ ++count; }
triple_value_holder()
: m_value1(0)
, m_value2(0)
, m_value3(0)
{ ++count; }
triple_value_holder(const triple_value_holder &other)
: m_value1(other.m_value1), m_value2(other.m_value2), m_value3(other.m_value3)
{ ++count; }
triple_value_holder &operator=(const triple_value_holder &other)
{ m_value1 = other.m_value1; m_value2 = other.m_value2; m_value3 = other.m_value3; ; return *this; }
triple_value_holder &operator=(T val)
{ m_value1 = val; m_value2 = val; m_value3 = val; ; return *this; }
~triple_value_holder()
{ m_value1 = m_value2 = m_value3 = 0; --count; }
bool operator == (const triple_value_holder &other) const
{
return m_value1 == other.m_value1
&& m_value2 == other.m_value2
&& m_value3 == other.m_value3;
}
bool operator != (const triple_value_holder &other) const
{
return m_value1 != other.m_value1
|| m_value2 != other.m_value2
|| m_value3 != other.m_value3;
}
T m_value1;
T m_value2;
T m_value3;
static unsigned count;
};
template<class T>
unsigned triple_value_holder<T>::count = 0;
typedef value_holder<int> int_holder;
typedef triple_value_holder<int> triple_int_holder;
template<class T>
struct life_count
{
static unsigned check(unsigned) { return true; }
};
template<class T>
struct life_count< triple_value_holder<T> >
{
static unsigned check(unsigned c)
{ return c == triple_value_holder<T>::count; }
};
template<class T>
struct life_count< value_holder<T> >
{
static unsigned check(unsigned c)
{ return c == value_holder<T>::count; }
};
//Function to check if both sets are equal //Function to check if both sets are equal
template <class Vector1, class Vector2> template <class Vector1, class Vector2>
bool CheckEqualVector(const Vector1 &vector1, const Vector2 &vector2) bool CheckEqualVector(const Vector1 &vector1, const Vector2 &vector2)
@@ -209,7 +101,7 @@ bool test_insert_with_expand_bwd()
return false; return false;
expand_bwd_test_allocator<value_type> alloc expand_bwd_test_allocator<value_type> alloc
(&memory[0], MemorySize, Offset[iteration]); (memory, MemorySize, Offset[iteration]);
VectorWithExpandBwdAllocator vector(alloc); VectorWithExpandBwdAllocator vector(alloc);
vector.insert( vector.begin() vector.insert( vector.begin()
, initial_data.begin(), initial_data.end()); , initial_data.begin(), initial_data.end());
@@ -250,8 +142,9 @@ bool test_assign_with_expand_bwd()
for(int iteration = 0; iteration <Iterations; ++iteration) for(int iteration = 0; iteration <Iterations; ++iteration)
{ {
value_type *memory = new value_type[MemorySize]; boost::movelib::unique_ptr<char[]> memptr =
BOOST_TRY { boost::movelib::make_unique_definit<char[]>(MemorySize*sizeof(value_type));
value_type *memory = (value_type*)memptr.get();
//Create initial data //Create initial data
std::vector<non_volatile_value_type> initial_data; std::vector<non_volatile_value_type> initial_data;
initial_data.resize(InitialSize[iteration]); initial_data.resize(InitialSize[iteration]);
@@ -268,7 +161,7 @@ bool test_assign_with_expand_bwd()
//Insert initial data to the vector to test //Insert initial data to the vector to test
expand_bwd_test_allocator<value_type> alloc expand_bwd_test_allocator<value_type> alloc
(&memory[0], MemorySize, Offset[iteration]); (memory, MemorySize, Offset[iteration]);
VectorWithExpandBwdAllocator vector(alloc); VectorWithExpandBwdAllocator vector(alloc);
vector.insert( vector.begin() vector.insert( vector.begin()
, initial_data.begin(), initial_data.end()); , initial_data.begin(), initial_data.end());
@@ -285,13 +178,6 @@ bool test_assign_with_expand_bwd()
return false; return false;
} }
} }
BOOST_CATCH(...){
delete [](const_cast<typename boost::remove_volatile<value_type>::type*>(memory));
BOOST_RETHROW;
}
BOOST_CATCH_END
delete [](const_cast<typename boost::remove_volatile<value_type>::type*>(memory));
}
return true; return true;
} }

View File

@@ -247,24 +247,24 @@ bool flat_tree_ordered_insertion_test()
} }
//Construction insertion //Construction insertion
flat_multimap<int, int> fmmap(ordered_range, int_mmap.begin(), int_mmap.end()); flat_multimap<int, int> fmmap(ordered_range, int_mmap.begin(), int_mmap.end());
if(!CheckEqualContainers(&int_mmap, &fmmap)) if(!CheckEqualContainers(int_mmap, fmmap))
return false; return false;
//Insertion when empty //Insertion when empty
fmmap.clear(); fmmap.clear();
fmmap.insert(ordered_range, int_mmap.begin(), int_mmap.end()); fmmap.insert(ordered_range, int_mmap.begin(), int_mmap.end());
if(!CheckEqualContainers(&int_mmap, &fmmap)) if(!CheckEqualContainers(int_mmap, fmmap))
return false; return false;
//Re-insertion //Re-insertion
fmmap.insert(ordered_range, int_mmap.begin(), int_mmap.end()); fmmap.insert(ordered_range, int_mmap.begin(), int_mmap.end());
std::multimap<int, int> int_mmap2(int_mmap); std::multimap<int, int> int_mmap2(int_mmap);
int_mmap2.insert(int_mmap.begin(), int_mmap.end()); int_mmap2.insert(int_mmap.begin(), int_mmap.end());
if(!CheckEqualContainers(&int_mmap2, &fmmap)) if(!CheckEqualContainers(int_mmap2, fmmap))
return false; return false;
//Re-re-insertion //Re-re-insertion
fmmap.insert(ordered_range, int_mmap2.begin(), int_mmap2.end()); fmmap.insert(ordered_range, int_mmap2.begin(), int_mmap2.end());
std::multimap<int, int> int_mmap4(int_mmap2); std::multimap<int, int> int_mmap4(int_mmap2);
int_mmap4.insert(int_mmap2.begin(), int_mmap2.end()); int_mmap4.insert(int_mmap2.begin(), int_mmap2.end());
if(!CheckEqualContainers(&int_mmap4, &fmmap)) if(!CheckEqualContainers(int_mmap4, fmmap))
return false; return false;
//Re-re-insertion of even //Re-re-insertion of even
std::multimap<int, int> int_even_mmap; std::multimap<int, int> int_even_mmap;
@@ -273,7 +273,7 @@ bool flat_tree_ordered_insertion_test()
} }
fmmap.insert(ordered_range, int_even_mmap.begin(), int_even_mmap.end()); fmmap.insert(ordered_range, int_even_mmap.begin(), int_even_mmap.end());
int_mmap4.insert(int_even_mmap.begin(), int_even_mmap.end()); int_mmap4.insert(int_even_mmap.begin(), int_even_mmap.end());
if(!CheckEqualContainers(&int_mmap4, &fmmap)) if(!CheckEqualContainers(int_mmap4, fmmap))
return false; return false;
} }
@@ -285,24 +285,24 @@ bool flat_tree_ordered_insertion_test()
} }
//Construction insertion //Construction insertion
flat_map<int, int> fmap(ordered_unique_range, int_map.begin(), int_map.end()); flat_map<int, int> fmap(ordered_unique_range, int_map.begin(), int_map.end());
if(!CheckEqualContainers(&int_map, &fmap)) if(!CheckEqualContainers(int_map, fmap))
return false; return false;
//Insertion when empty //Insertion when empty
fmap.clear(); fmap.clear();
fmap.insert(ordered_unique_range, int_map.begin(), int_map.end()); fmap.insert(ordered_unique_range, int_map.begin(), int_map.end());
if(!CheckEqualContainers(&int_map, &fmap)) if(!CheckEqualContainers(int_map, fmap))
return false; return false;
//Re-insertion //Re-insertion
fmap.insert(ordered_unique_range, int_map.begin(), int_map.end()); fmap.insert(ordered_unique_range, int_map.begin(), int_map.end());
std::map<int, int> int_map2(int_map); std::map<int, int> int_map2(int_map);
int_map2.insert(int_map.begin(), int_map.end()); int_map2.insert(int_map.begin(), int_map.end());
if(!CheckEqualContainers(&int_map2, &fmap)) if(!CheckEqualContainers(int_map2, fmap))
return false; return false;
//Re-re-insertion //Re-re-insertion
fmap.insert(ordered_unique_range, int_map2.begin(), int_map2.end()); fmap.insert(ordered_unique_range, int_map2.begin(), int_map2.end());
std::map<int, int> int_map4(int_map2); std::map<int, int> int_map4(int_map2);
int_map4.insert(int_map2.begin(), int_map2.end()); int_map4.insert(int_map2.begin(), int_map2.end());
if(!CheckEqualContainers(&int_map4, &fmap)) if(!CheckEqualContainers(int_map4, fmap))
return false; return false;
//Re-re-insertion of even //Re-re-insertion of even
std::map<int, int> int_even_map; std::map<int, int> int_even_map;
@@ -311,7 +311,7 @@ bool flat_tree_ordered_insertion_test()
} }
fmap.insert(ordered_unique_range, int_even_map.begin(), int_even_map.end()); fmap.insert(ordered_unique_range, int_even_map.begin(), int_even_map.end());
int_map4.insert(int_even_map.begin(), int_even_map.end()); int_map4.insert(int_even_map.begin(), int_even_map.end());
if(!CheckEqualContainers(&int_map4, &fmap)) if(!CheckEqualContainers(int_map4, fmap))
return false; return false;
} }

View File

@@ -272,24 +272,24 @@ bool flat_tree_ordered_insertion_test()
} }
//Construction insertion //Construction insertion
flat_multiset<int> fmset(ordered_range, int_mset.begin(), int_mset.end()); flat_multiset<int> fmset(ordered_range, int_mset.begin(), int_mset.end());
if(!CheckEqualContainers(&int_mset, &fmset)) if(!CheckEqualContainers(int_mset, fmset))
return false; return false;
//Insertion when empty //Insertion when empty
fmset.clear(); fmset.clear();
fmset.insert(ordered_range, int_mset.begin(), int_mset.end()); fmset.insert(ordered_range, int_mset.begin(), int_mset.end());
if(!CheckEqualContainers(&int_mset, &fmset)) if(!CheckEqualContainers(int_mset, fmset))
return false; return false;
//Re-insertion //Re-insertion
fmset.insert(ordered_range, int_mset.begin(), int_mset.end()); fmset.insert(ordered_range, int_mset.begin(), int_mset.end());
std::multiset<int> int_mset2(int_mset); std::multiset<int> int_mset2(int_mset);
int_mset2.insert(int_mset.begin(), int_mset.end()); int_mset2.insert(int_mset.begin(), int_mset.end());
if(!CheckEqualContainers(&int_mset2, &fmset)) if(!CheckEqualContainers(int_mset2, fmset))
return false; return false;
//Re-re-insertion //Re-re-insertion
fmset.insert(ordered_range, int_mset2.begin(), int_mset2.end()); fmset.insert(ordered_range, int_mset2.begin(), int_mset2.end());
std::multiset<int> int_mset4(int_mset2); std::multiset<int> int_mset4(int_mset2);
int_mset4.insert(int_mset2.begin(), int_mset2.end()); int_mset4.insert(int_mset2.begin(), int_mset2.end());
if(!CheckEqualContainers(&int_mset4, &fmset)) if(!CheckEqualContainers(int_mset4, fmset))
return false; return false;
//Re-re-insertion of even //Re-re-insertion of even
std::multiset<int> int_even_mset; std::multiset<int> int_even_mset;
@@ -298,7 +298,7 @@ bool flat_tree_ordered_insertion_test()
} }
fmset.insert(ordered_range, int_even_mset.begin(), int_even_mset.end()); fmset.insert(ordered_range, int_even_mset.begin(), int_even_mset.end());
int_mset4.insert(int_even_mset.begin(), int_even_mset.end()); int_mset4.insert(int_even_mset.begin(), int_even_mset.end());
if(!CheckEqualContainers(&int_mset4, &fmset)) if(!CheckEqualContainers(int_mset4, fmset))
return false; return false;
} }
@@ -310,24 +310,24 @@ bool flat_tree_ordered_insertion_test()
} }
//Construction insertion //Construction insertion
flat_set<int> fset(ordered_unique_range, int_set.begin(), int_set.end()); flat_set<int> fset(ordered_unique_range, int_set.begin(), int_set.end());
if(!CheckEqualContainers(&int_set, &fset)) if(!CheckEqualContainers(int_set, fset))
return false; return false;
//Insertion when empty //Insertion when empty
fset.clear(); fset.clear();
fset.insert(ordered_unique_range, int_set.begin(), int_set.end()); fset.insert(ordered_unique_range, int_set.begin(), int_set.end());
if(!CheckEqualContainers(&int_set, &fset)) if(!CheckEqualContainers(int_set, fset))
return false; return false;
//Re-insertion //Re-insertion
fset.insert(ordered_unique_range, int_set.begin(), int_set.end()); fset.insert(ordered_unique_range, int_set.begin(), int_set.end());
std::set<int> int_set2(int_set); std::set<int> int_set2(int_set);
int_set2.insert(int_set.begin(), int_set.end()); int_set2.insert(int_set.begin(), int_set.end());
if(!CheckEqualContainers(&int_set2, &fset)) if(!CheckEqualContainers(int_set2, fset))
return false; return false;
//Re-re-insertion //Re-re-insertion
fset.insert(ordered_unique_range, int_set2.begin(), int_set2.end()); fset.insert(ordered_unique_range, int_set2.begin(), int_set2.end());
std::set<int> int_set4(int_set2); std::set<int> int_set4(int_set2);
int_set4.insert(int_set2.begin(), int_set2.end()); int_set4.insert(int_set2.begin(), int_set2.end());
if(!CheckEqualContainers(&int_set4, &fset)) if(!CheckEqualContainers(int_set4, fset))
return false; return false;
//Re-re-insertion of even //Re-re-insertion of even
std::set<int> int_even_set; std::set<int> int_even_set;
@@ -336,7 +336,7 @@ bool flat_tree_ordered_insertion_test()
} }
fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end()); fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end());
int_set4.insert(int_even_set.begin(), int_even_set.end()); int_set4.insert(int_even_set.begin(), int_even_set.end());
if(!CheckEqualContainers(&int_set4, &fset)) if(!CheckEqualContainers(int_set4, fset))
return false; return false;
//Partial Re-re-insertion of even //Partial Re-re-insertion of even
int_even_set.clear(); int_even_set.clear();
@@ -348,7 +348,7 @@ bool flat_tree_ordered_insertion_test()
//insert 0,4,8,12... //insert 0,4,8,12...
fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end()); fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end());
int_set4.insert(int_even_set.begin(), int_even_set.end()); int_set4.insert(int_even_set.begin(), int_even_set.end());
if(!CheckEqualContainers(&int_set4, &fset)) if(!CheckEqualContainers(int_set4, fset))
return false; return false;
for(std::size_t i = 2; i < NumElements; i+=4){ for(std::size_t i = 2; i < NumElements; i+=4){
int_even_set.insert(static_cast<int>(i)); int_even_set.insert(static_cast<int>(i));
@@ -356,7 +356,7 @@ bool flat_tree_ordered_insertion_test()
//insert 0,2,4,6,8,10,12... //insert 0,2,4,6,8,10,12...
fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end()); fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end());
int_set4.insert(int_even_set.begin(), int_even_set.end()); int_set4.insert(int_even_set.begin(), int_even_set.end());
if(!CheckEqualContainers(&int_set4, &fset)) if(!CheckEqualContainers(int_set4, fset))
return false; return false;
int_even_set.clear(); int_even_set.clear();
for(std::size_t i = 0; i < NumElements; i+=8){ for(std::size_t i = 0; i < NumElements; i+=8){
@@ -367,7 +367,7 @@ bool flat_tree_ordered_insertion_test()
//insert 0,8,16... //insert 0,8,16...
fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end()); fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end());
int_set4.insert(int_even_set.begin(), int_even_set.end()); int_set4.insert(int_even_set.begin(), int_even_set.end());
if(!CheckEqualContainers(&int_set4, &fset)) if(!CheckEqualContainers(int_set4, fset))
return false; return false;
for(std::size_t i = 0; i < NumElements; i+=2){ for(std::size_t i = 0; i < NumElements; i+=2){
int_even_set.insert(static_cast<int>(i)); int_even_set.insert(static_cast<int>(i));
@@ -375,7 +375,7 @@ bool flat_tree_ordered_insertion_test()
//insert 0,2,4,6,8,10,12... //insert 0,2,4,6,8,10,12...
fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end()); fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end());
int_set4.insert(int_even_set.begin(), int_even_set.end()); int_set4.insert(int_even_set.begin(), int_even_set.end());
if(!CheckEqualContainers(&int_set4, &fset)) if(!CheckEqualContainers(int_set4, fset))
return false; return false;
@@ -390,7 +390,7 @@ bool flat_tree_ordered_insertion_test()
//insert 0,2,8,10... //insert 0,2,8,10...
fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end()); fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end());
int_set4.insert(int_even_set.begin(), int_even_set.end()); int_set4.insert(int_even_set.begin(), int_even_set.end());
if(!CheckEqualContainers(&int_set4, &fset)) if(!CheckEqualContainers(int_set4, fset))
return false; return false;
for(std::size_t i = 0; i < NumElements; i+=2){ for(std::size_t i = 0; i < NumElements; i+=2){
int_even_set.insert(static_cast<int>(i)); int_even_set.insert(static_cast<int>(i));
@@ -398,7 +398,7 @@ bool flat_tree_ordered_insertion_test()
//insert 0,2,4,6,8,10,12... //insert 0,2,4,6,8,10,12...
fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end()); fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end());
int_set4.insert(int_even_set.begin(), int_even_set.end()); int_set4.insert(int_even_set.begin(), int_even_set.end());
if(!CheckEqualContainers(&int_set4, &fset)) if(!CheckEqualContainers(int_set4, fset))
return false; return false;
} }

View File

@@ -23,7 +23,7 @@ void
, std::size_t index , std::size_t index
) )
{ {
BOOST_TEST(CheckEqualContainers(&std_deque, &seq_container)); BOOST_TEST(CheckEqualContainers(std_deque, seq_container));
std_deque.insert( std_deque.insert(
std_deque.begin() + index std_deque.begin() + index
@@ -36,7 +36,7 @@ void
, input_deque.begin() , input_deque.begin()
, input_deque.end() , input_deque.end()
); );
BOOST_TEST(CheckEqualContainers(&std_deque, &seq_container)); BOOST_TEST(CheckEqualContainers(std_deque, seq_container));
} }
template<class SeqContainer> template<class SeqContainer>

View File

@@ -22,52 +22,53 @@
#include <boost/move/utility_core.hpp> #include <boost/move/utility_core.hpp>
#include <boost/move/iterator.hpp> #include <boost/move/iterator.hpp>
#include <string> #include <string>
#include <boost/move/make_unique.hpp>
namespace boost{ namespace boost{
namespace container { namespace container {
namespace test{ namespace test{
template<class V1, class V2> template<class V1, class V2>
bool list_copyable_only(V1 *, V2 *, boost::container::container_detail::false_type) bool list_copyable_only(V1 &, V2 &, boost::container::container_detail::false_type)
{ {
return true; return true;
} }
//Function to check if both sets are equal //Function to check if both sets are equal
template<class V1, class V2> template<class V1, class V2>
bool list_copyable_only(V1 *boostlist, V2 *stdlist, boost::container::container_detail::true_type) bool list_copyable_only(V1 &boostlist, V2 &stdlist, boost::container::container_detail::true_type)
{ {
typedef typename V1::value_type IntType; typedef typename V1::value_type IntType;
boostlist->insert(boostlist->end(), 50, IntType(1)); boostlist.insert(boostlist.end(), 50, IntType(1));
stdlist->insert(stdlist->end(), 50, 1); stdlist.insert(stdlist.end(), 50, 1);
if(!test::CheckEqualContainers(boostlist, stdlist)) return false; if(!test::CheckEqualContainers(boostlist, stdlist)) return false;
{ {
IntType move_me(1); IntType move_me(1);
boostlist->insert(boostlist->begin(), 50, boost::move(move_me)); boostlist.insert(boostlist.begin(), 50, boost::move(move_me));
stdlist->insert(stdlist->begin(), 50, 1); stdlist.insert(stdlist.begin(), 50, 1);
if(!test::CheckEqualContainers(boostlist, stdlist)) return false; if(!test::CheckEqualContainers(boostlist, stdlist)) return false;
} }
{ {
IntType move_me(2); IntType move_me(2);
boostlist->assign(boostlist->size()/2, boost::move(move_me)); boostlist.assign(boostlist.size()/2, boost::move(move_me));
stdlist->assign(stdlist->size()/2, 2); stdlist.assign(stdlist.size()/2, 2);
if(!test::CheckEqualContainers(boostlist, stdlist)) return false; if(!test::CheckEqualContainers(boostlist, stdlist)) return false;
} }
{ {
IntType move_me(3); IntType move_me(3);
boostlist->assign(boostlist->size()*3-1, boost::move(move_me)); boostlist.assign(boostlist.size()*3-1, boost::move(move_me));
stdlist->assign(stdlist->size()*3-1, 3); stdlist.assign(stdlist.size()*3-1, 3);
if(!test::CheckEqualContainers(boostlist, stdlist)) return false; if(!test::CheckEqualContainers(boostlist, stdlist)) return false;
} }
{ {
IntType copy_me(3); IntType copy_me(3);
const IntType ccopy_me(3); const IntType ccopy_me(3);
boostlist->push_front(copy_me); boostlist.push_front(copy_me);
stdlist->push_front(int(3)); stdlist.push_front(int(3));
boostlist->push_front(ccopy_me); boostlist.push_front(ccopy_me);
stdlist->push_front(int(3)); stdlist.push_front(int(3));
if(!test::CheckEqualContainers(boostlist, stdlist)) return false; if(!test::CheckEqualContainers(boostlist, stdlist)) return false;
} }
@@ -78,15 +79,15 @@ template<bool DoublyLinked>
struct list_push_data_function struct list_push_data_function
{ {
template<class MyBoostList, class MyStdList> template<class MyBoostList, class MyStdList>
static int execute(int max, MyBoostList *boostlist, MyStdList *stdlist) static int execute(int max, MyBoostList &boostlist, MyStdList &stdlist)
{ {
typedef typename MyBoostList::value_type IntType; typedef typename MyBoostList::value_type IntType;
for(int i = 0; i < max; ++i){ for(int i = 0; i < max; ++i){
IntType move_me(i); IntType move_me(i);
boostlist->push_back(boost::move(move_me)); boostlist.push_back(boost::move(move_me));
stdlist->push_back(i); stdlist.push_back(i);
boostlist->push_front(IntType(i)); boostlist.push_front(IntType(i));
stdlist->push_front(int(i)); stdlist.push_front(int(i));
} }
if(!CheckEqualContainers(boostlist, stdlist)) if(!CheckEqualContainers(boostlist, stdlist))
return 1; return 1;
@@ -98,15 +99,15 @@ template<>
struct list_push_data_function<false> struct list_push_data_function<false>
{ {
template<class MyBoostList, class MyStdList> template<class MyBoostList, class MyStdList>
static int execute(int max, MyBoostList *boostlist, MyStdList *stdlist) static int execute(int max, MyBoostList &boostlist, MyStdList &stdlist)
{ {
typedef typename MyBoostList::value_type IntType; typedef typename MyBoostList::value_type IntType;
for(int i = 0; i < max; ++i){ for(int i = 0; i < max; ++i){
IntType move_me(i); IntType move_me(i);
boostlist->push_front(boost::move(move_me)); boostlist.push_front(boost::move(move_me));
stdlist->push_front(i); stdlist.push_front(i);
boostlist->push_front(IntType(i)); boostlist.push_front(IntType(i));
stdlist->push_front(int(i)); stdlist.push_front(int(i));
} }
if(!CheckEqualContainers(boostlist, stdlist)) if(!CheckEqualContainers(boostlist, stdlist))
return 1; return 1;
@@ -118,10 +119,10 @@ template<bool DoublyLinked>
struct list_pop_back_function struct list_pop_back_function
{ {
template<class MyStdList, class MyBoostList> template<class MyStdList, class MyBoostList>
static int execute(MyBoostList *boostlist, MyStdList *stdlist) static int execute(MyBoostList &boostlist, MyStdList &stdlist)
{ {
boostlist->pop_back(); boostlist.pop_back();
stdlist->pop_back(); stdlist.pop_back();
if(!CheckEqualContainers(boostlist, stdlist)) if(!CheckEqualContainers(boostlist, stdlist))
return 1; return 1;
return 0; return 0;
@@ -132,7 +133,7 @@ template<>
struct list_pop_back_function<false> struct list_pop_back_function<false>
{ {
template<class MyStdList, class MyBoostList> template<class MyStdList, class MyBoostList>
static int execute(MyBoostList *boostlist, MyStdList *stdlist) static int execute(MyBoostList &boostlist, MyStdList &stdlist)
{ {
(void)boostlist; (void)stdlist; (void)boostlist; (void)stdlist;
return 0; return 0;
@@ -148,24 +149,26 @@ int list_test (bool copied_allocators_equal = true)
const int max = 100; const int max = 100;
typedef list_push_data_function<DoublyLinked> push_data_t; typedef list_push_data_function<DoublyLinked> push_data_t;
BOOST_TRY{ ::boost::movelib::unique_ptr<MyBoostList> const pboostlist = ::boost::movelib::make_unique<MyBoostList>();
MyBoostList *boostlist = new MyBoostList; ::boost::movelib::unique_ptr<MyStdList> const pstdlist = ::boost::movelib::make_unique<MyStdList>();
MyStdList *stdlist = new MyStdList;
MyBoostList &boostlist = *pboostlist;
MyStdList &stdlist = *pstdlist;
if(push_data_t::execute(max, boostlist, stdlist)){ if(push_data_t::execute(max, boostlist, stdlist)){
return 1; return 1;
} }
boostlist->erase(boostlist->begin()++); boostlist.erase(boostlist.begin()++);
stdlist->erase(stdlist->begin()++); stdlist.erase(stdlist.begin()++);
if(!CheckEqualContainers(boostlist, stdlist)) return 1; if(!CheckEqualContainers(boostlist, stdlist)) return 1;
if(list_pop_back_function<DoublyLinked>::execute(boostlist, stdlist)){ if(list_pop_back_function<DoublyLinked>::execute(boostlist, stdlist)){
return 1; return 1;
} }
boostlist->pop_front(); boostlist.pop_front();
stdlist->pop_front(); stdlist.pop_front();
if(!CheckEqualContainers(boostlist, stdlist)) return 1; if(!CheckEqualContainers(boostlist, stdlist)) return 1;
{ {
@@ -178,9 +181,9 @@ int list_test (bool copied_allocators_equal = true)
for(int i = 0; i < 50; ++i){ for(int i = 0; i < 50; ++i){
aux_vect2[i] = -1; aux_vect2[i] = -1;
} }
boostlist->assign(boost::make_move_iterator(&aux_vect[0]) boostlist.assign(boost::make_move_iterator(&aux_vect[0])
,boost::make_move_iterator(&aux_vect[50])); ,boost::make_move_iterator(&aux_vect[50]));
stdlist->assign(&aux_vect2[0], &aux_vect2[50]); stdlist.assign(&aux_vect2[0], &aux_vect2[50]);
if(!CheckEqualContainers(boostlist, stdlist)) return 1; if(!CheckEqualContainers(boostlist, stdlist)) return 1;
for(int i = 0; i < 50; ++i){ for(int i = 0; i < 50; ++i){
@@ -191,24 +194,24 @@ int list_test (bool copied_allocators_equal = true)
for(int i = 0; i < 50; ++i){ for(int i = 0; i < 50; ++i){
aux_vect2[i] = -1; aux_vect2[i] = -1;
} }
boostlist->assign(boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0])) boostlist.assign(boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0]))
,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[50]))); ,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[50])));
stdlist->assign(&aux_vect2[0], &aux_vect2[50]); stdlist.assign(&aux_vect2[0], &aux_vect2[50]);
if(!CheckEqualContainers(boostlist, stdlist)) return 1; if(!CheckEqualContainers(boostlist, stdlist)) return 1;
} }
if(copied_allocators_equal){ if(copied_allocators_equal){
boostlist->sort(); boostlist.sort();
stdlist->sort(); stdlist.sort();
if(!CheckEqualContainers(boostlist, stdlist)) return 1; if(!CheckEqualContainers(boostlist, stdlist)) return 1;
} }
boostlist->reverse(); boostlist.reverse();
stdlist->reverse(); stdlist.reverse();
if(!CheckEqualContainers(boostlist, stdlist)) return 1; if(!CheckEqualContainers(boostlist, stdlist)) return 1;
boostlist->reverse(); boostlist.reverse();
stdlist->reverse(); stdlist.reverse();
if(!CheckEqualContainers(boostlist, stdlist)) return 1; if(!CheckEqualContainers(boostlist, stdlist)) return 1;
{ {
@@ -221,15 +224,15 @@ int list_test (bool copied_allocators_equal = true)
for(int i = 0; i < 50; ++i){ for(int i = 0; i < 50; ++i){
aux_vect2[i] = -1; aux_vect2[i] = -1;
} }
typename MyBoostList::iterator old_begin = boostlist->begin(); typename MyBoostList::iterator old_begin = boostlist.begin();
typename MyBoostList::iterator it_insert = typename MyBoostList::iterator it_insert =
boostlist->insert(boostlist->begin() boostlist.insert(boostlist.begin()
,boost::make_move_iterator(&aux_vect[0]) ,boost::make_move_iterator(&aux_vect[0])
,boost::make_move_iterator(&aux_vect[50])); ,boost::make_move_iterator(&aux_vect[50]));
if(it_insert != boostlist->begin() || std::distance(it_insert, old_begin) != 50) if(it_insert != boostlist.begin() || std::distance(it_insert, old_begin) != 50)
return 1; return 1;
stdlist->insert(stdlist->begin(), &aux_vect2[0], &aux_vect2[50]); stdlist.insert(stdlist.begin(), &aux_vect2[0], &aux_vect2[50]);
if(!CheckEqualContainers(boostlist, stdlist)) if(!CheckEqualContainers(boostlist, stdlist))
return 1; return 1;
@@ -242,43 +245,43 @@ int list_test (bool copied_allocators_equal = true)
aux_vect2[i] = -1; aux_vect2[i] = -1;
} }
old_begin = boostlist->begin(); old_begin = boostlist.begin();
it_insert = boostlist->insert(boostlist->end() it_insert = boostlist.insert(boostlist.end()
,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0])) ,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0]))
,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[50]))); ,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[50])));
if(std::distance(it_insert, boostlist->end()) != 50) if(std::distance(it_insert, boostlist.end()) != 50)
return 1; return 1;
stdlist->insert(stdlist->end(), &aux_vect2[0], &aux_vect2[50]); stdlist.insert(stdlist.end(), &aux_vect2[0], &aux_vect2[50]);
if(!CheckEqualContainers(boostlist, stdlist)) if(!CheckEqualContainers(boostlist, stdlist))
return 1; return 1;
} }
boostlist->unique(); boostlist.unique();
stdlist->unique(); stdlist.unique();
if(!CheckEqualContainers(boostlist, stdlist)) if(!CheckEqualContainers(boostlist, stdlist))
return 1; return 1;
if(copied_allocators_equal){ if(copied_allocators_equal){
boostlist->sort(std::greater<IntType>()); boostlist.sort(std::greater<IntType>());
stdlist->sort(std::greater<int>()); stdlist.sort(std::greater<int>());
if(!CheckEqualContainers(boostlist, stdlist)) if(!CheckEqualContainers(boostlist, stdlist))
return 1; return 1;
} }
for(int i = 0; i < max; ++i){ for(int i = 0; i < max; ++i){
IntType new_int(i); IntType new_int(i);
boostlist->insert(boostlist->end(), boost::move(new_int)); boostlist.insert(boostlist.end(), boost::move(new_int));
stdlist->insert(stdlist->end(), i); stdlist.insert(stdlist.end(), i);
if(!test::CheckEqualContainers(boostlist, stdlist)) return 1; if(!test::CheckEqualContainers(boostlist, stdlist)) return 1;
} }
if(!test::CheckEqualContainers(boostlist, stdlist)) return 1; if(!test::CheckEqualContainers(boostlist, stdlist)) return 1;
boostlist->resize(25); boostlist.resize(25);
stdlist->resize(25); stdlist.resize(25);
boostlist->resize(50); boostlist.resize(50);
stdlist->resize(50); stdlist.resize(50);
boostlist->resize(0); boostlist.resize(0);
stdlist->resize(0); stdlist.resize(0);
if(!CheckEqualContainers(boostlist, stdlist)) if(!CheckEqualContainers(boostlist, stdlist))
return 1; return 1;
@@ -286,45 +289,45 @@ int list_test (bool copied_allocators_equal = true)
return 1; return 1;
} }
{ {
MyBoostList otherboostlist(boostlist->get_allocator()); MyBoostList otherboostlist(boostlist.get_allocator());
MyStdList otherstdlist; MyStdList otherstdlist;
int listsize = (int)boostlist->size(); int listsize = (int)boostlist.size();
if(push_data_t::execute(listsize, boostlist, stdlist)){ if(push_data_t::execute(listsize, boostlist, stdlist)){
return 1; return 1;
} }
if(copied_allocators_equal){ if(copied_allocators_equal){
boostlist->splice(boostlist->begin(), otherboostlist); boostlist.splice(boostlist.begin(), otherboostlist);
stdlist->splice(stdlist->begin(), otherstdlist); stdlist.splice(stdlist.begin(), otherstdlist);
if(!CheckEqualContainers(boostlist, stdlist)) if(!CheckEqualContainers(boostlist, stdlist))
return 1; return 1;
} }
listsize = (int)boostlist->size(); listsize = (int)boostlist.size();
if(push_data_t::execute(listsize, boostlist, stdlist)){ if(push_data_t::execute(listsize, boostlist, stdlist)){
return 1; return 1;
} }
if(push_data_t::execute(listsize, &otherboostlist, &otherstdlist)){ if(push_data_t::execute(listsize, otherboostlist, otherstdlist)){
return 1; return 1;
} }
if(copied_allocators_equal){ if(copied_allocators_equal){
boostlist->sort(std::greater<IntType>()); boostlist.sort(std::greater<IntType>());
stdlist->sort(std::greater<int>()); stdlist.sort(std::greater<int>());
if(!CheckEqualContainers(boostlist, stdlist)) if(!CheckEqualContainers(boostlist, stdlist))
return 1; return 1;
otherboostlist.sort(std::greater<IntType>()); otherboostlist.sort(std::greater<IntType>());
otherstdlist.sort(std::greater<int>()); otherstdlist.sort(std::greater<int>());
if(!CheckEqualContainers(&otherboostlist, &otherstdlist)) if(!CheckEqualContainers(otherboostlist, otherstdlist))
return 1; return 1;
boostlist->merge(otherboostlist, std::greater<IntType>()); boostlist.merge(otherboostlist, std::greater<IntType>());
stdlist->merge(otherstdlist, std::greater<int>()); stdlist.merge(otherstdlist, std::greater<int>());
if(!CheckEqualContainers(boostlist, stdlist)) if(!CheckEqualContainers(boostlist, stdlist))
return 1; return 1;
} }
@@ -334,14 +337,6 @@ int list_test (bool copied_allocators_equal = true)
return 1; return 1;
} }
} }
delete boostlist;
delete stdlist;
}
BOOST_CATCH(...){
BOOST_RETHROW;
}
BOOST_CATCH_END
return 0; return 0;
} }

View File

@@ -21,6 +21,7 @@
#include <boost/container/detail/pair.hpp> #include <boost/container/detail/pair.hpp>
#include <boost/move/iterator.hpp> #include <boost/move/iterator.hpp>
#include <boost/move/utility_core.hpp> #include <boost/move/utility_core.hpp>
#include <boost/move/make_unique.hpp>
#include <string> #include <string>
#include <boost/intrusive/detail/has_member_function_callable_with.hpp> #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
@@ -67,64 +68,58 @@ int map_test_copyable(boost::container::container_detail::true_type)
typedef container_detail::pair<IntType, IntType> IntPairType; typedef container_detail::pair<IntType, IntType> IntPairType;
typedef typename MyStdMap::value_type StdPairType; typedef typename MyStdMap::value_type StdPairType;
const int max = 100; const int max = 50;
BOOST_TRY{ ::boost::movelib::unique_ptr<MyBoostMap> const pboostmap = ::boost::movelib::make_unique<MyBoostMap>();
MyBoostMap *boostmap = new MyBoostMap; ::boost::movelib::unique_ptr<MyStdMap> const pstdmap = ::boost::movelib::make_unique<MyStdMap>();
MyStdMap *stdmap = new MyStdMap; ::boost::movelib::unique_ptr<MyBoostMultiMap> const pboostmultimap = ::boost::movelib::make_unique<MyBoostMultiMap>();
MyBoostMultiMap *boostmultimap = new MyBoostMultiMap; ::boost::movelib::unique_ptr<MyStdMultiMap> const pstdmultimap = ::boost::movelib::make_unique<MyStdMultiMap>();
MyStdMultiMap *stdmultimap = new MyStdMultiMap; MyBoostMap &boostmap = *pboostmap;
MyStdMap &stdmap = *pstdmap;
MyBoostMultiMap &boostmultimap = *pboostmultimap;
MyStdMultiMap &stdmultimap = *pstdmultimap;
int i; int i;
for(i = 0; i < max; ++i){ for(i = 0; i < max; ++i){
{ {
IntType i1(i), i2(i); IntType i1(i), i2(i);
IntPairType intpair1(boost::move(i1), boost::move(i2)); IntPairType intpair1(boost::move(i1), boost::move(i2));
boostmap->insert(boost::move(intpair1)); boostmap.insert(boost::move(intpair1));
stdmap->insert(StdPairType(i, i)); stdmap.insert(StdPairType(i, i));
} }
{ {
IntType i1(i), i2(i); IntType i1(i), i2(i);
IntPairType intpair2(boost::move(i1), boost::move(i2)); IntPairType intpair2(boost::move(i1), boost::move(i2));
boostmultimap->insert(boost::move(intpair2)); boostmultimap.insert(boost::move(intpair2));
stdmultimap->insert(StdPairType(i, i)); stdmultimap.insert(StdPairType(i, i));
} }
} }
if(!CheckEqualContainers(boostmap, stdmap)) return 1; if(!CheckEqualContainers(boostmap, stdmap)) return 1;
if(!CheckEqualContainers(boostmultimap, stdmultimap)) return 1; if(!CheckEqualContainers(boostmultimap, stdmultimap)) return 1;
{ {
//Now, test copy constructor //Now, test copy constructor
MyBoostMap boostmapcopy(*boostmap); MyBoostMap boostmapcopy(boostmap);
MyStdMap stdmapcopy(*stdmap); MyStdMap stdmapcopy(stdmap);
MyBoostMultiMap boostmmapcopy(*boostmultimap); MyBoostMultiMap boostmmapcopy(boostmultimap);
MyStdMultiMap stdmmapcopy(*stdmultimap); MyStdMultiMap stdmmapcopy(stdmultimap);
if(!CheckEqualContainers(&boostmapcopy, &stdmapcopy)) if(!CheckEqualContainers(boostmapcopy, stdmapcopy))
return 1; return 1;
if(!CheckEqualContainers(&boostmmapcopy, &stdmmapcopy)) if(!CheckEqualContainers(boostmmapcopy, stdmmapcopy))
return 1; return 1;
//And now assignment //And now assignment
boostmapcopy = *boostmap; boostmapcopy = boostmap;
stdmapcopy = *stdmap; stdmapcopy = stdmap;
boostmmapcopy = *boostmultimap; boostmmapcopy = boostmultimap;
stdmmapcopy = *stdmultimap; stdmmapcopy = stdmultimap;
if(!CheckEqualContainers(&boostmapcopy, &stdmapcopy)) if(!CheckEqualContainers(boostmapcopy, stdmapcopy))
return 1; return 1;
if(!CheckEqualContainers(&boostmmapcopy, &stdmmapcopy)) if(!CheckEqualContainers(boostmmapcopy, stdmmapcopy))
return 1; return 1;
delete boostmap;
delete boostmultimap;
delete stdmap;
delete stdmultimap;
} }
}
BOOST_CATCH(...){
BOOST_RETHROW;
}
BOOST_CATCH_END
return 0; return 0;
} }
@@ -137,13 +132,16 @@ int map_test()
typedef typename MyBoostMap::key_type IntType; typedef typename MyBoostMap::key_type IntType;
typedef container_detail::pair<IntType, IntType> IntPairType; typedef container_detail::pair<IntType, IntType> IntPairType;
typedef typename MyStdMap::value_type StdPairType; typedef typename MyStdMap::value_type StdPairType;
const int max = 100; const int max = 50;
BOOST_TRY{ ::boost::movelib::unique_ptr<MyBoostMap> const pboostmap = ::boost::movelib::make_unique<MyBoostMap>();
MyBoostMap *boostmap = new MyBoostMap; ::boost::movelib::unique_ptr<MyStdMap> const pstdmap = ::boost::movelib::make_unique<MyStdMap>();
MyStdMap *stdmap = new MyStdMap; ::boost::movelib::unique_ptr<MyBoostMultiMap> const pboostmultimap = ::boost::movelib::make_unique<MyBoostMultiMap>();
MyBoostMultiMap *boostmultimap = new MyBoostMultiMap; ::boost::movelib::unique_ptr<MyStdMultiMap> const pstdmultimap = ::boost::movelib::make_unique<MyStdMultiMap>();
MyStdMultiMap *stdmultimap = new MyStdMultiMap; MyBoostMap &boostmap = *pboostmap;
MyStdMap &stdmap = *pstdmap;
MyBoostMultiMap &boostmultimap = *pboostmultimap;
MyStdMultiMap &stdmultimap = *pstdmultimap;
//Test construction from a range //Test construction from a range
{ {
@@ -170,14 +168,21 @@ int map_test()
new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2)); new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
} }
MyBoostMap *boostmap2 = new MyBoostMap ::boost::movelib::unique_ptr<MyBoostMap> const pboostmap2 = ::boost::movelib::make_unique<MyBoostMap>
( boost::make_move_iterator(&aux_vect[0]) ( boost::make_move_iterator(&aux_vect[0])
, boost::make_move_iterator(aux_vect + 50)); , boost::make_move_iterator(&aux_vect[0] + 50));
MyStdMap *stdmap2 = new MyStdMap(aux_vect2, aux_vect2 + 50); ::boost::movelib::unique_ptr<MyStdMap> const pstdmap2 = ::boost::movelib::make_unique<MyStdMap>
MyBoostMultiMap *boostmultimap2 = new MyBoostMultiMap (&aux_vect2[0], &aux_vect2[0] + 50);
::boost::movelib::unique_ptr<MyBoostMultiMap> const pboostmultimap2 = ::boost::movelib::make_unique<MyBoostMultiMap>
( boost::make_move_iterator(&aux_vect3[0]) ( boost::make_move_iterator(&aux_vect3[0])
, boost::make_move_iterator(aux_vect3 + 50)); , boost::make_move_iterator(&aux_vect3[0] + 50));
MyStdMultiMap *stdmultimap2 = new MyStdMultiMap(aux_vect2, aux_vect2 + 50); ::boost::movelib::unique_ptr<MyStdMultiMap> const pstdmultimap2 = ::boost::movelib::make_unique<MyStdMultiMap>
(&aux_vect2[0], &aux_vect2[0] + 50);
MyBoostMap &boostmap2 = *pboostmap2;
MyStdMap &stdmap2 = *pstdmap2;
MyBoostMultiMap &boostmultimap2 = *pboostmultimap2;
MyStdMultiMap &stdmultimap2 = *pstdmultimap2;
if(!CheckEqualContainers(boostmap2, stdmap2)) return 1; if(!CheckEqualContainers(boostmap2, stdmap2)) return 1;
if(!CheckEqualContainers(boostmultimap2, stdmultimap2)) return 1; if(!CheckEqualContainers(boostmultimap2, stdmultimap2)) return 1;
@@ -201,16 +206,20 @@ int map_test()
if(!CheckEqualContainers(boostmap2, stdmap2)) return 1; if(!CheckEqualContainers(boostmap2, stdmap2)) return 1;
if(!CheckEqualContainers(boostmultimap2, stdmultimap2)) return 1; if(!CheckEqualContainers(boostmultimap2, stdmultimap2)) return 1;
MyBoostMap *boostmap3 = new MyBoostMap ::boost::movelib::unique_ptr<MyBoostMap> const pboostmap3 = ::boost::movelib::make_unique<MyBoostMap>
( ordered_unique_range ( boost::make_move_iterator(&aux_vect[0])
, boost::make_move_iterator(&aux_vect[0]) , boost::make_move_iterator(&aux_vect[0] + 50));
, boost::make_move_iterator(aux_vect + 50)); ::boost::movelib::unique_ptr<MyStdMap> const pstdmap3 = ::boost::movelib::make_unique<MyStdMap>
MyStdMap *stdmap3 = new MyStdMap(aux_vect2, aux_vect2 + 50); (&aux_vect2[0], &aux_vect2[0] + 50);
MyBoostMultiMap *boostmultimap3 = new MyBoostMultiMap ::boost::movelib::unique_ptr<MyBoostMultiMap> const pboostmultimap3 = ::boost::movelib::make_unique<MyBoostMultiMap>
( ordered_range ( boost::make_move_iterator(&aux_vect3[0])
, boost::make_move_iterator(&aux_vect3[0]) , boost::make_move_iterator(&aux_vect3[0] + 50));
, boost::make_move_iterator(aux_vect3 + 50)); ::boost::movelib::unique_ptr<MyStdMultiMap> const pstdmultimap3 = ::boost::movelib::make_unique<MyStdMultiMap>
MyStdMultiMap *stdmultimap3 = new MyStdMultiMap(aux_vect2, aux_vect2 + 50); (&aux_vect2[0], &aux_vect2[0] + 50);
MyBoostMap &boostmap3 = *pboostmap3;
MyStdMap &stdmap3 = *pstdmap3;
MyBoostMultiMap &boostmultimap3 = *pboostmultimap3;
MyStdMultiMap &stdmultimap3 = *pstdmultimap3;
if(!CheckEqualContainers(boostmap3, stdmap3)){ if(!CheckEqualContainers(boostmap3, stdmap3)){
std::cout << "Error in construct<MyBoostMap>(MyBoostMap3)" << std::endl; std::cout << "Error in construct<MyBoostMap>(MyBoostMap3)" << std::endl;
@@ -223,31 +232,22 @@ int map_test()
{ {
IntType i0(0); IntType i0(0);
boostmap2->erase(i0); boostmap2.erase(i0);
boostmultimap2->erase(i0); boostmultimap2.erase(i0);
stdmap2->erase(0); stdmap2.erase(0);
stdmultimap2->erase(0); stdmultimap2.erase(0);
} }
{ {
IntType i0(0); IntType i0(0);
IntType i1(1); IntType i1(1);
(*boostmap2)[::boost::move(i0)] = ::boost::move(i1); boostmap2[::boost::move(i0)] = ::boost::move(i1);
} }
{ {
IntType i1(1); IntType i1(1);
(*boostmap2)[IntType(0)] = ::boost::move(i1); boostmap2[IntType(0)] = ::boost::move(i1);
} }
(*stdmap2)[0] = 1; stdmap2[0] = 1;
if(!CheckEqualContainers(boostmap2, stdmap2)) return 1; if(!CheckEqualContainers(boostmap2, stdmap2)) return 1;
delete boostmap2;
delete boostmultimap2;
delete stdmap2;
delete stdmultimap2;
delete boostmap3;
delete boostmultimap3;
delete stdmap3;
delete stdmultimap3;
} }
{ {
//This is really nasty, but we have no other simple choice //This is really nasty, but we have no other simple choice
@@ -265,30 +265,30 @@ int map_test()
} }
for(int i = 0; i < max; ++i){ for(int i = 0; i < max; ++i){
boostmap->insert(boost::move(aux_vect[i])); boostmap.insert(boost::move(aux_vect[i]));
stdmap->insert(StdPairType(i, i)); stdmap.insert(StdPairType(i, i));
boostmultimap->insert(boost::move(aux_vect3[i])); boostmultimap.insert(boost::move(aux_vect3[i]));
stdmultimap->insert(StdPairType(i, i)); stdmultimap.insert(StdPairType(i, i));
} }
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
typename MyBoostMap::iterator it = boostmap->begin(); typename MyBoostMap::iterator it = boostmap.begin();
typename MyBoostMap::const_iterator cit = it; typename MyBoostMap::const_iterator cit = it;
(void)cit; (void)cit;
boostmap->erase(boostmap->begin()); boostmap.erase(boostmap.begin());
stdmap->erase(stdmap->begin()); stdmap.erase(stdmap.begin());
boostmultimap->erase(boostmultimap->begin()); boostmultimap.erase(boostmultimap.begin());
stdmultimap->erase(stdmultimap->begin()); stdmultimap.erase(stdmultimap.begin());
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
boostmap->erase(boostmap->begin()); boostmap.erase(boostmap.begin());
stdmap->erase(stdmap->begin()); stdmap.erase(stdmap.begin());
boostmultimap->erase(boostmultimap->begin()); boostmultimap.erase(boostmultimap.begin());
stdmultimap->erase(stdmultimap->begin()); stdmultimap.erase(stdmultimap.begin());
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
@@ -297,14 +297,14 @@ int map_test()
MyStdMap tmpstdmap2; MyStdMap tmpstdmap2;
MyBoostMultiMap tmpboostemultimap2; MyBoostMultiMap tmpboostemultimap2;
MyStdMultiMap tmpstdmultimap2; MyStdMultiMap tmpstdmultimap2;
boostmap->swap(tmpboostemap2); boostmap.swap(tmpboostemap2);
stdmap->swap(tmpstdmap2); stdmap.swap(tmpstdmap2);
boostmultimap->swap(tmpboostemultimap2); boostmultimap.swap(tmpboostemultimap2);
stdmultimap->swap(tmpstdmultimap2); stdmultimap.swap(tmpstdmultimap2);
boostmap->swap(tmpboostemap2); boostmap.swap(tmpboostemap2);
stdmap->swap(tmpstdmap2); stdmap.swap(tmpstdmap2);
boostmultimap->swap(tmpboostemultimap2); boostmultimap.swap(tmpboostemultimap2);
stdmultimap->swap(tmpstdmultimap2); stdmultimap.swap(tmpstdmultimap2);
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
} }
@@ -325,21 +325,21 @@ int map_test()
new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2)); new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
} }
boostmap->insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(aux_vect + 50)); boostmap.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + 50));
boostmultimap->insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(aux_vect3 + 50)); boostmultimap.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0] + 50));
for(std::size_t i = 0; i != 50; ++i){ for(std::size_t i = 0; i != 50; ++i){
StdPairType stdpairtype(-1, -1); StdPairType stdpairtype(-1, -1);
stdmap->insert(stdpairtype); stdmap.insert(stdpairtype);
stdmultimap->insert(stdpairtype); stdmultimap.insert(stdpairtype);
} }
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
for(int i = 0, j = static_cast<int>(boostmap->size()); i < j; ++i){ for(int i = 0, j = static_cast<int>(boostmap.size()); i < j; ++i){
boostmap->erase(IntType(i)); boostmap.erase(IntType(i));
stdmap->erase(i); stdmap.erase(i);
boostmultimap->erase(IntType(i)); boostmultimap.erase(IntType(i));
stdmultimap->erase(i); stdmultimap.erase(i);
} }
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
@@ -373,25 +373,25 @@ int map_test()
new(&aux_vect5[i])IntPairType(boost::move(i1), boost::move(i2)); new(&aux_vect5[i])IntPairType(boost::move(i1), boost::move(i2));
} }
boostmap->insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(aux_vect + 50)); boostmap.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + 50));
boostmap->insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(aux_vect3 + 50)); boostmap.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0] + 50));
boostmultimap->insert(boost::make_move_iterator(&aux_vect4[0]), boost::make_move_iterator(aux_vect4 + 50)); boostmultimap.insert(boost::make_move_iterator(&aux_vect4[0]), boost::make_move_iterator(aux_vect4 + 50));
boostmultimap->insert(boost::make_move_iterator(&aux_vect5[0]), boost::make_move_iterator(aux_vect5 + 50)); boostmultimap.insert(boost::make_move_iterator(&aux_vect5[0]), boost::make_move_iterator(aux_vect5 + 50));
for(std::size_t i = 0; i != 50; ++i){ for(std::size_t i = 0; i != 50; ++i){
StdPairType stdpairtype(-1, -1); StdPairType stdpairtype(-1, -1);
stdmap->insert(stdpairtype); stdmap.insert(stdpairtype);
stdmultimap->insert(stdpairtype); stdmultimap.insert(stdpairtype);
stdmap->insert(stdpairtype); stdmap.insert(stdpairtype);
stdmultimap->insert(stdpairtype); stdmultimap.insert(stdpairtype);
} }
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
boostmap->erase(boostmap->begin()->first); boostmap.erase(boostmap.begin()->first);
stdmap->erase(stdmap->begin()->first); stdmap.erase(stdmap.begin()->first);
boostmultimap->erase(boostmultimap->begin()->first); boostmultimap.erase(boostmultimap.begin()->first);
stdmultimap->erase(stdmultimap->begin()->first); stdmultimap.erase(stdmultimap.begin()->first);
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
} }
@@ -412,10 +412,10 @@ int map_test()
} }
for(int i = 0; i < max; ++i){ for(int i = 0; i < max; ++i){
boostmap->insert(boost::move(aux_vect[i])); boostmap.insert(boost::move(aux_vect[i]));
stdmap->insert(StdPairType(i, i)); stdmap.insert(StdPairType(i, i));
boostmultimap->insert(boost::move(aux_vect3[i])); boostmultimap.insert(boost::move(aux_vect3[i]));
stdmultimap->insert(StdPairType(i, i)); stdmultimap.insert(StdPairType(i, i));
} }
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1; if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
@@ -428,16 +428,16 @@ int map_test()
IntType i2(i); IntType i2(i);
new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
} }
boostmap->insert(boostmap->begin(), boost::move(intpair)); boostmap.insert(boostmap.begin(), boost::move(intpair));
stdmap->insert(stdmap->begin(), StdPairType(i, i)); stdmap.insert(stdmap.begin(), StdPairType(i, i));
//PrintContainers(boostmap, stdmap); //PrintContainers(boostmap, stdmap);
{ {
IntType i1(i); IntType i1(i);
IntType i2(i); IntType i2(i);
new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
} }
boostmultimap->insert(boostmultimap->begin(), boost::move(intpair)); boostmultimap.insert(boostmultimap.begin(), boost::move(intpair));
stdmultimap->insert(stdmultimap->begin(), StdPairType(i, i)); stdmultimap.insert(stdmultimap.begin(), StdPairType(i, i));
//PrintContainers(boostmultimap, stdmultimap); //PrintContainers(boostmultimap, stdmultimap);
if(!CheckEqualPairContainers(boostmap, stdmap)) if(!CheckEqualPairContainers(boostmap, stdmap))
return 1; return 1;
@@ -448,15 +448,15 @@ int map_test()
IntType i2(i); IntType i2(i);
new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
} }
boostmap->insert(boostmap->end(), boost::move(intpair)); boostmap.insert(boostmap.end(), boost::move(intpair));
stdmap->insert(stdmap->end(), StdPairType(i, i)); stdmap.insert(stdmap.end(), StdPairType(i, i));
{ {
IntType i1(i); IntType i1(i);
IntType i2(i); IntType i2(i);
new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
} }
boostmultimap->insert(boostmultimap->end(), boost::move(intpair)); boostmultimap.insert(boostmultimap.end(), boost::move(intpair));
stdmultimap->insert(stdmultimap->end(), StdPairType(i, i)); stdmultimap.insert(stdmultimap.end(), StdPairType(i, i));
if(!CheckEqualPairContainers(boostmap, stdmap)) if(!CheckEqualPairContainers(boostmap, stdmap))
return 1; return 1;
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) if(!CheckEqualPairContainers(boostmultimap, stdmultimap))
@@ -466,8 +466,8 @@ int map_test()
IntType i2(i); IntType i2(i);
new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
} }
boostmap->insert(boostmap->lower_bound(IntType(i)), boost::move(intpair)); boostmap.insert(boostmap.lower_bound(IntType(i)), boost::move(intpair));
stdmap->insert(stdmap->lower_bound(i), StdPairType(i, i)); stdmap.insert(stdmap.lower_bound(i), StdPairType(i, i));
//PrintContainers(boostmap, stdmap); //PrintContainers(boostmap, stdmap);
{ {
IntType i1(i); IntType i1(i);
@@ -476,8 +476,8 @@ int map_test()
} }
{ {
IntType i1(i); IntType i1(i);
boostmultimap->insert(boostmultimap->lower_bound(boost::move(i1)), boost::move(intpair)); boostmultimap.insert(boostmultimap.lower_bound(boost::move(i1)), boost::move(intpair));
stdmultimap->insert(stdmultimap->lower_bound(i), StdPairType(i, i)); stdmultimap.insert(stdmultimap.lower_bound(i), StdPairType(i, i));
} }
//PrintContainers(boostmultimap, stdmultimap); //PrintContainers(boostmultimap, stdmultimap);
@@ -487,10 +487,10 @@ int map_test()
return 1; return 1;
{ //Check equal_range { //Check equal_range
std::pair<typename MyBoostMultiMap::iterator, typename MyBoostMultiMap::iterator> bret = std::pair<typename MyBoostMultiMap::iterator, typename MyBoostMultiMap::iterator> bret =
boostmultimap->equal_range(boostmultimap->begin()->first); boostmultimap.equal_range(boostmultimap.begin()->first);
std::pair<typename MyStdMultiMap::iterator, typename MyStdMultiMap::iterator> sret = std::pair<typename MyStdMultiMap::iterator, typename MyStdMultiMap::iterator> sret =
stdmultimap->equal_range(stdmultimap->begin()->first); stdmultimap.equal_range(stdmultimap.begin()->first);
if( std::distance(bret.first, bret.second) != if( std::distance(bret.first, bret.second) !=
std::distance(sret.first, sret.second) ){ std::distance(sret.first, sret.second) ){
@@ -499,8 +499,8 @@ int map_test()
} }
{ {
IntType i1(i); IntType i1(i);
boostmap->insert(boostmap->upper_bound(boost::move(i1)), boost::move(intpair)); boostmap.insert(boostmap.upper_bound(boost::move(i1)), boost::move(intpair));
stdmap->insert(stdmap->upper_bound(i), StdPairType(i, i)); stdmap.insert(stdmap.upper_bound(i), StdPairType(i, i));
} }
//PrintContainers(boostmap, stdmap); //PrintContainers(boostmap, stdmap);
{ {
@@ -510,8 +510,8 @@ int map_test()
} }
{ {
IntType i1(i); IntType i1(i);
boostmultimap->insert(boostmultimap->upper_bound(boost::move(i1)), boost::move(intpair)); boostmultimap.insert(boostmultimap.upper_bound(boost::move(i1)), boost::move(intpair));
stdmultimap->insert(stdmultimap->upper_bound(i), StdPairType(i, i)); stdmultimap.insert(stdmultimap.upper_bound(i), StdPairType(i, i));
} }
//PrintContainers(boostmultimap, stdmultimap); //PrintContainers(boostmultimap, stdmultimap);
if(!CheckEqualPairContainers(boostmap, stdmap)) if(!CheckEqualPairContainers(boostmap, stdmap))
@@ -519,36 +519,36 @@ int map_test()
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) if(!CheckEqualPairContainers(boostmultimap, stdmultimap))
return 1; return 1;
map_test_rebalanceable(*boostmap map_test_rebalanceable(boostmap
, container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostMap>::value>()); , container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostMap>::value>());
if(!CheckEqualContainers(boostmap, stdmap)){ if(!CheckEqualContainers(boostmap, stdmap)){
std::cout << "Error in boostmap->rebalance()" << std::endl; std::cout << "Error in boostmap.rebalance()" << std::endl;
return 1; return 1;
} }
map_test_rebalanceable(*boostmultimap map_test_rebalanceable(boostmultimap
, container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostMultiMap>::value>()); , container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostMultiMap>::value>());
if(!CheckEqualContainers(boostmultimap, stdmultimap)){ if(!CheckEqualContainers(boostmultimap, stdmultimap)){
std::cout << "Error in boostmultimap->rebalance()" << std::endl; std::cout << "Error in boostmultimap.rebalance()" << std::endl;
return 1; return 1;
} }
} }
//Compare count with std containers //Compare count with std containers
for(int i = 0; i < max; ++i){ for(int i = 0; i < max; ++i){
if(boostmap->count(IntType(i)) != stdmap->count(i)){ if(boostmap.count(IntType(i)) != stdmap.count(i)){
return -1; return -1;
} }
if(boostmultimap->count(IntType(i)) != stdmultimap->count(i)){ if(boostmultimap.count(IntType(i)) != stdmultimap.count(i)){
return -1; return -1;
} }
} }
//Now do count exercise //Now do count exercise
boostmap->erase(boostmap->begin(), boostmap->end()); boostmap.erase(boostmap.begin(), boostmap.end());
boostmultimap->erase(boostmultimap->begin(), boostmultimap->end()); boostmultimap.erase(boostmultimap.begin(), boostmultimap.end());
boostmap->clear(); boostmap.clear();
boostmultimap->clear(); boostmultimap.clear();
for(int j = 0; j < 3; ++j) for(int j = 0; j < 3; ++j)
for(int i = 0; i < 100; ++i){ for(int i = 0; i < 100; ++i){
@@ -557,29 +557,19 @@ int map_test()
IntType i1(i), i2(i); IntType i1(i), i2(i);
new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
} }
boostmap->insert(boost::move(intpair)); boostmap.insert(boost::move(intpair));
{ {
IntType i1(i), i2(i); IntType i1(i), i2(i);
new(&intpair)IntPairType(boost::move(i1), boost::move(i2)); new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
} }
boostmultimap->insert(boost::move(intpair)); boostmultimap.insert(boost::move(intpair));
if(boostmap->count(IntType(i)) != typename MyBoostMultiMap::size_type(1)) if(boostmap.count(IntType(i)) != typename MyBoostMultiMap::size_type(1))
return 1; return 1;
if(boostmultimap->count(IntType(i)) != typename MyBoostMultiMap::size_type(j+1)) if(boostmultimap.count(IntType(i)) != typename MyBoostMultiMap::size_type(j+1))
return 1; return 1;
} }
} }
delete boostmap;
delete stdmap;
delete boostmultimap;
delete stdmultimap;
}
BOOST_CATCH(...){
BOOST_RETHROW;
}
BOOST_CATCH_END
if(map_test_copyable<MyBoostMap, MyStdMap, MyBoostMultiMap, MyStdMultiMap> if(map_test_copyable<MyBoostMap, MyStdMap, MyBoostMultiMap, MyStdMultiMap>
(container_detail::bool_<boost::container::test::is_copyable<IntType>::value>())){ (container_detail::bool_<boost::container::test::is_copyable<IntType>::value>())){
return 1; return 1;

View File

@@ -19,6 +19,7 @@
#include "print_container.hpp" #include "print_container.hpp"
#include <boost/move/utility_core.hpp> #include <boost/move/utility_core.hpp>
#include <boost/move/iterator.hpp> #include <boost/move/iterator.hpp>
#include <boost/move/make_unique.hpp>
#include <string> #include <string>
#include <boost/intrusive/detail/has_member_function_callable_with.hpp> #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
@@ -57,59 +58,56 @@ template<class MyBoostSet
int set_test_copyable(boost::container::container_detail::true_type) int set_test_copyable(boost::container::container_detail::true_type)
{ {
typedef typename MyBoostSet::value_type IntType; typedef typename MyBoostSet::value_type IntType;
const int max = 100; const int max = 50;
BOOST_TRY{ ::boost::movelib::unique_ptr<MyBoostSet> const pboostset = ::boost::movelib::make_unique<MyBoostSet>();
MyBoostSet *boostset = new MyBoostSet; ::boost::movelib::unique_ptr<MyStdSet> const pstdset = ::boost::movelib::make_unique<MyStdSet>();
MyStdSet *stdset = new MyStdSet; ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset = ::boost::movelib::make_unique<MyBoostMultiSet>();
MyBoostMultiSet *boostmultiset = new MyBoostMultiSet; ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset = ::boost::movelib::make_unique<MyStdMultiSet>();
MyStdMultiSet *stdmultiset = new MyStdMultiSet;
MyBoostSet &boostset = *pboostset;
MyStdSet &stdset = *pstdset;
MyBoostMultiSet &boostmultiset = *pboostmultiset;
MyStdMultiSet &stdmultiset = *pstdmultiset;
for(int i = 0; i < max; ++i){ for(int i = 0; i < max; ++i){
IntType move_me(i); IntType move_me(i);
boostset->insert(boost::move(move_me)); boostset.insert(boost::move(move_me));
stdset->insert(i); stdset.insert(i);
IntType move_me2(i); IntType move_me2(i);
boostmultiset->insert(boost::move(move_me2)); boostmultiset.insert(boost::move(move_me2));
stdmultiset->insert(i); stdmultiset.insert(i);
} }
if(!CheckEqualContainers(boostset, stdset)) return 1; if(!CheckEqualContainers(boostset, stdset)) return 1;
if(!CheckEqualContainers(boostmultiset, stdmultiset)) return 1; if(!CheckEqualContainers(boostmultiset, stdmultiset)) return 1;
{ {
//Now, test copy constructor //Now, test copy constructor
MyBoostSet boostsetcopy(*boostset); MyBoostSet boostsetcopy(boostset);
MyStdSet stdsetcopy(*stdset); MyStdSet stdsetcopy(stdset);
if(!CheckEqualContainers(&boostsetcopy, &stdsetcopy)) if(!CheckEqualContainers(boostsetcopy, stdsetcopy))
return 1; return 1;
MyBoostMultiSet boostmsetcopy(*boostmultiset); MyBoostMultiSet boostmsetcopy(boostmultiset);
MyStdMultiSet stdmsetcopy(*stdmultiset); MyStdMultiSet stdmsetcopy(stdmultiset);
if(!CheckEqualContainers(&boostmsetcopy, &stdmsetcopy)) if(!CheckEqualContainers(boostmsetcopy, stdmsetcopy))
return 1; return 1;
//And now assignment //And now assignment
boostsetcopy = *boostset; boostsetcopy =boostset;
stdsetcopy = *stdset; stdsetcopy = stdset;
if(!CheckEqualContainers(&boostsetcopy, &stdsetcopy)) if(!CheckEqualContainers(boostsetcopy, stdsetcopy))
return 1; return 1;
boostmsetcopy = *boostmultiset; boostmsetcopy = boostmultiset;
stdmsetcopy = *stdmultiset; stdmsetcopy = stdmultiset;
if(!CheckEqualContainers(&boostmsetcopy, &stdmsetcopy)) if(!CheckEqualContainers(boostmsetcopy, stdmsetcopy))
return 1; return 1;
} }
delete boostset;
delete boostmultiset;
}
BOOST_CATCH(...){
BOOST_RETHROW;
}
BOOST_CATCH_END
return 0; return 0;
} }
@@ -121,12 +119,17 @@ template<class MyBoostSet
int set_test () int set_test ()
{ {
typedef typename MyBoostSet::value_type IntType; typedef typename MyBoostSet::value_type IntType;
const int max = 100; const int max = 50;
MyBoostSet *boostset = new MyBoostSet; ::boost::movelib::unique_ptr<MyBoostSet> const pboostset = ::boost::movelib::make_unique<MyBoostSet>();
MyStdSet *stdset = new MyStdSet; ::boost::movelib::unique_ptr<MyStdSet> const pstdset = ::boost::movelib::make_unique<MyStdSet>();
MyBoostMultiSet *boostmultiset = new MyBoostMultiSet; ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset = ::boost::movelib::make_unique<MyBoostMultiSet>();
MyStdMultiSet *stdmultiset = new MyStdMultiSet; ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset = ::boost::movelib::make_unique<MyStdMultiSet>();
MyBoostSet &boostset = *pboostset;
MyStdSet &stdset = *pstdset;
MyBoostMultiSet &boostmultiset = *pboostmultiset;
MyStdMultiSet &stdmultiset = *pstdmultiset;
//Test construction from a range //Test construction from a range
{ {
@@ -145,14 +148,22 @@ int set_test ()
aux_vect3[i] = boost::move(move_me); aux_vect3[i] = boost::move(move_me);
} }
MyBoostSet *boostset2 = new MyBoostSet ::boost::movelib::unique_ptr<MyBoostSet> const pboostset2 = ::boost::movelib::make_unique<MyBoostSet>
( boost::make_move_iterator(&aux_vect[0]) ( boost::make_move_iterator(&aux_vect[0])
, boost::make_move_iterator(aux_vect + 50)); , boost::make_move_iterator(aux_vect + 50));
MyStdSet *stdset2 = new MyStdSet(aux_vect2, aux_vect2 + 50); ::boost::movelib::unique_ptr<MyStdSet> const pstdset2 = ::boost::movelib::make_unique<MyStdSet>
MyBoostMultiSet *boostmultiset2 = new MyBoostMultiSet (&aux_vect2[0], &aux_vect2[0] + 50);
::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset2 = ::boost::movelib::make_unique<MyBoostMultiSet>
( boost::make_move_iterator(&aux_vect3[0]) ( boost::make_move_iterator(&aux_vect3[0])
, boost::make_move_iterator(aux_vect3 + 50)); , boost::make_move_iterator(aux_vect3 + 50));
MyStdMultiSet *stdmultiset2 = new MyStdMultiSet(aux_vect2, aux_vect2 + 50); ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset2 = ::boost::movelib::make_unique<MyStdMultiSet>
(&aux_vect2[0], &aux_vect2[0] + 50);
MyBoostSet &boostset2 = *pboostset2;
MyStdSet &stdset2 = *pstdset2;
MyBoostMultiSet &boostmultiset2 = *pboostmultiset2;
MyStdMultiSet &stdmultiset2 = *pstdmultiset2;
if(!CheckEqualContainers(boostset2, stdset2)){ if(!CheckEqualContainers(boostset2, stdset2)){
std::cout << "Error in construct<MyBoostSet>(MyBoostSet2)" << std::endl; std::cout << "Error in construct<MyBoostSet>(MyBoostSet2)" << std::endl;
return 1; return 1;
@@ -177,16 +188,25 @@ int set_test ()
aux_vect3[i] = boost::move(move_me); aux_vect3[i] = boost::move(move_me);
} }
MyBoostSet *boostset3 = new MyBoostSet
::boost::movelib::unique_ptr<MyBoostSet> const pboostset3 = ::boost::movelib::make_unique<MyBoostSet>
( ordered_unique_range ( ordered_unique_range
, boost::make_move_iterator(&aux_vect[0]) , boost::make_move_iterator(&aux_vect[0])
, boost::make_move_iterator(aux_vect + 50)); , boost::make_move_iterator(&aux_vect[0] + 50));
MyStdSet *stdset3 = new MyStdSet(aux_vect2, aux_vect2 + 50); ::boost::movelib::unique_ptr<MyStdSet> const pstdset3 = ::boost::movelib::make_unique<MyStdSet>
MyBoostMultiSet *boostmultiset3 = new MyBoostMultiSet (&aux_vect2[0], &aux_vect2[0] + 50);
::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset3 = ::boost::movelib::make_unique<MyBoostMultiSet>
( ordered_range ( ordered_range
, boost::make_move_iterator(&aux_vect3[0]) , boost::make_move_iterator(&aux_vect3[0])
, boost::make_move_iterator(aux_vect3 + 50)); , boost::make_move_iterator(aux_vect3 + 50));
MyStdMultiSet *stdmultiset3 = new MyStdMultiSet(aux_vect2, aux_vect2 + 50); ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset3 = ::boost::movelib::make_unique<MyStdMultiSet>
(&aux_vect2[0], &aux_vect2[0] + 50);
MyBoostSet &boostset3 = *pboostset3;
MyStdSet &stdset3 = *pstdset3;
MyBoostMultiSet &boostmultiset3 = *pboostmultiset3;
MyStdMultiSet &stdmultiset3 = *pstdmultiset3;
if(!CheckEqualContainers(boostset3, stdset3)){ if(!CheckEqualContainers(boostset3, stdset3)){
std::cout << "Error in construct<MyBoostSet>(MyBoostSet3)" << std::endl; std::cout << "Error in construct<MyBoostSet>(MyBoostSet3)" << std::endl;
@@ -196,67 +216,58 @@ int set_test ()
std::cout << "Error in construct<MyBoostMultiSet>(MyBoostMultiSet3)" << std::endl; std::cout << "Error in construct<MyBoostMultiSet>(MyBoostMultiSet3)" << std::endl;
return 1; return 1;
} }
delete boostset2;
delete boostmultiset2;
delete stdset2;
delete stdmultiset2;
delete boostset3;
delete boostmultiset3;
delete stdset3;
delete stdmultiset3;
} }
for(int i = 0; i < max; ++i){ for(int i = 0; i < max; ++i){
IntType move_me(i); IntType move_me(i);
boostset->insert(boost::move(move_me)); boostset.insert(boost::move(move_me));
stdset->insert(i); stdset.insert(i);
boostset->insert(IntType(i)); boostset.insert(IntType(i));
stdset->insert(i); stdset.insert(i);
IntType move_me2(i); IntType move_me2(i);
boostmultiset->insert(boost::move(move_me2)); boostmultiset.insert(boost::move(move_me2));
stdmultiset->insert(i); stdmultiset.insert(i);
boostmultiset->insert(IntType(i)); boostmultiset.insert(IntType(i));
stdmultiset->insert(i); stdmultiset.insert(i);
} }
if(!CheckEqualContainers(boostset, stdset)){ if(!CheckEqualContainers(boostset, stdset)){
std::cout << "Error in boostset->insert(boost::move(move_me)" << std::endl; std::cout << "Error in boostset.insert(boost::move(move_me)" << std::endl;
return 1; return 1;
} }
if(!CheckEqualContainers(boostmultiset, stdmultiset)){ if(!CheckEqualContainers(boostmultiset, stdmultiset)){
std::cout << "Error in boostmultiset->insert(boost::move(move_me)" << std::endl; std::cout << "Error in boostmultiset.insert(boost::move(move_me)" << std::endl;
return 1; return 1;
} }
typename MyBoostSet::iterator it = boostset->begin(); typename MyBoostSet::iterator it = boostset.begin();
typename MyBoostSet::const_iterator cit = it; typename MyBoostSet::const_iterator cit = it;
(void)cit; (void)cit;
boostset->erase(boostset->begin()); boostset.erase(boostset.begin());
stdset->erase(stdset->begin()); stdset.erase(stdset.begin());
boostmultiset->erase(boostmultiset->begin()); boostmultiset.erase(boostmultiset.begin());
stdmultiset->erase(stdmultiset->begin()); stdmultiset.erase(stdmultiset.begin());
if(!CheckEqualContainers(boostset, stdset)){ if(!CheckEqualContainers(boostset, stdset)){
std::cout << "Error in boostset->erase(boostset->begin())" << std::endl; std::cout << "Error in boostset.erase(boostset.begin())" << std::endl;
return 1; return 1;
} }
if(!CheckEqualContainers(boostmultiset, stdmultiset)){ if(!CheckEqualContainers(boostmultiset, stdmultiset)){
std::cout << "Error in boostmultiset->erase(boostmultiset->begin())" << std::endl; std::cout << "Error in boostmultiset.erase(boostmultiset.begin())" << std::endl;
return 1; return 1;
} }
boostset->erase(boostset->begin()); boostset.erase(boostset.begin());
stdset->erase(stdset->begin()); stdset.erase(stdset.begin());
boostmultiset->erase(boostmultiset->begin()); boostmultiset.erase(boostmultiset.begin());
stdmultiset->erase(stdmultiset->begin()); stdmultiset.erase(stdmultiset.begin());
if(!CheckEqualContainers(boostset, stdset)){ if(!CheckEqualContainers(boostset, stdset)){
std::cout << "Error in boostset->erase(boostset->begin())" << std::endl; std::cout << "Error in boostset.erase(boostset.begin())" << std::endl;
return 1; return 1;
} }
if(!CheckEqualContainers(boostmultiset, stdmultiset)){ if(!CheckEqualContainers(boostmultiset, stdmultiset)){
std::cout << "Error in boostmultiset->erase(boostmultiset->begin())" << std::endl; std::cout << "Error in boostmultiset.erase(boostmultiset.begin())" << std::endl;
return 1; return 1;
} }
@@ -265,20 +276,20 @@ int set_test ()
MyStdSet tmpstdset2; MyStdSet tmpstdset2;
MyBoostMultiSet tmpboostemultiset2; MyBoostMultiSet tmpboostemultiset2;
MyStdMultiSet tmpstdmultiset2; MyStdMultiSet tmpstdmultiset2;
boostset->swap(tmpboosteset2); boostset.swap(tmpboosteset2);
stdset->swap(tmpstdset2); stdset.swap(tmpstdset2);
boostmultiset->swap(tmpboostemultiset2); boostmultiset.swap(tmpboostemultiset2);
stdmultiset->swap(tmpstdmultiset2); stdmultiset.swap(tmpstdmultiset2);
boostset->swap(tmpboosteset2); boostset.swap(tmpboosteset2);
stdset->swap(tmpstdset2); stdset.swap(tmpstdset2);
boostmultiset->swap(tmpboostemultiset2); boostmultiset.swap(tmpboostemultiset2);
stdmultiset->swap(tmpstdmultiset2); stdmultiset.swap(tmpstdmultiset2);
if(!CheckEqualContainers(boostset, stdset)){ if(!CheckEqualContainers(boostset, stdset)){
std::cout << "Error in boostset->swap(tmpboosteset2)" << std::endl; std::cout << "Error in boostset.swap(tmpboosteset2)" << std::endl;
return 1; return 1;
} }
if(!CheckEqualContainers(boostmultiset, stdmultiset)){ if(!CheckEqualContainers(boostmultiset, stdmultiset)){
std::cout << "Error in boostmultiset->swap(tmpboostemultiset2)" << std::endl; std::cout << "Error in boostmultiset.swap(tmpboostemultiset2)" << std::endl;
return 1; return 1;
} }
@@ -300,31 +311,31 @@ int set_test ()
aux_vect3[i] = boost::move(move_me); aux_vect3[i] = boost::move(move_me);
} }
boostset->insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(aux_vect + 50)); boostset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + 50));
stdset->insert(aux_vect2, aux_vect2 + 50); stdset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
boostmultiset->insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(aux_vect3 + 50)); boostmultiset.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(aux_vect3 + 50));
stdmultiset->insert(aux_vect2, aux_vect2 + 50); stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
if(!CheckEqualContainers(boostset, stdset)){ if(!CheckEqualContainers(boostset, stdset)){
std::cout << "Error in boostset->insert(boost::make_move_iterator(&aux_vect[0])..." << std::endl; std::cout << "Error in boostset.insert(boost::make_move_iterator(&aux_vect[0])..." << std::endl;
return 1; return 1;
} }
if(!CheckEqualContainers(boostmultiset, stdmultiset)){ if(!CheckEqualContainers(boostmultiset, stdmultiset)){
std::cout << "Error in boostmultiset->insert(boost::make_move_iterator(&aux_vect3[0]), ..." << std::endl; std::cout << "Error in boostmultiset.insert(boost::make_move_iterator(&aux_vect3[0]), ..." << std::endl;
return 1; return 1;
} }
for(int i = 0, j = static_cast<int>(boostset->size()); i < j; ++i){ for(int i = 0, j = static_cast<int>(boostset.size()); i < j; ++i){
IntType erase_me(i); IntType erase_me(i);
boostset->erase(erase_me); boostset.erase(erase_me);
stdset->erase(i); stdset.erase(i);
boostmultiset->erase(erase_me); boostmultiset.erase(erase_me);
stdmultiset->erase(i); stdmultiset.erase(i);
if(!CheckEqualContainers(boostset, stdset)){ if(!CheckEqualContainers(boostset, stdset)){
std::cout << "Error in boostset->erase(erase_me)" << boostset->size() << " " << stdset->size() << std::endl; std::cout << "Error in boostset.erase(erase_me)" << boostset.size() << " " << stdset.size() << std::endl;
return 1; return 1;
} }
if(!CheckEqualContainers(boostmultiset, stdmultiset)){ if(!CheckEqualContainers(boostmultiset, stdmultiset)){
std::cout << "Error in boostmultiset->erase(erase_me)" << std::endl; std::cout << "Error in boostmultiset.erase(erase_me)" << std::endl;
return 1; return 1;
} }
} }
@@ -357,104 +368,104 @@ int set_test ()
aux_vect5[i] = boost::move(move_me); aux_vect5[i] = boost::move(move_me);
} }
boostset->insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(aux_vect + 50)); boostset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + 50));
boostset->insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(aux_vect3 + 50)); boostset.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0] + 50));
stdset->insert(aux_vect2, aux_vect2 + 50); stdset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
stdset->insert(aux_vect2, aux_vect2 + 50); stdset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
boostmultiset->insert(boost::make_move_iterator(&aux_vect4[0]), boost::make_move_iterator(aux_vect4 + 50)); boostmultiset.insert(boost::make_move_iterator(&aux_vect4[0]), boost::make_move_iterator(&aux_vect4[0] + 50));
boostmultiset->insert(boost::make_move_iterator(&aux_vect5[0]), boost::make_move_iterator(aux_vect5 + 50)); boostmultiset.insert(boost::make_move_iterator(&aux_vect5[0]), boost::make_move_iterator(&aux_vect5[0] + 50));
stdmultiset->insert(aux_vect2, aux_vect2 + 50); stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
stdmultiset->insert(aux_vect2, aux_vect2 + 50); stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
if(!CheckEqualContainers(boostset, stdset)){ if(!CheckEqualContainers(boostset, stdset)){
std::cout << "Error in boostset->insert(boost::make_move_iterator(&aux_vect3[0])..." << std::endl; std::cout << "Error in boostset.insert(boost::make_move_iterator(&aux_vect3[0])..." << std::endl;
return 1; return 1;
} }
if(!CheckEqualContainers(boostmultiset, stdmultiset)){ if(!CheckEqualContainers(boostmultiset, stdmultiset)){
std::cout << "Error in boostmultiset->insert(boost::make_move_iterator(&aux_vect5[0])..." << std::endl; std::cout << "Error in boostmultiset.insert(boost::make_move_iterator(&aux_vect5[0])..." << std::endl;
return 1; return 1;
} }
boostset->erase(*boostset->begin()); boostset.erase(*boostset.begin());
stdset->erase(*stdset->begin()); stdset.erase(*stdset.begin());
boostmultiset->erase(*boostmultiset->begin()); boostmultiset.erase(*boostmultiset.begin());
stdmultiset->erase(*stdmultiset->begin()); stdmultiset.erase(*stdmultiset.begin());
if(!CheckEqualContainers(boostset, stdset)){ if(!CheckEqualContainers(boostset, stdset)){
std::cout << "Error in boostset->erase(*boostset->begin())" << std::endl; std::cout << "Error in boostset.erase(*boostset.begin())" << std::endl;
return 1; return 1;
} }
if(!CheckEqualContainers(boostmultiset, stdmultiset)){ if(!CheckEqualContainers(boostmultiset, stdmultiset)){
std::cout << "Error in boostmultiset->erase(*boostmultiset->begin())" << std::endl; std::cout << "Error in boostmultiset.erase(*boostmultiset.begin())" << std::endl;
return 1; return 1;
} }
} }
for(int i = 0; i < max; ++i){ for(int i = 0; i < max; ++i){
IntType move_me(i); IntType move_me(i);
boostset->insert(boost::move(move_me)); boostset.insert(boost::move(move_me));
stdset->insert(i); stdset.insert(i);
IntType move_me2(i); IntType move_me2(i);
boostmultiset->insert(boost::move(move_me2)); boostmultiset.insert(boost::move(move_me2));
stdmultiset->insert(i); stdmultiset.insert(i);
} }
if(!CheckEqualContainers(boostset, stdset)){ if(!CheckEqualContainers(boostset, stdset)){
std::cout << "Error in boostset->insert(boost::move(move_me)) try 2" << std::endl; std::cout << "Error in boostset.insert(boost::move(move_me)) try 2" << std::endl;
return 1; return 1;
} }
if(!CheckEqualContainers(boostmultiset, stdmultiset)){ if(!CheckEqualContainers(boostmultiset, stdmultiset)){
std::cout << "Error in boostmultiset->insert(boost::move(move_me2)) try 2" << std::endl; std::cout << "Error in boostmultiset.insert(boost::move(move_me2)) try 2" << std::endl;
return 1; return 1;
} }
for(int i = 0; i < max; ++i){ for(int i = 0; i < max; ++i){
{ {
IntType move_me(i); IntType move_me(i);
boostset->insert(boostset->begin(), boost::move(move_me)); boostset.insert(boostset.begin(), boost::move(move_me));
stdset->insert(stdset->begin(), i); stdset.insert(stdset.begin(), i);
//PrintContainers(boostset, stdset); //PrintContainers(boostset, stdset);
IntType move_me2(i); IntType move_me2(i);
boostmultiset->insert(boostmultiset->begin(), boost::move(move_me2)); boostmultiset.insert(boostmultiset.begin(), boost::move(move_me2));
stdmultiset->insert(stdmultiset->begin(), i); stdmultiset.insert(stdmultiset.begin(), i);
//PrintContainers(boostmultiset, stdmultiset); //PrintContainers(boostmultiset, stdmultiset);
if(!CheckEqualContainers(boostset, stdset)){ if(!CheckEqualContainers(boostset, stdset)){
std::cout << "Error in boostset->insert(boostset->begin(), boost::move(move_me))" << std::endl; std::cout << "Error in boostset.insert(boostset.begin(), boost::move(move_me))" << std::endl;
return 1; return 1;
} }
if(!CheckEqualContainers(boostmultiset, stdmultiset)){ if(!CheckEqualContainers(boostmultiset, stdmultiset)){
std::cout << "Error in boostmultiset->insert(boostmultiset->begin(), boost::move(move_me2))" << std::endl; std::cout << "Error in boostmultiset.insert(boostmultiset.begin(), boost::move(move_me2))" << std::endl;
return 1; return 1;
} }
IntType move_me3(i); IntType move_me3(i);
boostset->insert(boostset->end(), boost::move(move_me3)); boostset.insert(boostset.end(), boost::move(move_me3));
stdset->insert(stdset->end(), i); stdset.insert(stdset.end(), i);
IntType move_me4(i); IntType move_me4(i);
boostmultiset->insert(boostmultiset->end(), boost::move(move_me4)); boostmultiset.insert(boostmultiset.end(), boost::move(move_me4));
stdmultiset->insert(stdmultiset->end(), i); stdmultiset.insert(stdmultiset.end(), i);
if(!CheckEqualContainers(boostset, stdset)){ if(!CheckEqualContainers(boostset, stdset)){
std::cout << "Error in boostset->insert(boostset->end(), boost::move(move_me3))" << std::endl; std::cout << "Error in boostset.insert(boostset.end(), boost::move(move_me3))" << std::endl;
return 1; return 1;
} }
if(!CheckEqualContainers(boostmultiset, stdmultiset)){ if(!CheckEqualContainers(boostmultiset, stdmultiset)){
std::cout << "Error in boostmultiset->insert(boostmultiset->end(), boost::move(move_me4))" << std::endl; std::cout << "Error in boostmultiset.insert(boostmultiset.end(), boost::move(move_me4))" << std::endl;
return 1; return 1;
} }
} }
{ {
IntType move_me(i); IntType move_me(i);
boostset->insert(boostset->upper_bound(move_me), boost::move(move_me)); boostset.insert(boostset.upper_bound(move_me), boost::move(move_me));
stdset->insert(stdset->upper_bound(i), i); stdset.insert(stdset.upper_bound(i), i);
//PrintContainers(boostset, stdset); //PrintContainers(boostset, stdset);
IntType move_me2(i); IntType move_me2(i);
boostmultiset->insert(boostmultiset->upper_bound(move_me2), boost::move(move_me2)); boostmultiset.insert(boostmultiset.upper_bound(move_me2), boost::move(move_me2));
stdmultiset->insert(stdmultiset->upper_bound(i), i); stdmultiset.insert(stdmultiset.upper_bound(i), i);
//PrintContainers(boostmultiset, stdmultiset); //PrintContainers(boostmultiset, stdmultiset);
if(!CheckEqualContainers(boostset, stdset)){ if(!CheckEqualContainers(boostset, stdset)){
std::cout << "Error in boostset->insert(boostset->upper_bound(move_me), boost::move(move_me))" << std::endl; std::cout << "Error in boostset.insert(boostset.upper_bound(move_me), boost::move(move_me))" << std::endl;
return 1; return 1;
} }
if(!CheckEqualContainers(boostmultiset, stdmultiset)){ if(!CheckEqualContainers(boostmultiset, stdmultiset)){
std::cout << "Error in boostmultiset->insert(boostmultiset->upper_bound(move_me2), boost::move(move_me2))" << std::endl; std::cout << "Error in boostmultiset.insert(boostmultiset.upper_bound(move_me2), boost::move(move_me2))" << std::endl;
return 1; return 1;
} }
@@ -462,31 +473,31 @@ int set_test ()
{ {
IntType move_me(i); IntType move_me(i);
IntType move_me2(i); IntType move_me2(i);
boostset->insert(boostset->lower_bound(move_me), boost::move(move_me2)); boostset.insert(boostset.lower_bound(move_me), boost::move(move_me2));
stdset->insert(stdset->lower_bound(i), i); stdset.insert(stdset.lower_bound(i), i);
//PrintContainers(boostset, stdset); //PrintContainers(boostset, stdset);
move_me2 = i; move_me2 = i;
boostmultiset->insert(boostmultiset->lower_bound(move_me2), boost::move(move_me2)); boostmultiset.insert(boostmultiset.lower_bound(move_me2), boost::move(move_me2));
stdmultiset->insert(stdmultiset->lower_bound(i), i); stdmultiset.insert(stdmultiset.lower_bound(i), i);
//PrintContainers(boostmultiset, stdmultiset); //PrintContainers(boostmultiset, stdmultiset);
if(!CheckEqualContainers(boostset, stdset)){ if(!CheckEqualContainers(boostset, stdset)){
std::cout << "Error in boostset->insert(boostset->lower_bound(move_me), boost::move(move_me2))" << std::endl; std::cout << "Error in boostset.insert(boostset.lower_bound(move_me), boost::move(move_me2))" << std::endl;
return 1; return 1;
} }
if(!CheckEqualContainers(boostmultiset, stdmultiset)){ if(!CheckEqualContainers(boostmultiset, stdmultiset)){
std::cout << "Error in boostmultiset->insert(boostmultiset->lower_bound(move_me2), boost::move(move_me2))" << std::endl; std::cout << "Error in boostmultiset.insert(boostmultiset.lower_bound(move_me2), boost::move(move_me2))" << std::endl;
return 1; return 1;
} }
set_test_rebalanceable(*boostset set_test_rebalanceable(boostset
, container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostSet>::value>()); , container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostSet>::value>());
if(!CheckEqualContainers(boostset, stdset)){ if(!CheckEqualContainers(boostset, stdset)){
std::cout << "Error in boostset->rebalance()" << std::endl; std::cout << "Error in boostset.rebalance()" << std::endl;
return 1; return 1;
} }
set_test_rebalanceable(*boostmultiset set_test_rebalanceable(boostmultiset
, container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostMultiSet>::value>()); , container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostMultiSet>::value>());
if(!CheckEqualContainers(boostmultiset, stdmultiset)){ if(!CheckEqualContainers(boostmultiset, stdmultiset)){
std::cout << "Error in boostmultiset->rebalance()" << std::endl; std::cout << "Error in boostmultiset.rebalance()" << std::endl;
return 1; return 1;
} }
} }
@@ -495,19 +506,19 @@ int set_test ()
//Compare count with std containers //Compare count with std containers
for(int i = 0; i < max; ++i){ for(int i = 0; i < max; ++i){
IntType count_me(i); IntType count_me(i);
if(boostset->count(count_me) != stdset->count(i)){ if(boostset.count(count_me) != stdset.count(i)){
return -1; return -1;
} }
if(boostmultiset->count(count_me) != stdmultiset->count(i)){ if(boostmultiset.count(count_me) != stdmultiset.count(i)){
return -1; return -1;
} }
} }
//Compare find/lower_bound/upper_bound in set //Compare find/lower_bound/upper_bound in set
{ {
typename MyBoostSet::iterator bs_b = boostset->begin(); typename MyBoostSet::iterator bs_b = boostset.begin();
typename MyBoostSet::iterator bs_e = boostset->end(); typename MyBoostSet::iterator bs_e = boostset.end();
typename MyStdSet::iterator ss_b = stdset->begin(); typename MyStdSet::iterator ss_b = stdset.begin();
std::size_t i = 0; std::size_t i = 0;
while(bs_b != bs_e){ while(bs_b != bs_e){
@@ -515,21 +526,21 @@ int set_test ()
typename MyBoostSet::iterator bs_i; typename MyBoostSet::iterator bs_i;
typename MyStdSet::iterator ss_i; typename MyStdSet::iterator ss_i;
//find //find
bs_i = boostset->find(*bs_b); bs_i = boostset.find(*bs_b);
ss_i = stdset->find(*ss_b); ss_i = stdset.find(*ss_b);
if(!CheckEqualIt(bs_i, ss_i, *boostset, *stdset)){ if(!CheckEqualIt(bs_i, ss_i, boostset, stdset)){
return -1; return -1;
} }
//lower bound //lower bound
bs_i = boostset->lower_bound(*bs_b); bs_i = boostset.lower_bound(*bs_b);
ss_i = stdset->lower_bound(*ss_b); ss_i = stdset.lower_bound(*ss_b);
if(!CheckEqualIt(bs_i, ss_i, *boostset, *stdset)){ if(!CheckEqualIt(bs_i, ss_i, boostset, stdset)){
return -1; return -1;
} }
//upper bound //upper bound
bs_i = boostset->upper_bound(*bs_b); bs_i = boostset.upper_bound(*bs_b);
ss_i = stdset->upper_bound(*ss_b); ss_i = stdset.upper_bound(*ss_b);
if(!CheckEqualIt(bs_i, ss_i, *boostset, *stdset)){ if(!CheckEqualIt(bs_i, ss_i, boostset, stdset)){
return -1; return -1;
} }
//equal range //equal range
@@ -537,12 +548,12 @@ int set_test ()
,typename MyBoostSet::iterator> bs_ip; ,typename MyBoostSet::iterator> bs_ip;
std::pair<typename MyStdSet::iterator std::pair<typename MyStdSet::iterator
,typename MyStdSet::iterator> ss_ip; ,typename MyStdSet::iterator> ss_ip;
bs_ip = boostset->equal_range(*bs_b); bs_ip = boostset.equal_range(*bs_b);
ss_ip = stdset->equal_range(*ss_b); ss_ip = stdset.equal_range(*ss_b);
if(!CheckEqualIt(bs_ip.first, ss_ip.first, *boostset, *stdset)){ if(!CheckEqualIt(bs_ip.first, ss_ip.first, boostset, stdset)){
return -1; return -1;
} }
if(!CheckEqualIt(bs_ip.second, ss_ip.second, *boostset, *stdset)){ if(!CheckEqualIt(bs_ip.second, ss_ip.second, boostset, stdset)){
return -1; return -1;
} }
++bs_b; ++bs_b;
@@ -551,29 +562,29 @@ int set_test ()
} }
//Compare find/lower_bound/upper_bound in multiset //Compare find/lower_bound/upper_bound in multiset
{ {
typename MyBoostMultiSet::iterator bm_b = boostmultiset->begin(); typename MyBoostMultiSet::iterator bm_b = boostmultiset.begin();
typename MyBoostMultiSet::iterator bm_e = boostmultiset->end(); typename MyBoostMultiSet::iterator bm_e = boostmultiset.end();
typename MyStdMultiSet::iterator sm_b = stdmultiset->begin(); typename MyStdMultiSet::iterator sm_b = stdmultiset.begin();
while(bm_b != bm_e){ while(bm_b != bm_e){
typename MyBoostMultiSet::iterator bm_i; typename MyBoostMultiSet::iterator bm_i;
typename MyStdMultiSet::iterator sm_i; typename MyStdMultiSet::iterator sm_i;
//find //find
bm_i = boostmultiset->find(*bm_b); bm_i = boostmultiset.find(*bm_b);
sm_i = stdmultiset->find(*sm_b); sm_i = stdmultiset.find(*sm_b);
if(!CheckEqualIt(bm_i, sm_i, *boostmultiset, *stdmultiset)){ if(!CheckEqualIt(bm_i, sm_i, boostmultiset, stdmultiset)){
return -1; return -1;
} }
//lower bound //lower bound
bm_i = boostmultiset->lower_bound(*bm_b); bm_i = boostmultiset.lower_bound(*bm_b);
sm_i = stdmultiset->lower_bound(*sm_b); sm_i = stdmultiset.lower_bound(*sm_b);
if(!CheckEqualIt(bm_i, sm_i, *boostmultiset, *stdmultiset)){ if(!CheckEqualIt(bm_i, sm_i, boostmultiset, stdmultiset)){
return -1; return -1;
} }
//upper bound //upper bound
bm_i = boostmultiset->upper_bound(*bm_b); bm_i = boostmultiset.upper_bound(*bm_b);
sm_i = stdmultiset->upper_bound(*sm_b); sm_i = stdmultiset.upper_bound(*sm_b);
if(!CheckEqualIt(bm_i, sm_i, *boostmultiset, *stdmultiset)){ if(!CheckEqualIt(bm_i, sm_i, boostmultiset, stdmultiset)){
return -1; return -1;
} }
//equal range //equal range
@@ -581,12 +592,12 @@ int set_test ()
,typename MyBoostMultiSet::iterator> bm_ip; ,typename MyBoostMultiSet::iterator> bm_ip;
std::pair<typename MyStdMultiSet::iterator std::pair<typename MyStdMultiSet::iterator
,typename MyStdMultiSet::iterator> sm_ip; ,typename MyStdMultiSet::iterator> sm_ip;
bm_ip = boostmultiset->equal_range(*bm_b); bm_ip = boostmultiset.equal_range(*bm_b);
sm_ip = stdmultiset->equal_range(*sm_b); sm_ip = stdmultiset.equal_range(*sm_b);
if(!CheckEqualIt(bm_ip.first, sm_ip.first, *boostmultiset, *stdmultiset)){ if(!CheckEqualIt(bm_ip.first, sm_ip.first, boostmultiset, stdmultiset)){
return -1; return -1;
} }
if(!CheckEqualIt(bm_ip.second, sm_ip.second, *boostmultiset, *stdmultiset)){ if(!CheckEqualIt(bm_ip.second, sm_ip.second, boostmultiset, stdmultiset)){
return -1; return -1;
} }
++bm_b; ++bm_b;
@@ -595,33 +606,28 @@ int set_test ()
} }
//Now do count exercise //Now do count exercise
boostset->erase(boostset->begin(), boostset->end()); boostset.erase(boostset.begin(), boostset.end());
boostmultiset->erase(boostmultiset->begin(), boostmultiset->end()); boostmultiset.erase(boostmultiset.begin(), boostmultiset.end());
boostset->clear(); boostset.clear();
boostmultiset->clear(); boostmultiset.clear();
for(int j = 0; j < 3; ++j) for(int j = 0; j < 3; ++j)
for(int i = 0; i < 100; ++i){ for(int i = 0; i < 100; ++i){
IntType move_me(i); IntType move_me(i);
boostset->insert(boost::move(move_me)); boostset.insert(boost::move(move_me));
IntType move_me2(i); IntType move_me2(i);
boostmultiset->insert(boost::move(move_me2)); boostmultiset.insert(boost::move(move_me2));
IntType count_me(i); IntType count_me(i);
if(boostset->count(count_me) != typename MyBoostMultiSet::size_type(1)){ if(boostset.count(count_me) != typename MyBoostMultiSet::size_type(1)){
std::cout << "Error in boostset->count(count_me)" << std::endl; std::cout << "Error in boostset.count(count_me)" << std::endl;
return 1; return 1;
} }
if(boostmultiset->count(count_me) != typename MyBoostMultiSet::size_type(j+1)){ if(boostmultiset.count(count_me) != typename MyBoostMultiSet::size_type(j+1)){
std::cout << "Error in boostmultiset->count(count_me)" << std::endl; std::cout << "Error in boostmultiset.count(count_me)" << std::endl;
return 1; return 1;
} }
} }
delete boostset;
delete stdset;
delete boostmultiset;
delete stdmultiset;
if(set_test_copyable<MyBoostSet, MyStdSet, MyBoostMultiSet, MyStdMultiSet> if(set_test_copyable<MyBoostSet, MyStdSet, MyBoostMultiSet, MyStdMultiSet>
(container_detail::bool_<boost::container::test::is_copyable<IntType>::value>())){ (container_detail::bool_<boost::container::test::is_copyable<IntType>::value>())){
return 1; return 1;

View File

@@ -81,27 +81,15 @@ int test_expand_bwd()
int_allocator_type; int_allocator_type;
typedef vector<int, int_allocator_type> typedef vector<int, int_allocator_type>
int_vector; int_vector;
if(!test::test_all_expand_bwd<int_vector>()) if(!test::test_all_expand_bwd<int_vector>())
return 1; return 1;
//Now user defined wrapped int //Now user defined copyable int
typedef test::expand_bwd_test_allocator<test::int_holder> typedef test::expand_bwd_test_allocator<test::copyable_int>
int_holder_allocator_type; copyable_int_allocator_type;
typedef vector<test::int_holder, int_holder_allocator_type> typedef vector<test::copyable_int, copyable_int_allocator_type>
int_holder_vector; copyable_int_vector;
if(!test::test_all_expand_bwd<copyable_int_vector>())
if(!test::test_all_expand_bwd<int_holder_vector>())
return 1;
//Now user defined bigger wrapped int
typedef test::expand_bwd_test_allocator<test::triple_int_holder>
triple_int_holder_allocator_type;
typedef vector<test::triple_int_holder, triple_int_holder_allocator_type>
triple_int_holder_vector;
if(!test::test_all_expand_bwd<triple_int_holder_vector>())
return 1; return 1;
return 0; return 0;

View File

@@ -30,6 +30,7 @@
#include "input_from_forward_iterator.hpp" #include "input_from_forward_iterator.hpp"
#include <boost/move/utility_core.hpp> #include <boost/move/utility_core.hpp>
#include <boost/move/iterator.hpp> #include <boost/move/iterator.hpp>
#include <boost/move/make_unique.hpp>
#include <boost/core/no_exceptions_support.hpp> #include <boost/core/no_exceptions_support.hpp>
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
#include "insert_test.hpp" #include "insert_test.hpp"
@@ -39,59 +40,61 @@ namespace container {
namespace test{ namespace test{
template<class V1, class V2> template<class V1, class V2>
bool vector_copyable_only(V1 *, V2 *, boost::container::container_detail::false_type) bool vector_copyable_only(V1&, V2&, boost::container::container_detail::false_type)
{ {
return true; return true;
} }
//Function to check if both sets are equal //Function to check if both sets are equal
template<class V1, class V2> template<class V1, class V2>
bool vector_copyable_only(V1 *boostvector, V2 *stdvector, boost::container::container_detail::true_type) bool vector_copyable_only(V1 &boostvector, V2 &stdvector, boost::container::container_detail::true_type)
{ {
typedef typename V1::value_type IntType; typedef typename V1::value_type IntType;
std::size_t size = boostvector->size(); std::size_t size = boostvector.size();
boostvector->insert(boostvector->end(), 50, IntType(1)); boostvector.insert(boostvector.end(), 50, IntType(1));
stdvector->insert(stdvector->end(), 50, 1); stdvector.insert(stdvector.end(), 50, 1);
if(!test::CheckEqualContainers(boostvector, stdvector)) return false; if(!test::CheckEqualContainers(boostvector, stdvector)) return false;
{ {
IntType move_me(1); IntType move_me(1);
boostvector->insert(boostvector->begin()+size/2, 50, boost::move(move_me)); boostvector.insert(boostvector.begin()+size/2, 50, boost::move(move_me));
stdvector->insert(stdvector->begin()+size/2, 50, 1); stdvector.insert(stdvector.begin()+size/2, 50, 1);
if(!test::CheckEqualContainers(boostvector, stdvector)) return false; if(!test::CheckEqualContainers(boostvector, stdvector)) return false;
} }
{ {
IntType move_me(2); IntType move_me(2);
boostvector->assign(boostvector->size()/2, boost::move(move_me)); boostvector.assign(boostvector.size()/2, boost::move(move_me));
stdvector->assign(stdvector->size()/2, 2); stdvector.assign(stdvector.size()/2, 2);
if(!test::CheckEqualContainers(boostvector, stdvector)) return false; if(!test::CheckEqualContainers(boostvector, stdvector)) return false;
} }
{ {
IntType move_me(3); IntType move_me(3);
boostvector->assign(boostvector->size()*3-1, boost::move(move_me)); boostvector.assign(boostvector.size()*3-1, boost::move(move_me));
stdvector->assign(stdvector->size()*3-1, 3); stdvector.assign(stdvector.size()*3-1, 3);
if(!test::CheckEqualContainers(boostvector, stdvector)) return false; if(!test::CheckEqualContainers(boostvector, stdvector)) return false;
} }
{ {
IntType copy_me(3); IntType copy_me(3);
const IntType ccopy_me(3); const IntType ccopy_me(3);
boostvector->push_back(copy_me); boostvector.push_back(copy_me);
stdvector->push_back(int(3)); stdvector.push_back(int(3));
boostvector->push_back(ccopy_me); boostvector.push_back(ccopy_me);
stdvector->push_back(int(3)); stdvector.push_back(int(3));
if(!test::CheckEqualContainers(boostvector, stdvector)) return false; if(!test::CheckEqualContainers(boostvector, stdvector)) return false;
} }
{ {
V1 *pv1 = new V1(*boostvector); ::boost::movelib::unique_ptr<V1> const pv1 = ::boost::movelib::make_unique<V1>(boostvector);
V2 *pv2 = new V2(*stdvector); ::boost::movelib::unique_ptr<V2> const pv2 = ::boost::movelib::make_unique<V2>(stdvector);
boostvector->clear();
stdvector->clear(); V1 &v1 = *pv1;
boostvector->assign(pv1->begin(), pv1->end()); V2 &v2 = *pv2;
stdvector->assign(pv2->begin(), pv2->end());
boostvector.clear();
stdvector.clear();
boostvector.assign(v1.begin(), v1.end());
stdvector.assign(v2.begin(), v2.end());
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
delete pv1;
delete pv2;
} }
return true; return true;
@@ -109,40 +112,43 @@ int vector_test()
} }
{ {
BOOST_TRY{ ::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp = ::boost::movelib::make_unique<MyBoostVector>();
MyBoostVector *boostvector = new MyBoostVector; ::boost::movelib::unique_ptr<MyStdVector> const stdvectorp = ::boost::movelib::make_unique<MyStdVector>();
MyStdVector *stdvector = new MyStdVector;
boostvector->resize(100); MyBoostVector & boostvector = *boostvectorp;
stdvector->resize(100); MyStdVector & stdvector = *stdvectorp;
boostvector.resize(100);
stdvector.resize(100);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
boostvector->resize(200); boostvector.resize(200);
stdvector->resize(200); stdvector.resize(200);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
boostvector->resize(0); boostvector.resize(0);
stdvector->resize(0); stdvector.resize(0);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
for(int i = 0; i < max; ++i){ for(int i = 0; i < max; ++i){
IntType new_int(i); IntType new_int(i);
boostvector->insert(boostvector->end(), boost::move(new_int)); boostvector.insert(boostvector.end(), boost::move(new_int));
stdvector->insert(stdvector->end(), i); stdvector.insert(stdvector.end(), i);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
} }
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
typename MyBoostVector::iterator boostit(boostvector->begin()); typename MyBoostVector::iterator boostit(boostvector.begin());
typename MyStdVector::iterator stdit(stdvector->begin()); typename MyStdVector::iterator stdit(stdvector.begin());
typename MyBoostVector::const_iterator cboostit = boostit; typename MyBoostVector::const_iterator cboostit = boostit;
(void)cboostit; (void)cboostit;
++boostit; ++stdit; ++boostit; ++stdit;
boostvector->erase(boostit); boostvector.erase(boostit);
stdvector->erase(stdit); stdvector.erase(stdit);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
boostvector->erase(boostvector->begin()); boostvector.erase(boostvector.begin());
stdvector->erase(stdvector->begin()); stdvector.erase(stdvector.begin());
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
{ {
@@ -158,22 +164,22 @@ int vector_test()
aux_vect2[i] = -1; aux_vect2[i] = -1;
} }
typename MyBoostVector::iterator insert_it = typename MyBoostVector::iterator insert_it =
boostvector->insert(boostvector->end() boostvector.insert(boostvector.end()
,boost::make_move_iterator(&aux_vect[0]) ,boost::make_move_iterator(&aux_vect[0])
,boost::make_move_iterator(aux_vect + 50)); ,boost::make_move_iterator(aux_vect + 50));
if(std::size_t(std::distance(insert_it, boostvector->end())) != 50) return 1; if(std::size_t(std::distance(insert_it, boostvector.end())) != 50) return 1;
stdvector->insert(stdvector->end(), aux_vect2, aux_vect2 + 50); stdvector.insert(stdvector.end(), aux_vect2, aux_vect2 + 50);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
for(int i = 0, j = static_cast<int>(boostvector->size()); i < j; ++i){ for(int i = 0, j = static_cast<int>(boostvector.size()); i < j; ++i){
boostvector->erase(boostvector->begin()); boostvector.erase(boostvector.begin());
stdvector->erase(stdvector->begin()); stdvector.erase(stdvector.begin());
} }
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
} }
{ {
boostvector->resize(100); boostvector.resize(100);
stdvector->resize(100); stdvector.resize(100);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
IntType aux_vect[50]; IntType aux_vect[50];
@@ -185,13 +191,13 @@ int vector_test()
for(int i = 0; i < 50; ++i){ for(int i = 0; i < 50; ++i){
aux_vect2[i] = -i; aux_vect2[i] = -i;
} }
typename MyBoostVector::size_type old_size = boostvector->size(); typename MyBoostVector::size_type old_size = boostvector.size();
typename MyBoostVector::iterator insert_it = typename MyBoostVector::iterator insert_it =
boostvector->insert(boostvector->begin() + old_size/2 boostvector.insert(boostvector.begin() + old_size/2
,boost::make_move_iterator(&aux_vect[0]) ,boost::make_move_iterator(&aux_vect[0])
,boost::make_move_iterator(aux_vect + 50)); ,boost::make_move_iterator(aux_vect + 50));
if(boostvector->begin() + old_size/2 != insert_it) return 1; if(boostvector.begin() + old_size/2 != insert_it) return 1;
stdvector->insert(stdvector->begin() + old_size/2, aux_vect2, aux_vect2 + 50); stdvector.insert(stdvector.begin() + old_size/2, aux_vect2, aux_vect2 + 50);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
for(int i = 0; i < 50; ++i){ for(int i = 0; i < 50; ++i){
@@ -202,53 +208,53 @@ int vector_test()
for(int i = 0; i < 50; ++i){ for(int i = 0; i < 50; ++i){
aux_vect2[i] = -i; aux_vect2[i] = -i;
} }
old_size = boostvector->size(); old_size = boostvector.size();
//Now try with input iterators instead //Now try with input iterators instead
insert_it = boostvector->insert(boostvector->begin() + old_size/2 insert_it = boostvector.insert(boostvector.begin() + old_size/2
,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0])) ,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0]))
,boost::make_move_iterator(make_input_from_forward_iterator(aux_vect + 50)) ,boost::make_move_iterator(make_input_from_forward_iterator(aux_vect + 50))
); );
if(boostvector->begin() + old_size/2 != insert_it) return 1; if(boostvector.begin() + old_size/2 != insert_it) return 1;
stdvector->insert(stdvector->begin() + old_size/2, aux_vect2, aux_vect2 + 50); stdvector.insert(stdvector.begin() + old_size/2, aux_vect2, aux_vect2 + 50);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
} }
/* //deque has no reserve /* //deque has no reserve
boostvector->reserve(boostvector->size()*2); boostvector.reserve(boostvector.size()*2);
stdvector->reserve(stdvector->size()*2); stdvector.reserve(stdvector.size()*2);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
*/ */
boostvector->shrink_to_fit(); boostvector.shrink_to_fit();
MyStdVector(*stdvector).swap(*stdvector); MyStdVector(stdvector).swap(stdvector);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
boostvector->shrink_to_fit(); boostvector.shrink_to_fit();
MyStdVector(*stdvector).swap(*stdvector); MyStdVector(stdvector).swap(stdvector);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
{ //push_back with not enough capacity { //push_back with not enough capacity
IntType push_back_this(1); IntType push_back_this(1);
boostvector->push_back(boost::move(push_back_this)); boostvector.push_back(boost::move(push_back_this));
stdvector->push_back(int(1)); stdvector.push_back(int(1));
boostvector->push_back(IntType(1)); boostvector.push_back(IntType(1));
stdvector->push_back(int(1)); stdvector.push_back(int(1));
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
} }
{ //test back() { //test back()
const IntType test_this(1); const IntType test_this(1);
if(test_this != boostvector->back()) return 1; if(test_this != boostvector.back()) return 1;
} }
{ //pop_back with enough capacity { //pop_back with enough capacity
boostvector->pop_back(); boostvector.pop_back();
boostvector->pop_back(); boostvector.pop_back();
stdvector->pop_back(); stdvector.pop_back();
stdvector->pop_back(); stdvector.pop_back();
IntType push_back_this(1); IntType push_back_this(1);
boostvector->push_back(boost::move(push_back_this)); boostvector.push_back(boost::move(push_back_this));
stdvector->push_back(int(1)); stdvector.push_back(int(1));
boostvector->push_back(IntType(1)); boostvector.push_back(IntType(1));
stdvector->push_back(int(1)); stdvector.push_back(int(1));
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
} }
@@ -257,16 +263,16 @@ int vector_test()
return 1; return 1;
} }
boostvector->erase(boostvector->begin()); boostvector.erase(boostvector.begin());
stdvector->erase(stdvector->begin()); stdvector.erase(stdvector.begin());
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
for(int i = 0; i < max; ++i){ for(int i = 0; i < max; ++i){
IntType insert_this(i); IntType insert_this(i);
boostvector->insert(boostvector->begin(), boost::move(insert_this)); boostvector.insert(boostvector.begin(), boost::move(insert_this));
stdvector->insert(stdvector->begin(), i); stdvector.insert(stdvector.begin(), i);
boostvector->insert(boostvector->begin(), IntType(i)); boostvector.insert(boostvector.begin(), IntType(i));
stdvector->insert(stdvector->begin(), int(i)); stdvector.insert(stdvector.begin(), int(i));
} }
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
@@ -274,56 +280,44 @@ int vector_test()
{ {
std::list<int> l(50, int(1)); std::list<int> l(50, int(1));
typename MyBoostVector::iterator it_insert = typename MyBoostVector::iterator it_insert =
boostvector->insert(boostvector->begin(), l.begin(), l.end()); boostvector.insert(boostvector.begin(), l.begin(), l.end());
if(boostvector->begin() != it_insert) return 1; if(boostvector.begin() != it_insert) return 1;
stdvector->insert(stdvector->begin(), l.begin(), l.end()); stdvector.insert(stdvector.begin(), l.begin(), l.end());
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
boostvector->assign(l.begin(), l.end()); boostvector.assign(l.begin(), l.end());
stdvector->assign(l.begin(), l.end()); stdvector.assign(l.begin(), l.end());
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
boostvector->clear(); boostvector.clear();
stdvector->clear(); stdvector.clear();
boostvector->assign(make_input_from_forward_iterator(l.begin()), make_input_from_forward_iterator(l.end())); boostvector.assign(make_input_from_forward_iterator(l.begin()), make_input_from_forward_iterator(l.end()));
stdvector->assign(l.begin(), l.end()); stdvector.assign(l.begin(), l.end());
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
} }
/* deque has no reserve or capacity /* deque has no reserve or capacity
std::size_t cap = boostvector->capacity(); std::size_t cap = boostvector.capacity();
boostvector->reserve(cap*2); boostvector.reserve(cap*2);
stdvector->reserve(cap*2); stdvector.reserve(cap*2);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
boostvector->resize(0); boostvector.resize(0);
stdvector->resize(0); stdvector.resize(0);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
boostvector->resize(cap*2); boostvector.resize(cap*2);
stdvector->resize(cap*2); stdvector.resize(cap*2);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
boostvector->clear(); boostvector.clear();
stdvector->clear(); stdvector.clear();
boostvector->shrink_to_fit(); boostvector.shrink_to_fit();
MyStdVector(*stdvector).swap(*stdvector); MyStdVector(stdvector).swap(stdvector);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
boostvector->resize(cap*2); boostvector.resize(cap*2);
stdvector->resize(cap*2); stdvector.resize(cap*2);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
*/ */
delete stdvector;
delete boostvector;
} }
BOOST_CATCH(std::exception &ex){
#ifndef BOOST_NO_EXCEPTIONS
std::cout << ex.what() << std::endl;
#endif
return 1;
}
BOOST_CATCH_END
}
std::cout << std::endl << "Test OK!" << std::endl; std::cout << std::endl << "Test OK!" << std::endl;
return 0; return 0;
} }
@@ -335,7 +329,7 @@ bool test_vector_methods_with_initializer_list_as_argument_for()
{ {
const VectorContainerType testedVector = {1, 2, 3}; const VectorContainerType testedVector = {1, 2, 3};
const std::vector<int> expectedVector = {1, 2, 3}; const std::vector<int> expectedVector = {1, 2, 3};
if(!test::CheckEqualContainers(&testedVector, &expectedVector)) return false; if(!test::CheckEqualContainers(testedVector, expectedVector)) return false;
} }
{ {
@@ -343,7 +337,7 @@ bool test_vector_methods_with_initializer_list_as_argument_for()
testedVector = {11, 12, 13}; testedVector = {11, 12, 13};
const std::vector<int> expectedVector = {11, 12, 13}; const std::vector<int> expectedVector = {11, 12, 13};
if(!test::CheckEqualContainers(&testedVector, &expectedVector)) return false; if(!test::CheckEqualContainers(testedVector, expectedVector)) return false;
} }
{ {
@@ -351,7 +345,7 @@ bool test_vector_methods_with_initializer_list_as_argument_for()
testedVector.assign({5, 6, 7}); testedVector.assign({5, 6, 7});
const std::vector<int> expectedVector = {5, 6, 7}; const std::vector<int> expectedVector = {5, 6, 7};
if(!test::CheckEqualContainers(&testedVector, &expectedVector)) return false; if(!test::CheckEqualContainers(testedVector, expectedVector)) return false;
} }
{ {
@@ -359,7 +353,7 @@ bool test_vector_methods_with_initializer_list_as_argument_for()
testedVector.insert(testedVector.cend(), {5, 6, 7}); testedVector.insert(testedVector.cend(), {5, 6, 7});
const std::vector<int> expectedVector = {1, 2, 3, 5, 6, 7}; const std::vector<int> expectedVector = {1, 2, 3, 5, 6, 7};
if(!test::CheckEqualContainers(&testedVector, &expectedVector)) return false; if(!test::CheckEqualContainers(testedVector, expectedVector)) return false;
} }
return true; return true;
#else #else