mirror of
https://github.com/boostorg/container.git
synced 2025-08-02 14:04:26 +02:00
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:
@@ -17,6 +17,7 @@
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <boost/move/unique_ptr.hpp>
|
||||
|
||||
namespace boost{
|
||||
namespace container {
|
||||
@@ -60,15 +61,15 @@ bool CheckEqual( const Pair1 &pair1, const Pair2 &pair2
|
||||
//Function to check if both containers are equal
|
||||
template<class MyBoostCont
|
||||
,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;
|
||||
|
||||
typename MyBoostCont::const_iterator itboost(boostcont->begin()), itboostend(boostcont->end());
|
||||
typename MyStdCont::const_iterator itstd(stdcont->begin());
|
||||
typename MyBoostCont::const_iterator itboost(boostcont.begin()), itboostend(boostcont.end());
|
||||
typename MyStdCont::const_iterator itstd(stdcont.begin());
|
||||
typename MyStdCont::size_type dist = (typename MyStdCont::size_type)std::distance(itboost, itboostend);
|
||||
if(dist != boostcont->size()){
|
||||
if(dist != boostcont.size()){
|
||||
return false;
|
||||
}
|
||||
std::size_t i = 0;
|
||||
@@ -81,16 +82,16 @@ bool CheckEqualContainers(const MyBoostCont *boostcont, const MyStdCont *stdcont
|
||||
|
||||
template<class MyBoostCont
|
||||
,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;
|
||||
|
||||
typedef typename MyBoostCont::key_type key_type;
|
||||
typedef typename MyBoostCont::mapped_type mapped_type;
|
||||
|
||||
typename MyBoostCont::const_iterator itboost(boostcont->begin()), itboostend(boostcont->end());
|
||||
typename MyStdCont::const_iterator itstd(stdcont->begin());
|
||||
typename MyBoostCont::const_iterator itboost(boostcont.begin()), itboostend(boostcont.end());
|
||||
typename MyStdCont::const_iterator itstd(stdcont.begin());
|
||||
for(; itboost != itboostend; ++itboost, ++itstd){
|
||||
if(itboost->first != key_type(itstd->first))
|
||||
return false;
|
||||
|
@@ -70,58 +70,58 @@ template class boost::container::deque
|
||||
|
||||
//Function to check if both sets are equal
|
||||
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;
|
||||
}
|
||||
|
||||
//Function to check if both sets are equal
|
||||
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;
|
||||
std::size_t size = cntdeque->size();
|
||||
stddeque->insert(stddeque->end(), 50, 1);
|
||||
cntdeque->insert(cntdeque->end(), 50, IntType(1));
|
||||
std::size_t size = cntdeque.size();
|
||||
stddeque.insert(stddeque.end(), 50, 1);
|
||||
cntdeque.insert(cntdeque.end(), 50, IntType(1));
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
{
|
||||
IntType move_me(1);
|
||||
stddeque->insert(stddeque->begin()+size/2, 50, 1);
|
||||
cntdeque->insert(cntdeque->begin()+size/2, 50, boost::move(move_me));
|
||||
stddeque.insert(stddeque.begin()+size/2, 50, 1);
|
||||
cntdeque.insert(cntdeque.begin()+size/2, 50, boost::move(move_me));
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
}
|
||||
{
|
||||
IntType move_me(2);
|
||||
cntdeque->assign(cntdeque->size()/2, boost::move(move_me));
|
||||
stddeque->assign(stddeque->size()/2, 2);
|
||||
cntdeque.assign(cntdeque.size()/2, boost::move(move_me));
|
||||
stddeque.assign(stddeque.size()/2, 2);
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
}
|
||||
{
|
||||
IntType move_me(1);
|
||||
stddeque->clear();
|
||||
cntdeque->clear();
|
||||
stddeque->insert(stddeque->begin(), 50, 1);
|
||||
cntdeque->insert(cntdeque->begin(), 50, boost::move(move_me));
|
||||
stddeque.clear();
|
||||
cntdeque.clear();
|
||||
stddeque.insert(stddeque.begin(), 50, 1);
|
||||
cntdeque.insert(cntdeque.begin(), 50, boost::move(move_me));
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
stddeque->insert(stddeque->begin()+20, 50, 1);
|
||||
cntdeque->insert(cntdeque->begin()+20, 50, boost::move(move_me));
|
||||
stddeque.insert(stddeque.begin()+20, 50, 1);
|
||||
cntdeque.insert(cntdeque.begin()+20, 50, boost::move(move_me));
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
stddeque->insert(stddeque->begin()+20, 20, 1);
|
||||
cntdeque->insert(cntdeque->begin()+20, 20, boost::move(move_me));
|
||||
stddeque.insert(stddeque.begin()+20, 20, 1);
|
||||
cntdeque.insert(cntdeque.begin()+20, 20, boost::move(move_me));
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
}
|
||||
{
|
||||
IntType move_me(1);
|
||||
stddeque->clear();
|
||||
cntdeque->clear();
|
||||
stddeque->insert(stddeque->end(), 50, 1);
|
||||
cntdeque->insert(cntdeque->end(), 50, boost::move(move_me));
|
||||
stddeque.clear();
|
||||
cntdeque.clear();
|
||||
stddeque.insert(stddeque.end(), 50, 1);
|
||||
cntdeque.insert(cntdeque.end(), 50, boost::move(move_me));
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
stddeque->insert(stddeque->end()-20, 50, 1);
|
||||
cntdeque->insert(cntdeque->end()-20, 50, boost::move(move_me));
|
||||
stddeque.insert(stddeque.end()-20, 50, 1);
|
||||
cntdeque.insert(cntdeque.end()-20, 50, boost::move(move_me));
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
stddeque->insert(stddeque->end()-20, 20, 1);
|
||||
cntdeque->insert(cntdeque->end()-20, 20, boost::move(move_me));
|
||||
stddeque.insert(stddeque.end()-20, 20, 1);
|
||||
cntdeque.insert(cntdeque.end()-20, 20, boost::move(move_me));
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
}
|
||||
|
||||
@@ -165,33 +165,35 @@ bool do_test()
|
||||
typedef deque<IntType> MyCntDeque;
|
||||
typedef std::deque<int> MyStdDeque;
|
||||
const int max = 100;
|
||||
BOOST_TRY{
|
||||
MyCntDeque *cntdeque = new MyCntDeque;
|
||||
MyStdDeque *stddeque = new MyStdDeque;
|
||||
{
|
||||
::boost::movelib::unique_ptr<MyCntDeque> const pcntdeque = ::boost::movelib::make_unique<MyCntDeque>();
|
||||
::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){
|
||||
IntType move_me(i);
|
||||
cntdeque->insert(cntdeque->end(), boost::move(move_me));
|
||||
stddeque->insert(stddeque->end(), i);
|
||||
cntdeque.insert(cntdeque.end(), boost::move(move_me));
|
||||
stddeque.insert(stddeque.end(), i);
|
||||
}
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
|
||||
cntdeque->clear();
|
||||
stddeque->clear();
|
||||
cntdeque.clear();
|
||||
stddeque.clear();
|
||||
|
||||
for(int i = 0; i < max*100; ++i){
|
||||
IntType move_me(i);
|
||||
cntdeque->push_back(boost::move(move_me));
|
||||
stddeque->push_back(i);
|
||||
cntdeque.push_back(boost::move(move_me));
|
||||
stddeque.push_back(i);
|
||||
}
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
|
||||
cntdeque->clear();
|
||||
stddeque->clear();
|
||||
cntdeque.clear();
|
||||
stddeque.clear();
|
||||
|
||||
for(int i = 0; i < max*100; ++i){
|
||||
IntType move_me(i);
|
||||
cntdeque->push_front(boost::move(move_me));
|
||||
stddeque->push_front(i);
|
||||
cntdeque.push_front(boost::move(move_me));
|
||||
stddeque.push_front(i);
|
||||
}
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
|
||||
@@ -199,12 +201,12 @@ bool do_test()
|
||||
typename MyCntDeque::const_iterator cit = it;
|
||||
(void)cit;
|
||||
|
||||
cntdeque->erase(cntdeque->begin()++);
|
||||
stddeque->erase(stddeque->begin()++);
|
||||
cntdeque.erase(cntdeque.begin()++);
|
||||
stddeque.erase(stddeque.begin()++);
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
|
||||
cntdeque->erase(cntdeque->begin());
|
||||
stddeque->erase(stddeque->begin());
|
||||
cntdeque.erase(cntdeque.begin());
|
||||
stddeque.erase(stddeque.begin());
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
|
||||
{
|
||||
@@ -219,10 +221,10 @@ bool do_test()
|
||||
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 + 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;
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
@@ -233,15 +235,15 @@ bool do_test()
|
||||
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 + 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;
|
||||
|
||||
for(int i = 0, j = static_cast<int>(cntdeque->size()); i < j; ++i){
|
||||
cntdeque->erase(cntdeque->begin());
|
||||
stddeque->erase(stddeque->begin());
|
||||
for(int i = 0, j = static_cast<int>(cntdeque.size()); i < j; ++i){
|
||||
cntdeque.erase(cntdeque.begin());
|
||||
stddeque.erase(stddeque.begin());
|
||||
}
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
}
|
||||
@@ -255,10 +257,10 @@ bool do_test()
|
||||
for(int i = 0; i < 50; ++i){
|
||||
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 + 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;
|
||||
}
|
||||
|
||||
@@ -267,47 +269,37 @@ bool do_test()
|
||||
return false;
|
||||
}
|
||||
|
||||
cntdeque->erase(cntdeque->begin());
|
||||
stddeque->erase(stddeque->begin());
|
||||
cntdeque.erase(cntdeque.begin());
|
||||
stddeque.erase(stddeque.begin());
|
||||
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType move_me(i);
|
||||
cntdeque->insert(cntdeque->begin(), boost::move(move_me));
|
||||
stddeque->insert(stddeque->begin(), i);
|
||||
cntdeque.insert(cntdeque.begin(), boost::move(move_me));
|
||||
stddeque.insert(stddeque.begin(), i);
|
||||
}
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
|
||||
//Test insertion from list
|
||||
{
|
||||
std::list<int> l(50, int(1));
|
||||
cntdeque->insert(cntdeque->begin(), l.begin(), l.end());
|
||||
stddeque->insert(stddeque->begin(), l.begin(), l.end());
|
||||
cntdeque.insert(cntdeque.begin(), l.begin(), l.end());
|
||||
stddeque.insert(stddeque.begin(), l.begin(), l.end());
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return 1;
|
||||
cntdeque->assign(l.begin(), l.end());
|
||||
stddeque->assign(l.begin(), l.end());
|
||||
cntdeque.assign(l.begin(), l.end());
|
||||
stddeque.assign(l.begin(), l.end());
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return 1;
|
||||
}
|
||||
|
||||
cntdeque->resize(100);
|
||||
stddeque->resize(100);
|
||||
cntdeque.resize(100);
|
||||
stddeque.resize(100);
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return 1;
|
||||
|
||||
cntdeque->resize(200);
|
||||
stddeque->resize(200);
|
||||
cntdeque.resize(200);
|
||||
stddeque.resize(200);
|
||||
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;
|
||||
return true;
|
||||
|
@@ -21,114 +21,6 @@
|
||||
|
||||
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
|
||||
template <class Vector1, class Vector2>
|
||||
bool CheckEqualVector(const Vector1 &vector1, const Vector2 &vector2)
|
||||
@@ -209,7 +101,7 @@ bool test_insert_with_expand_bwd()
|
||||
return false;
|
||||
|
||||
expand_bwd_test_allocator<value_type> alloc
|
||||
(&memory[0], MemorySize, Offset[iteration]);
|
||||
(memory, MemorySize, Offset[iteration]);
|
||||
VectorWithExpandBwdAllocator vector(alloc);
|
||||
vector.insert( vector.begin()
|
||||
, initial_data.begin(), initial_data.end());
|
||||
@@ -250,47 +142,41 @@ bool test_assign_with_expand_bwd()
|
||||
|
||||
for(int iteration = 0; iteration <Iterations; ++iteration)
|
||||
{
|
||||
value_type *memory = new value_type[MemorySize];
|
||||
BOOST_TRY {
|
||||
//Create initial data
|
||||
std::vector<non_volatile_value_type> initial_data;
|
||||
initial_data.resize(InitialSize[iteration]);
|
||||
for(int i = 0; i < InitialSize[iteration]; ++i){
|
||||
initial_data[i] = i;
|
||||
}
|
||||
|
||||
//Create data to assign
|
||||
std::vector<non_volatile_value_type> data_to_insert;
|
||||
data_to_insert.resize(InsertSize[iteration]);
|
||||
for(int i = 0; i < InsertSize[iteration]; ++i){
|
||||
data_to_insert[i] = -i;
|
||||
}
|
||||
|
||||
//Insert initial data to the vector to test
|
||||
expand_bwd_test_allocator<value_type> alloc
|
||||
(&memory[0], MemorySize, Offset[iteration]);
|
||||
VectorWithExpandBwdAllocator vector(alloc);
|
||||
vector.insert( vector.begin()
|
||||
, initial_data.begin(), initial_data.end());
|
||||
|
||||
//Assign data
|
||||
vector.insert(vector.cbegin(), data_to_insert.begin(), data_to_insert.end());
|
||||
initial_data.insert(initial_data.begin(), data_to_insert.begin(), data_to_insert.end());
|
||||
|
||||
//Now check that values are equal
|
||||
if(!CheckEqualVector(vector, initial_data)){
|
||||
std::cout << "test_assign_with_expand_bwd::CheckEqualVector failed." << std::endl
|
||||
<< " Class: " << typeid(VectorWithExpandBwdAllocator).name() << std::endl
|
||||
<< " Iteration: " << iteration << std::endl;
|
||||
return false;
|
||||
}
|
||||
boost::movelib::unique_ptr<char[]> memptr =
|
||||
boost::movelib::make_unique_definit<char[]>(MemorySize*sizeof(value_type));
|
||||
value_type *memory = (value_type*)memptr.get();
|
||||
//Create initial data
|
||||
std::vector<non_volatile_value_type> initial_data;
|
||||
initial_data.resize(InitialSize[iteration]);
|
||||
for(int i = 0; i < InitialSize[iteration]; ++i){
|
||||
initial_data[i] = i;
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
delete [](const_cast<typename boost::remove_volatile<value_type>::type*>(memory));
|
||||
BOOST_RETHROW;
|
||||
|
||||
//Create data to assign
|
||||
std::vector<non_volatile_value_type> data_to_insert;
|
||||
data_to_insert.resize(InsertSize[iteration]);
|
||||
for(int i = 0; i < InsertSize[iteration]; ++i){
|
||||
data_to_insert[i] = -i;
|
||||
}
|
||||
|
||||
//Insert initial data to the vector to test
|
||||
expand_bwd_test_allocator<value_type> alloc
|
||||
(memory, MemorySize, Offset[iteration]);
|
||||
VectorWithExpandBwdAllocator vector(alloc);
|
||||
vector.insert( vector.begin()
|
||||
, initial_data.begin(), initial_data.end());
|
||||
|
||||
//Assign data
|
||||
vector.insert(vector.cbegin(), data_to_insert.begin(), data_to_insert.end());
|
||||
initial_data.insert(initial_data.begin(), data_to_insert.begin(), data_to_insert.end());
|
||||
|
||||
//Now check that values are equal
|
||||
if(!CheckEqualVector(vector, initial_data)){
|
||||
std::cout << "test_assign_with_expand_bwd::CheckEqualVector failed." << std::endl
|
||||
<< " Class: " << typeid(VectorWithExpandBwdAllocator).name() << std::endl
|
||||
<< " Iteration: " << iteration << std::endl;
|
||||
return false;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
delete [](const_cast<typename boost::remove_volatile<value_type>::type*>(memory));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@@ -247,24 +247,24 @@ bool flat_tree_ordered_insertion_test()
|
||||
}
|
||||
//Construction insertion
|
||||
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;
|
||||
//Insertion when empty
|
||||
fmmap.clear();
|
||||
fmmap.insert(ordered_range, int_mmap.begin(), int_mmap.end());
|
||||
if(!CheckEqualContainers(&int_mmap, &fmmap))
|
||||
if(!CheckEqualContainers(int_mmap, fmmap))
|
||||
return false;
|
||||
//Re-insertion
|
||||
fmmap.insert(ordered_range, int_mmap.begin(), int_mmap.end());
|
||||
std::multimap<int, int> int_mmap2(int_mmap);
|
||||
int_mmap2.insert(int_mmap.begin(), int_mmap.end());
|
||||
if(!CheckEqualContainers(&int_mmap2, &fmmap))
|
||||
if(!CheckEqualContainers(int_mmap2, fmmap))
|
||||
return false;
|
||||
//Re-re-insertion
|
||||
fmmap.insert(ordered_range, int_mmap2.begin(), int_mmap2.end());
|
||||
std::multimap<int, int> int_mmap4(int_mmap2);
|
||||
int_mmap4.insert(int_mmap2.begin(), int_mmap2.end());
|
||||
if(!CheckEqualContainers(&int_mmap4, &fmmap))
|
||||
if(!CheckEqualContainers(int_mmap4, fmmap))
|
||||
return false;
|
||||
//Re-re-insertion of even
|
||||
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());
|
||||
int_mmap4.insert(int_even_mmap.begin(), int_even_mmap.end());
|
||||
if(!CheckEqualContainers(&int_mmap4, &fmmap))
|
||||
if(!CheckEqualContainers(int_mmap4, fmmap))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -285,24 +285,24 @@ bool flat_tree_ordered_insertion_test()
|
||||
}
|
||||
//Construction insertion
|
||||
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;
|
||||
//Insertion when empty
|
||||
fmap.clear();
|
||||
fmap.insert(ordered_unique_range, int_map.begin(), int_map.end());
|
||||
if(!CheckEqualContainers(&int_map, &fmap))
|
||||
if(!CheckEqualContainers(int_map, fmap))
|
||||
return false;
|
||||
//Re-insertion
|
||||
fmap.insert(ordered_unique_range, int_map.begin(), int_map.end());
|
||||
std::map<int, int> int_map2(int_map);
|
||||
int_map2.insert(int_map.begin(), int_map.end());
|
||||
if(!CheckEqualContainers(&int_map2, &fmap))
|
||||
if(!CheckEqualContainers(int_map2, fmap))
|
||||
return false;
|
||||
//Re-re-insertion
|
||||
fmap.insert(ordered_unique_range, int_map2.begin(), int_map2.end());
|
||||
std::map<int, int> int_map4(int_map2);
|
||||
int_map4.insert(int_map2.begin(), int_map2.end());
|
||||
if(!CheckEqualContainers(&int_map4, &fmap))
|
||||
if(!CheckEqualContainers(int_map4, fmap))
|
||||
return false;
|
||||
//Re-re-insertion of even
|
||||
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());
|
||||
int_map4.insert(int_even_map.begin(), int_even_map.end());
|
||||
if(!CheckEqualContainers(&int_map4, &fmap))
|
||||
if(!CheckEqualContainers(int_map4, fmap))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -272,24 +272,24 @@ bool flat_tree_ordered_insertion_test()
|
||||
}
|
||||
//Construction insertion
|
||||
flat_multiset<int> fmset(ordered_range, int_mset.begin(), int_mset.end());
|
||||
if(!CheckEqualContainers(&int_mset, &fmset))
|
||||
if(!CheckEqualContainers(int_mset, fmset))
|
||||
return false;
|
||||
//Insertion when empty
|
||||
fmset.clear();
|
||||
fmset.insert(ordered_range, int_mset.begin(), int_mset.end());
|
||||
if(!CheckEqualContainers(&int_mset, &fmset))
|
||||
if(!CheckEqualContainers(int_mset, fmset))
|
||||
return false;
|
||||
//Re-insertion
|
||||
fmset.insert(ordered_range, int_mset.begin(), int_mset.end());
|
||||
std::multiset<int> int_mset2(int_mset);
|
||||
int_mset2.insert(int_mset.begin(), int_mset.end());
|
||||
if(!CheckEqualContainers(&int_mset2, &fmset))
|
||||
if(!CheckEqualContainers(int_mset2, fmset))
|
||||
return false;
|
||||
//Re-re-insertion
|
||||
fmset.insert(ordered_range, int_mset2.begin(), int_mset2.end());
|
||||
std::multiset<int> int_mset4(int_mset2);
|
||||
int_mset4.insert(int_mset2.begin(), int_mset2.end());
|
||||
if(!CheckEqualContainers(&int_mset4, &fmset))
|
||||
if(!CheckEqualContainers(int_mset4, fmset))
|
||||
return false;
|
||||
//Re-re-insertion of even
|
||||
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());
|
||||
int_mset4.insert(int_even_mset.begin(), int_even_mset.end());
|
||||
if(!CheckEqualContainers(&int_mset4, &fmset))
|
||||
if(!CheckEqualContainers(int_mset4, fmset))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -310,24 +310,24 @@ bool flat_tree_ordered_insertion_test()
|
||||
}
|
||||
//Construction insertion
|
||||
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;
|
||||
//Insertion when empty
|
||||
fset.clear();
|
||||
fset.insert(ordered_unique_range, int_set.begin(), int_set.end());
|
||||
if(!CheckEqualContainers(&int_set, &fset))
|
||||
if(!CheckEqualContainers(int_set, fset))
|
||||
return false;
|
||||
//Re-insertion
|
||||
fset.insert(ordered_unique_range, int_set.begin(), int_set.end());
|
||||
std::set<int> int_set2(int_set);
|
||||
int_set2.insert(int_set.begin(), int_set.end());
|
||||
if(!CheckEqualContainers(&int_set2, &fset))
|
||||
if(!CheckEqualContainers(int_set2, fset))
|
||||
return false;
|
||||
//Re-re-insertion
|
||||
fset.insert(ordered_unique_range, int_set2.begin(), int_set2.end());
|
||||
std::set<int> int_set4(int_set2);
|
||||
int_set4.insert(int_set2.begin(), int_set2.end());
|
||||
if(!CheckEqualContainers(&int_set4, &fset))
|
||||
if(!CheckEqualContainers(int_set4, fset))
|
||||
return false;
|
||||
//Re-re-insertion of even
|
||||
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());
|
||||
int_set4.insert(int_even_set.begin(), int_even_set.end());
|
||||
if(!CheckEqualContainers(&int_set4, &fset))
|
||||
if(!CheckEqualContainers(int_set4, fset))
|
||||
return false;
|
||||
//Partial Re-re-insertion of even
|
||||
int_even_set.clear();
|
||||
@@ -348,7 +348,7 @@ bool flat_tree_ordered_insertion_test()
|
||||
//insert 0,4,8,12...
|
||||
fset.insert(ordered_unique_range, 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;
|
||||
for(std::size_t i = 2; i < NumElements; i+=4){
|
||||
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...
|
||||
fset.insert(ordered_unique_range, 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;
|
||||
int_even_set.clear();
|
||||
for(std::size_t i = 0; i < NumElements; i+=8){
|
||||
@@ -367,7 +367,7 @@ bool flat_tree_ordered_insertion_test()
|
||||
//insert 0,8,16...
|
||||
fset.insert(ordered_unique_range, 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;
|
||||
for(std::size_t i = 0; i < NumElements; i+=2){
|
||||
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...
|
||||
fset.insert(ordered_unique_range, 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;
|
||||
|
||||
|
||||
@@ -390,7 +390,7 @@ bool flat_tree_ordered_insertion_test()
|
||||
//insert 0,2,8,10...
|
||||
fset.insert(ordered_unique_range, 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;
|
||||
for(std::size_t i = 0; i < NumElements; i+=2){
|
||||
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...
|
||||
fset.insert(ordered_unique_range, 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;
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,7 @@ void
|
||||
, std::size_t index
|
||||
)
|
||||
{
|
||||
BOOST_TEST(CheckEqualContainers(&std_deque, &seq_container));
|
||||
BOOST_TEST(CheckEqualContainers(std_deque, seq_container));
|
||||
|
||||
std_deque.insert(
|
||||
std_deque.begin() + index
|
||||
@@ -36,7 +36,7 @@ void
|
||||
, input_deque.begin()
|
||||
, input_deque.end()
|
||||
);
|
||||
BOOST_TEST(CheckEqualContainers(&std_deque, &seq_container));
|
||||
BOOST_TEST(CheckEqualContainers(std_deque, seq_container));
|
||||
}
|
||||
|
||||
template<class SeqContainer>
|
||||
|
@@ -22,52 +22,53 @@
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/move/iterator.hpp>
|
||||
#include <string>
|
||||
#include <boost/move/make_unique.hpp>
|
||||
|
||||
namespace boost{
|
||||
namespace container {
|
||||
namespace test{
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//Function to check if both sets are equal
|
||||
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;
|
||||
boostlist->insert(boostlist->end(), 50, IntType(1));
|
||||
stdlist->insert(stdlist->end(), 50, 1);
|
||||
boostlist.insert(boostlist.end(), 50, IntType(1));
|
||||
stdlist.insert(stdlist.end(), 50, 1);
|
||||
if(!test::CheckEqualContainers(boostlist, stdlist)) return false;
|
||||
|
||||
{
|
||||
IntType move_me(1);
|
||||
boostlist->insert(boostlist->begin(), 50, boost::move(move_me));
|
||||
stdlist->insert(stdlist->begin(), 50, 1);
|
||||
boostlist.insert(boostlist.begin(), 50, boost::move(move_me));
|
||||
stdlist.insert(stdlist.begin(), 50, 1);
|
||||
if(!test::CheckEqualContainers(boostlist, stdlist)) return false;
|
||||
}
|
||||
{
|
||||
IntType move_me(2);
|
||||
boostlist->assign(boostlist->size()/2, boost::move(move_me));
|
||||
stdlist->assign(stdlist->size()/2, 2);
|
||||
boostlist.assign(boostlist.size()/2, boost::move(move_me));
|
||||
stdlist.assign(stdlist.size()/2, 2);
|
||||
if(!test::CheckEqualContainers(boostlist, stdlist)) return false;
|
||||
}
|
||||
{
|
||||
IntType move_me(3);
|
||||
boostlist->assign(boostlist->size()*3-1, boost::move(move_me));
|
||||
stdlist->assign(stdlist->size()*3-1, 3);
|
||||
boostlist.assign(boostlist.size()*3-1, boost::move(move_me));
|
||||
stdlist.assign(stdlist.size()*3-1, 3);
|
||||
if(!test::CheckEqualContainers(boostlist, stdlist)) return false;
|
||||
}
|
||||
|
||||
{
|
||||
IntType copy_me(3);
|
||||
const IntType ccopy_me(3);
|
||||
boostlist->push_front(copy_me);
|
||||
stdlist->push_front(int(3));
|
||||
boostlist->push_front(ccopy_me);
|
||||
stdlist->push_front(int(3));
|
||||
boostlist.push_front(copy_me);
|
||||
stdlist.push_front(int(3));
|
||||
boostlist.push_front(ccopy_me);
|
||||
stdlist.push_front(int(3));
|
||||
if(!test::CheckEqualContainers(boostlist, stdlist)) return false;
|
||||
}
|
||||
|
||||
@@ -78,15 +79,15 @@ template<bool DoublyLinked>
|
||||
struct list_push_data_function
|
||||
{
|
||||
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;
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType move_me(i);
|
||||
boostlist->push_back(boost::move(move_me));
|
||||
stdlist->push_back(i);
|
||||
boostlist->push_front(IntType(i));
|
||||
stdlist->push_front(int(i));
|
||||
boostlist.push_back(boost::move(move_me));
|
||||
stdlist.push_back(i);
|
||||
boostlist.push_front(IntType(i));
|
||||
stdlist.push_front(int(i));
|
||||
}
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
return 1;
|
||||
@@ -98,15 +99,15 @@ template<>
|
||||
struct list_push_data_function<false>
|
||||
{
|
||||
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;
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType move_me(i);
|
||||
boostlist->push_front(boost::move(move_me));
|
||||
stdlist->push_front(i);
|
||||
boostlist->push_front(IntType(i));
|
||||
stdlist->push_front(int(i));
|
||||
boostlist.push_front(boost::move(move_me));
|
||||
stdlist.push_front(i);
|
||||
boostlist.push_front(IntType(i));
|
||||
stdlist.push_front(int(i));
|
||||
}
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
return 1;
|
||||
@@ -118,10 +119,10 @@ template<bool DoublyLinked>
|
||||
struct list_pop_back_function
|
||||
{
|
||||
template<class MyStdList, class MyBoostList>
|
||||
static int execute(MyBoostList *boostlist, MyStdList *stdlist)
|
||||
static int execute(MyBoostList &boostlist, MyStdList &stdlist)
|
||||
{
|
||||
boostlist->pop_back();
|
||||
stdlist->pop_back();
|
||||
boostlist.pop_back();
|
||||
stdlist.pop_back();
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
return 1;
|
||||
return 0;
|
||||
@@ -132,7 +133,7 @@ template<>
|
||||
struct list_pop_back_function<false>
|
||||
{
|
||||
template<class MyStdList, class MyBoostList>
|
||||
static int execute(MyBoostList *boostlist, MyStdList *stdlist)
|
||||
static int execute(MyBoostList &boostlist, MyStdList &stdlist)
|
||||
{
|
||||
(void)boostlist; (void)stdlist;
|
||||
return 0;
|
||||
@@ -148,200 +149,194 @@ int list_test (bool copied_allocators_equal = true)
|
||||
const int max = 100;
|
||||
typedef list_push_data_function<DoublyLinked> push_data_t;
|
||||
|
||||
BOOST_TRY{
|
||||
MyBoostList *boostlist = new MyBoostList;
|
||||
MyStdList *stdlist = new MyStdList;
|
||||
::boost::movelib::unique_ptr<MyBoostList> const pboostlist = ::boost::movelib::make_unique<MyBoostList>();
|
||||
::boost::movelib::unique_ptr<MyStdList> const pstdlist = ::boost::movelib::make_unique<MyStdList>();
|
||||
|
||||
if(push_data_t::execute(max, boostlist, stdlist)){
|
||||
return 1;
|
||||
MyBoostList &boostlist = *pboostlist;
|
||||
MyStdList &stdlist = *pstdlist;
|
||||
|
||||
if(push_data_t::execute(max, boostlist, stdlist)){
|
||||
return 1;
|
||||
}
|
||||
|
||||
boostlist.erase(boostlist.begin()++);
|
||||
stdlist.erase(stdlist.begin()++);
|
||||
if(!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
|
||||
if(list_pop_back_function<DoublyLinked>::execute(boostlist, stdlist)){
|
||||
return 1;
|
||||
}
|
||||
|
||||
boostlist.pop_front();
|
||||
stdlist.pop_front();
|
||||
if(!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
|
||||
{
|
||||
IntType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
}
|
||||
|
||||
boostlist->erase(boostlist->begin()++);
|
||||
stdlist->erase(stdlist->begin()++);
|
||||
if(!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
|
||||
if(list_pop_back_function<DoublyLinked>::execute(boostlist, stdlist)){
|
||||
return 1;
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -1;
|
||||
}
|
||||
|
||||
boostlist->pop_front();
|
||||
stdlist->pop_front();
|
||||
if(!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
|
||||
{
|
||||
IntType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -1;
|
||||
}
|
||||
boostlist->assign(boost::make_move_iterator(&aux_vect[0])
|
||||
,boost::make_move_iterator(&aux_vect[50]));
|
||||
stdlist->assign(&aux_vect2[0], &aux_vect2[50]);
|
||||
if(!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -1;
|
||||
}
|
||||
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])));
|
||||
stdlist->assign(&aux_vect2[0], &aux_vect2[50]);
|
||||
if(!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
}
|
||||
|
||||
if(copied_allocators_equal){
|
||||
boostlist->sort();
|
||||
stdlist->sort();
|
||||
if(!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
}
|
||||
|
||||
boostlist->reverse();
|
||||
stdlist->reverse();
|
||||
if(!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
|
||||
boostlist->reverse();
|
||||
stdlist->reverse();
|
||||
if(!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
|
||||
{
|
||||
IntType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -1;
|
||||
}
|
||||
typename MyBoostList::iterator old_begin = boostlist->begin();
|
||||
typename MyBoostList::iterator it_insert =
|
||||
boostlist->insert(boostlist->begin()
|
||||
,boost::make_move_iterator(&aux_vect[0])
|
||||
boostlist.assign(boost::make_move_iterator(&aux_vect[0])
|
||||
,boost::make_move_iterator(&aux_vect[50]));
|
||||
if(it_insert != boostlist->begin() || std::distance(it_insert, old_begin) != 50)
|
||||
return 1;
|
||||
stdlist.assign(&aux_vect2[0], &aux_vect2[50]);
|
||||
if(!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
|
||||
stdlist->insert(stdlist->begin(), &aux_vect2[0], &aux_vect2[50]);
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
return 1;
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -1;
|
||||
}
|
||||
|
||||
old_begin = boostlist->begin();
|
||||
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[50])));
|
||||
if(std::distance(it_insert, boostlist->end()) != 50)
|
||||
return 1;
|
||||
stdlist->insert(stdlist->end(), &aux_vect2[0], &aux_vect2[50]);
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
return 1;
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
}
|
||||
|
||||
boostlist->unique();
|
||||
stdlist->unique();
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -1;
|
||||
}
|
||||
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])));
|
||||
stdlist.assign(&aux_vect2[0], &aux_vect2[50]);
|
||||
if(!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
}
|
||||
|
||||
if(copied_allocators_equal){
|
||||
boostlist.sort();
|
||||
stdlist.sort();
|
||||
if(!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
}
|
||||
|
||||
boostlist.reverse();
|
||||
stdlist.reverse();
|
||||
if(!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
|
||||
boostlist.reverse();
|
||||
stdlist.reverse();
|
||||
if(!CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
|
||||
{
|
||||
IntType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -1;
|
||||
}
|
||||
typename MyBoostList::iterator old_begin = boostlist.begin();
|
||||
typename MyBoostList::iterator it_insert =
|
||||
boostlist.insert(boostlist.begin()
|
||||
,boost::make_move_iterator(&aux_vect[0])
|
||||
,boost::make_move_iterator(&aux_vect[50]));
|
||||
if(it_insert != boostlist.begin() || std::distance(it_insert, old_begin) != 50)
|
||||
return 1;
|
||||
|
||||
stdlist.insert(stdlist.begin(), &aux_vect2[0], &aux_vect2[50]);
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
return 1;
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType move_me(-1);
|
||||
aux_vect[i] = boost::move(move_me);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -1;
|
||||
}
|
||||
|
||||
old_begin = boostlist.begin();
|
||||
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[50])));
|
||||
if(std::distance(it_insert, boostlist.end()) != 50)
|
||||
return 1;
|
||||
stdlist.insert(stdlist.end(), &aux_vect2[0], &aux_vect2[50]);
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
return 1;
|
||||
}
|
||||
|
||||
boostlist.unique();
|
||||
stdlist.unique();
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
return 1;
|
||||
|
||||
if(copied_allocators_equal){
|
||||
boostlist.sort(std::greater<IntType>());
|
||||
stdlist.sort(std::greater<int>());
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
return 1;
|
||||
}
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType new_int(i);
|
||||
boostlist.insert(boostlist.end(), boost::move(new_int));
|
||||
stdlist.insert(stdlist.end(), i);
|
||||
if(!test::CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
}
|
||||
if(!test::CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
|
||||
boostlist.resize(25);
|
||||
stdlist.resize(25);
|
||||
boostlist.resize(50);
|
||||
stdlist.resize(50);
|
||||
boostlist.resize(0);
|
||||
stdlist.resize(0);
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
return 1;
|
||||
|
||||
if(push_data_t::execute(max, boostlist, stdlist)){
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
MyBoostList otherboostlist(boostlist.get_allocator());
|
||||
MyStdList otherstdlist;
|
||||
|
||||
int listsize = (int)boostlist.size();
|
||||
|
||||
if(push_data_t::execute(listsize, boostlist, stdlist)){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(copied_allocators_equal){
|
||||
boostlist->sort(std::greater<IntType>());
|
||||
stdlist->sort(std::greater<int>());
|
||||
boostlist.splice(boostlist.begin(), otherboostlist);
|
||||
stdlist.splice(stdlist.begin(), otherstdlist);
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
return 1;
|
||||
}
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType new_int(i);
|
||||
boostlist->insert(boostlist->end(), boost::move(new_int));
|
||||
stdlist->insert(stdlist->end(), i);
|
||||
if(!test::CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
}
|
||||
if(!test::CheckEqualContainers(boostlist, stdlist)) return 1;
|
||||
listsize = (int)boostlist.size();
|
||||
|
||||
boostlist->resize(25);
|
||||
stdlist->resize(25);
|
||||
boostlist->resize(50);
|
||||
stdlist->resize(50);
|
||||
boostlist->resize(0);
|
||||
stdlist->resize(0);
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
return 1;
|
||||
|
||||
if(push_data_t::execute(max, boostlist, stdlist)){
|
||||
if(push_data_t::execute(listsize, boostlist, stdlist)){
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
MyBoostList otherboostlist(boostlist->get_allocator());
|
||||
MyStdList otherstdlist;
|
||||
|
||||
int listsize = (int)boostlist->size();
|
||||
|
||||
if(push_data_t::execute(listsize, boostlist, stdlist)){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(copied_allocators_equal){
|
||||
boostlist->splice(boostlist->begin(), otherboostlist);
|
||||
stdlist->splice(stdlist->begin(), otherstdlist);
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
return 1;
|
||||
}
|
||||
|
||||
listsize = (int)boostlist->size();
|
||||
|
||||
if(push_data_t::execute(listsize, boostlist, stdlist)){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(push_data_t::execute(listsize, &otherboostlist, &otherstdlist)){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(copied_allocators_equal){
|
||||
boostlist->sort(std::greater<IntType>());
|
||||
stdlist->sort(std::greater<int>());
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
return 1;
|
||||
|
||||
otherboostlist.sort(std::greater<IntType>());
|
||||
otherstdlist.sort(std::greater<int>());
|
||||
if(!CheckEqualContainers(&otherboostlist, &otherstdlist))
|
||||
return 1;
|
||||
|
||||
boostlist->merge(otherboostlist, std::greater<IntType>());
|
||||
stdlist->merge(otherstdlist, std::greater<int>());
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!list_copyable_only(boostlist, stdlist
|
||||
,container_detail::bool_<boost::container::test::is_copyable<IntType>::value>())){
|
||||
return 1;
|
||||
}
|
||||
if(push_data_t::execute(listsize, otherboostlist, otherstdlist)){
|
||||
return 1;
|
||||
}
|
||||
|
||||
delete boostlist;
|
||||
delete stdlist;
|
||||
if(copied_allocators_equal){
|
||||
boostlist.sort(std::greater<IntType>());
|
||||
stdlist.sort(std::greater<int>());
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
return 1;
|
||||
|
||||
otherboostlist.sort(std::greater<IntType>());
|
||||
otherstdlist.sort(std::greater<int>());
|
||||
if(!CheckEqualContainers(otherboostlist, otherstdlist))
|
||||
return 1;
|
||||
|
||||
boostlist.merge(otherboostlist, std::greater<IntType>());
|
||||
stdlist.merge(otherstdlist, std::greater<int>());
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!list_copyable_only(boostlist, stdlist
|
||||
,container_detail::bool_<boost::container::test::is_copyable<IntType>::value>())){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <boost/container/detail/pair.hpp>
|
||||
#include <boost/move/iterator.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/move/make_unique.hpp>
|
||||
#include <string>
|
||||
|
||||
#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 typename MyStdMap::value_type StdPairType;
|
||||
|
||||
const int max = 100;
|
||||
const int max = 50;
|
||||
|
||||
BOOST_TRY{
|
||||
MyBoostMap *boostmap = new MyBoostMap;
|
||||
MyStdMap *stdmap = new MyStdMap;
|
||||
MyBoostMultiMap *boostmultimap = new MyBoostMultiMap;
|
||||
MyStdMultiMap *stdmultimap = new MyStdMultiMap;
|
||||
::boost::movelib::unique_ptr<MyBoostMap> const pboostmap = ::boost::movelib::make_unique<MyBoostMap>();
|
||||
::boost::movelib::unique_ptr<MyStdMap> const pstdmap = ::boost::movelib::make_unique<MyStdMap>();
|
||||
::boost::movelib::unique_ptr<MyBoostMultiMap> const pboostmultimap = ::boost::movelib::make_unique<MyBoostMultiMap>();
|
||||
::boost::movelib::unique_ptr<MyStdMultiMap> const pstdmultimap = ::boost::movelib::make_unique<MyStdMultiMap>();
|
||||
MyBoostMap &boostmap = *pboostmap;
|
||||
MyStdMap &stdmap = *pstdmap;
|
||||
MyBoostMultiMap &boostmultimap = *pboostmultimap;
|
||||
MyStdMultiMap &stdmultimap = *pstdmultimap;
|
||||
|
||||
int i;
|
||||
for(i = 0; i < max; ++i){
|
||||
{
|
||||
IntType i1(i), i2(i);
|
||||
IntPairType intpair1(boost::move(i1), boost::move(i2));
|
||||
boostmap->insert(boost::move(intpair1));
|
||||
stdmap->insert(StdPairType(i, i));
|
||||
boostmap.insert(boost::move(intpair1));
|
||||
stdmap.insert(StdPairType(i, i));
|
||||
}
|
||||
{
|
||||
IntType i1(i), i2(i);
|
||||
IntPairType intpair2(boost::move(i1), boost::move(i2));
|
||||
boostmultimap->insert(boost::move(intpair2));
|
||||
stdmultimap->insert(StdPairType(i, i));
|
||||
boostmultimap.insert(boost::move(intpair2));
|
||||
stdmultimap.insert(StdPairType(i, i));
|
||||
}
|
||||
}
|
||||
if(!CheckEqualContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualContainers(boostmultimap, stdmultimap)) return 1;
|
||||
{
|
||||
//Now, test copy constructor
|
||||
MyBoostMap boostmapcopy(boostmap);
|
||||
MyStdMap stdmapcopy(stdmap);
|
||||
MyBoostMultiMap boostmmapcopy(boostmultimap);
|
||||
MyStdMultiMap stdmmapcopy(stdmultimap);
|
||||
|
||||
{
|
||||
//Now, test copy constructor
|
||||
MyBoostMap boostmapcopy(*boostmap);
|
||||
MyStdMap stdmapcopy(*stdmap);
|
||||
MyBoostMultiMap boostmmapcopy(*boostmultimap);
|
||||
MyStdMultiMap stdmmapcopy(*stdmultimap);
|
||||
if(!CheckEqualContainers(boostmapcopy, stdmapcopy))
|
||||
return 1;
|
||||
if(!CheckEqualContainers(boostmmapcopy, stdmmapcopy))
|
||||
return 1;
|
||||
|
||||
if(!CheckEqualContainers(&boostmapcopy, &stdmapcopy))
|
||||
return 1;
|
||||
if(!CheckEqualContainers(&boostmmapcopy, &stdmmapcopy))
|
||||
return 1;
|
||||
//And now assignment
|
||||
boostmapcopy = boostmap;
|
||||
stdmapcopy = stdmap;
|
||||
boostmmapcopy = boostmultimap;
|
||||
stdmmapcopy = stdmultimap;
|
||||
|
||||
//And now assignment
|
||||
boostmapcopy = *boostmap;
|
||||
stdmapcopy = *stdmap;
|
||||
boostmmapcopy = *boostmultimap;
|
||||
stdmmapcopy = *stdmultimap;
|
||||
|
||||
if(!CheckEqualContainers(&boostmapcopy, &stdmapcopy))
|
||||
return 1;
|
||||
if(!CheckEqualContainers(&boostmmapcopy, &stdmmapcopy))
|
||||
return 1;
|
||||
delete boostmap;
|
||||
delete boostmultimap;
|
||||
delete stdmap;
|
||||
delete stdmultimap;
|
||||
}
|
||||
if(!CheckEqualContainers(boostmapcopy, stdmapcopy))
|
||||
return 1;
|
||||
if(!CheckEqualContainers(boostmmapcopy, stdmmapcopy))
|
||||
return 1;
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -137,448 +132,443 @@ int map_test()
|
||||
typedef typename MyBoostMap::key_type IntType;
|
||||
typedef container_detail::pair<IntType, IntType> IntPairType;
|
||||
typedef typename MyStdMap::value_type StdPairType;
|
||||
const int max = 100;
|
||||
const int max = 50;
|
||||
|
||||
BOOST_TRY{
|
||||
MyBoostMap *boostmap = new MyBoostMap;
|
||||
MyStdMap *stdmap = new MyStdMap;
|
||||
MyBoostMultiMap *boostmultimap = new MyBoostMultiMap;
|
||||
MyStdMultiMap *stdmultimap = new MyStdMultiMap;
|
||||
::boost::movelib::unique_ptr<MyBoostMap> const pboostmap = ::boost::movelib::make_unique<MyBoostMap>();
|
||||
::boost::movelib::unique_ptr<MyStdMap> const pstdmap = ::boost::movelib::make_unique<MyStdMap>();
|
||||
::boost::movelib::unique_ptr<MyBoostMultiMap> const pboostmultimap = ::boost::movelib::make_unique<MyBoostMultiMap>();
|
||||
::boost::movelib::unique_ptr<MyStdMultiMap> const pstdmultimap = ::boost::movelib::make_unique<MyStdMultiMap>();
|
||||
MyBoostMap &boostmap = *pboostmap;
|
||||
MyStdMap &stdmap = *pstdmap;
|
||||
MyBoostMultiMap &boostmultimap = *pboostmultimap;
|
||||
MyStdMultiMap &stdmultimap = *pstdmultimap;
|
||||
|
||||
//Test construction from a range
|
||||
{
|
||||
//This is really nasty, but we have no other simple choice
|
||||
IntPairType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(i/2);
|
||||
IntType i2(i/2);
|
||||
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
//Test construction from a range
|
||||
{
|
||||
//This is really nasty, but we have no other simple choice
|
||||
IntPairType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(i/2);
|
||||
IntType i2(i/2);
|
||||
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
|
||||
typedef typename MyStdMap::value_type StdValueType;
|
||||
typedef typename MyStdMap::key_type StdKeyType;
|
||||
typedef typename MyStdMap::mapped_type StdMappedType;
|
||||
StdValueType aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
new(&aux_vect2[i])StdValueType(StdKeyType(i/2), StdMappedType(i/2));
|
||||
}
|
||||
typedef typename MyStdMap::value_type StdValueType;
|
||||
typedef typename MyStdMap::key_type StdKeyType;
|
||||
typedef typename MyStdMap::mapped_type StdMappedType;
|
||||
StdValueType aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
new(&aux_vect2[i])StdValueType(StdKeyType(i/2), StdMappedType(i/2));
|
||||
}
|
||||
|
||||
IntPairType aux_vect3[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(i/2);
|
||||
IntType i2(i/2);
|
||||
new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
IntPairType aux_vect3[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(i/2);
|
||||
IntType i2(i/2);
|
||||
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 + 50));
|
||||
MyStdMap *stdmap2 = new MyStdMap(aux_vect2, aux_vect2 + 50);
|
||||
MyBoostMultiMap *boostmultimap2 = new MyBoostMultiMap
|
||||
, boost::make_move_iterator(&aux_vect[0] + 50));
|
||||
::boost::movelib::unique_ptr<MyStdMap> const pstdmap2 = ::boost::movelib::make_unique<MyStdMap>
|
||||
(&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 + 50));
|
||||
MyStdMultiMap *stdmultimap2 = new MyStdMultiMap(aux_vect2, aux_vect2 + 50);
|
||||
if(!CheckEqualContainers(boostmap2, stdmap2)) return 1;
|
||||
if(!CheckEqualContainers(boostmultimap2, stdmultimap2)) return 1;
|
||||
, boost::make_move_iterator(&aux_vect3[0] + 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;
|
||||
|
||||
//ordered range insertion
|
||||
//This is really nasty, but we have no other simple choice
|
||||
for(int i = 0; i < 50; ++i){
|
||||
if(!CheckEqualContainers(boostmap2, stdmap2)) return 1;
|
||||
if(!CheckEqualContainers(boostmultimap2, stdmultimap2)) return 1;
|
||||
|
||||
//ordered range insertion
|
||||
//This is really nasty, but we have no other simple choice
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
new(&aux_vect2[i])StdValueType(StdKeyType(i), StdMappedType(i));
|
||||
}
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
if(!CheckEqualContainers(boostmap2, stdmap2)) return 1;
|
||||
if(!CheckEqualContainers(boostmultimap2, stdmultimap2)) return 1;
|
||||
|
||||
::boost::movelib::unique_ptr<MyBoostMap> const pboostmap3 = ::boost::movelib::make_unique<MyBoostMap>
|
||||
( boost::make_move_iterator(&aux_vect[0])
|
||||
, boost::make_move_iterator(&aux_vect[0] + 50));
|
||||
::boost::movelib::unique_ptr<MyStdMap> const pstdmap3 = ::boost::movelib::make_unique<MyStdMap>
|
||||
(&aux_vect2[0], &aux_vect2[0] + 50);
|
||||
::boost::movelib::unique_ptr<MyBoostMultiMap> const pboostmultimap3 = ::boost::movelib::make_unique<MyBoostMultiMap>
|
||||
( boost::make_move_iterator(&aux_vect3[0])
|
||||
, boost::make_move_iterator(&aux_vect3[0] + 50));
|
||||
::boost::movelib::unique_ptr<MyStdMultiMap> const pstdmultimap3 = ::boost::movelib::make_unique<MyStdMultiMap>
|
||||
(&aux_vect2[0], &aux_vect2[0] + 50);
|
||||
MyBoostMap &boostmap3 = *pboostmap3;
|
||||
MyStdMap &stdmap3 = *pstdmap3;
|
||||
MyBoostMultiMap &boostmultimap3 = *pboostmultimap3;
|
||||
MyStdMultiMap &stdmultimap3 = *pstdmultimap3;
|
||||
|
||||
if(!CheckEqualContainers(boostmap3, stdmap3)){
|
||||
std::cout << "Error in construct<MyBoostMap>(MyBoostMap3)" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
if(!CheckEqualContainers(boostmultimap3, stdmultimap3)){
|
||||
std::cout << "Error in construct<MyBoostMultiMap>(MyBoostMultiMap3)" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
{
|
||||
IntType i0(0);
|
||||
boostmap2.erase(i0);
|
||||
boostmultimap2.erase(i0);
|
||||
stdmap2.erase(0);
|
||||
stdmultimap2.erase(0);
|
||||
}
|
||||
{
|
||||
IntType i0(0);
|
||||
IntType i1(1);
|
||||
boostmap2[::boost::move(i0)] = ::boost::move(i1);
|
||||
}
|
||||
{
|
||||
IntType i1(1);
|
||||
boostmap2[IntType(0)] = ::boost::move(i1);
|
||||
}
|
||||
stdmap2[0] = 1;
|
||||
if(!CheckEqualContainers(boostmap2, stdmap2)) return 1;
|
||||
}
|
||||
{
|
||||
//This is really nasty, but we have no other simple choice
|
||||
IntPairType aux_vect[max];
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
IntPairType aux_vect3[max];
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
boostmap.insert(boost::move(aux_vect[i]));
|
||||
stdmap.insert(StdPairType(i, i));
|
||||
boostmultimap.insert(boost::move(aux_vect3[i]));
|
||||
stdmultimap.insert(StdPairType(i, i));
|
||||
}
|
||||
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
|
||||
typename MyBoostMap::iterator it = boostmap.begin();
|
||||
typename MyBoostMap::const_iterator cit = it;
|
||||
(void)cit;
|
||||
|
||||
boostmap.erase(boostmap.begin());
|
||||
stdmap.erase(stdmap.begin());
|
||||
boostmultimap.erase(boostmultimap.begin());
|
||||
stdmultimap.erase(stdmultimap.begin());
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
|
||||
boostmap.erase(boostmap.begin());
|
||||
stdmap.erase(stdmap.begin());
|
||||
boostmultimap.erase(boostmultimap.begin());
|
||||
stdmultimap.erase(stdmultimap.begin());
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
|
||||
//Swapping test
|
||||
MyBoostMap tmpboostemap2;
|
||||
MyStdMap tmpstdmap2;
|
||||
MyBoostMultiMap tmpboostemultimap2;
|
||||
MyStdMultiMap tmpstdmultimap2;
|
||||
boostmap.swap(tmpboostemap2);
|
||||
stdmap.swap(tmpstdmap2);
|
||||
boostmultimap.swap(tmpboostemultimap2);
|
||||
stdmultimap.swap(tmpstdmultimap2);
|
||||
boostmap.swap(tmpboostemap2);
|
||||
stdmap.swap(tmpstdmap2);
|
||||
boostmultimap.swap(tmpboostemultimap2);
|
||||
stdmultimap.swap(tmpstdmultimap2);
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
}
|
||||
//Insertion from other container
|
||||
//Initialize values
|
||||
{
|
||||
//This is really nasty, but we have no other simple choice
|
||||
IntPairType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(-1);
|
||||
IntType i2(-1);
|
||||
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
IntPairType aux_vect3[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(-1);
|
||||
IntType i2(-1);
|
||||
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[0] + 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){
|
||||
StdPairType stdpairtype(-1, -1);
|
||||
stdmap.insert(stdpairtype);
|
||||
stdmultimap.insert(stdpairtype);
|
||||
}
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
|
||||
for(int i = 0, j = static_cast<int>(boostmap.size()); i < j; ++i){
|
||||
boostmap.erase(IntType(i));
|
||||
stdmap.erase(i);
|
||||
boostmultimap.erase(IntType(i));
|
||||
stdmultimap.erase(i);
|
||||
}
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
}
|
||||
{
|
||||
IntPairType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(-1);
|
||||
IntType i2(-1);
|
||||
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
|
||||
IntPairType aux_vect3[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(-1);
|
||||
IntType i2(-1);
|
||||
new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
|
||||
IntPairType aux_vect4[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(-1);
|
||||
IntType i2(-1);
|
||||
new(&aux_vect4[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
|
||||
IntPairType aux_vect5[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(-1);
|
||||
IntType i2(-1);
|
||||
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[0] + 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_vect5[0]), boost::make_move_iterator(aux_vect5 + 50));
|
||||
|
||||
for(std::size_t i = 0; i != 50; ++i){
|
||||
StdPairType stdpairtype(-1, -1);
|
||||
stdmap.insert(stdpairtype);
|
||||
stdmultimap.insert(stdpairtype);
|
||||
stdmap.insert(stdpairtype);
|
||||
stdmultimap.insert(stdpairtype);
|
||||
}
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
|
||||
boostmap.erase(boostmap.begin()->first);
|
||||
stdmap.erase(stdmap.begin()->first);
|
||||
boostmultimap.erase(boostmultimap.begin()->first);
|
||||
stdmultimap.erase(stdmultimap.begin()->first);
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
}
|
||||
|
||||
{
|
||||
//This is really nasty, but we have no other simple choice
|
||||
IntPairType aux_vect[max];
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
IntPairType aux_vect3[max];
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
boostmap.insert(boost::move(aux_vect[i]));
|
||||
stdmap.insert(StdPairType(i, i));
|
||||
boostmultimap.insert(boost::move(aux_vect3[i]));
|
||||
stdmultimap.insert(StdPairType(i, i));
|
||||
}
|
||||
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntPairType intpair;
|
||||
{
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
new(&aux_vect2[i])StdValueType(StdKeyType(i), StdMappedType(i));
|
||||
}
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
boostmap.insert(boostmap.begin(), boost::move(intpair));
|
||||
stdmap.insert(stdmap.begin(), StdPairType(i, i));
|
||||
//PrintContainers(boostmap, stdmap);
|
||||
{
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
boostmultimap.insert(boostmultimap.begin(), boost::move(intpair));
|
||||
stdmultimap.insert(stdmultimap.begin(), StdPairType(i, i));
|
||||
//PrintContainers(boostmultimap, stdmultimap);
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap))
|
||||
return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap))
|
||||
return 1;
|
||||
{
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
boostmap.insert(boostmap.end(), boost::move(intpair));
|
||||
stdmap.insert(stdmap.end(), StdPairType(i, i));
|
||||
{
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
boostmultimap.insert(boostmultimap.end(), boost::move(intpair));
|
||||
stdmultimap.insert(stdmultimap.end(), StdPairType(i, i));
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap))
|
||||
return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap))
|
||||
return 1;
|
||||
{
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
boostmap.insert(boostmap.lower_bound(IntType(i)), boost::move(intpair));
|
||||
stdmap.insert(stdmap.lower_bound(i), StdPairType(i, i));
|
||||
//PrintContainers(boostmap, stdmap);
|
||||
{
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
{
|
||||
IntType i1(i);
|
||||
boostmultimap.insert(boostmultimap.lower_bound(boost::move(i1)), boost::move(intpair));
|
||||
stdmultimap.insert(stdmultimap.lower_bound(i), StdPairType(i, i));
|
||||
}
|
||||
if(!CheckEqualContainers(boostmap2, stdmap2)) return 1;
|
||||
if(!CheckEqualContainers(boostmultimap2, stdmultimap2)) return 1;
|
||||
|
||||
MyBoostMap *boostmap3 = new MyBoostMap
|
||||
( ordered_unique_range
|
||||
, boost::make_move_iterator(&aux_vect[0])
|
||||
, boost::make_move_iterator(aux_vect + 50));
|
||||
MyStdMap *stdmap3 = new MyStdMap(aux_vect2, aux_vect2 + 50);
|
||||
MyBoostMultiMap *boostmultimap3 = new MyBoostMultiMap
|
||||
( ordered_range
|
||||
, boost::make_move_iterator(&aux_vect3[0])
|
||||
, boost::make_move_iterator(aux_vect3 + 50));
|
||||
MyStdMultiMap *stdmultimap3 = new MyStdMultiMap(aux_vect2, aux_vect2 + 50);
|
||||
//PrintContainers(boostmultimap, stdmultimap);
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap))
|
||||
return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap))
|
||||
return 1;
|
||||
{ //Check equal_range
|
||||
std::pair<typename MyBoostMultiMap::iterator, typename MyBoostMultiMap::iterator> bret =
|
||||
boostmultimap.equal_range(boostmultimap.begin()->first);
|
||||
|
||||
if(!CheckEqualContainers(boostmap3, stdmap3)){
|
||||
std::cout << "Error in construct<MyBoostMap>(MyBoostMap3)" << std::endl;
|
||||
std::pair<typename MyStdMultiMap::iterator, typename MyStdMultiMap::iterator> sret =
|
||||
stdmultimap.equal_range(stdmultimap.begin()->first);
|
||||
|
||||
if( std::distance(bret.first, bret.second) !=
|
||||
std::distance(sret.first, sret.second) ){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
{
|
||||
IntType i1(i);
|
||||
boostmap.insert(boostmap.upper_bound(boost::move(i1)), boost::move(intpair));
|
||||
stdmap.insert(stdmap.upper_bound(i), StdPairType(i, i));
|
||||
}
|
||||
//PrintContainers(boostmap, stdmap);
|
||||
{
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
{
|
||||
IntType i1(i);
|
||||
boostmultimap.insert(boostmultimap.upper_bound(boost::move(i1)), boost::move(intpair));
|
||||
stdmultimap.insert(stdmultimap.upper_bound(i), StdPairType(i, i));
|
||||
}
|
||||
//PrintContainers(boostmultimap, stdmultimap);
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap))
|
||||
return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap))
|
||||
return 1;
|
||||
|
||||
map_test_rebalanceable(boostmap
|
||||
, container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostMap>::value>());
|
||||
if(!CheckEqualContainers(boostmap, stdmap)){
|
||||
std::cout << "Error in boostmap.rebalance()" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
if(!CheckEqualContainers(boostmultimap3, stdmultimap3)){
|
||||
std::cout << "Error in construct<MyBoostMultiMap>(MyBoostMultiMap3)" << std::endl;
|
||||
map_test_rebalanceable(boostmultimap
|
||||
, container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostMultiMap>::value>());
|
||||
if(!CheckEqualContainers(boostmultimap, stdmultimap)){
|
||||
std::cout << "Error in boostmultimap.rebalance()" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
//Compare count with std containers
|
||||
for(int i = 0; i < max; ++i){
|
||||
if(boostmap.count(IntType(i)) != stdmap.count(i)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(boostmultimap.count(IntType(i)) != stdmultimap.count(i)){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
//Now do count exercise
|
||||
boostmap.erase(boostmap.begin(), boostmap.end());
|
||||
boostmultimap.erase(boostmultimap.begin(), boostmultimap.end());
|
||||
boostmap.clear();
|
||||
boostmultimap.clear();
|
||||
|
||||
for(int j = 0; j < 3; ++j)
|
||||
for(int i = 0; i < 100; ++i){
|
||||
IntPairType intpair;
|
||||
{
|
||||
IntType i0(0);
|
||||
boostmap2->erase(i0);
|
||||
boostmultimap2->erase(i0);
|
||||
stdmap2->erase(0);
|
||||
stdmultimap2->erase(0);
|
||||
IntType i1(i), i2(i);
|
||||
new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
boostmap.insert(boost::move(intpair));
|
||||
{
|
||||
IntType i0(0);
|
||||
IntType i1(1);
|
||||
(*boostmap2)[::boost::move(i0)] = ::boost::move(i1);
|
||||
}
|
||||
{
|
||||
IntType i1(1);
|
||||
(*boostmap2)[IntType(0)] = ::boost::move(i1);
|
||||
}
|
||||
(*stdmap2)[0] = 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
|
||||
IntPairType aux_vect[max];
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
IntPairType aux_vect3[max];
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
boostmap->insert(boost::move(aux_vect[i]));
|
||||
stdmap->insert(StdPairType(i, i));
|
||||
boostmultimap->insert(boost::move(aux_vect3[i]));
|
||||
stdmultimap->insert(StdPairType(i, i));
|
||||
}
|
||||
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
|
||||
typename MyBoostMap::iterator it = boostmap->begin();
|
||||
typename MyBoostMap::const_iterator cit = it;
|
||||
(void)cit;
|
||||
|
||||
boostmap->erase(boostmap->begin());
|
||||
stdmap->erase(stdmap->begin());
|
||||
boostmultimap->erase(boostmultimap->begin());
|
||||
stdmultimap->erase(stdmultimap->begin());
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
|
||||
boostmap->erase(boostmap->begin());
|
||||
stdmap->erase(stdmap->begin());
|
||||
boostmultimap->erase(boostmultimap->begin());
|
||||
stdmultimap->erase(stdmultimap->begin());
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
|
||||
//Swapping test
|
||||
MyBoostMap tmpboostemap2;
|
||||
MyStdMap tmpstdmap2;
|
||||
MyBoostMultiMap tmpboostemultimap2;
|
||||
MyStdMultiMap tmpstdmultimap2;
|
||||
boostmap->swap(tmpboostemap2);
|
||||
stdmap->swap(tmpstdmap2);
|
||||
boostmultimap->swap(tmpboostemultimap2);
|
||||
stdmultimap->swap(tmpstdmultimap2);
|
||||
boostmap->swap(tmpboostemap2);
|
||||
stdmap->swap(tmpstdmap2);
|
||||
boostmultimap->swap(tmpboostemultimap2);
|
||||
stdmultimap->swap(tmpstdmultimap2);
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
}
|
||||
//Insertion from other container
|
||||
//Initialize values
|
||||
{
|
||||
//This is really nasty, but we have no other simple choice
|
||||
IntPairType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(-1);
|
||||
IntType i2(-1);
|
||||
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
IntPairType aux_vect3[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(-1);
|
||||
IntType i2(-1);
|
||||
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));
|
||||
boostmultimap->insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(aux_vect3 + 50));
|
||||
for(std::size_t i = 0; i != 50; ++i){
|
||||
StdPairType stdpairtype(-1, -1);
|
||||
stdmap->insert(stdpairtype);
|
||||
stdmultimap->insert(stdpairtype);
|
||||
}
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
|
||||
for(int i = 0, j = static_cast<int>(boostmap->size()); i < j; ++i){
|
||||
boostmap->erase(IntType(i));
|
||||
stdmap->erase(i);
|
||||
boostmultimap->erase(IntType(i));
|
||||
stdmultimap->erase(i);
|
||||
}
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
}
|
||||
{
|
||||
IntPairType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(-1);
|
||||
IntType i2(-1);
|
||||
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
|
||||
IntPairType aux_vect3[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(-1);
|
||||
IntType i2(-1);
|
||||
new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
|
||||
IntPairType aux_vect4[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(-1);
|
||||
IntType i2(-1);
|
||||
new(&aux_vect4[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
|
||||
IntPairType aux_vect5[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType i1(-1);
|
||||
IntType i2(-1);
|
||||
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_vect3[0]), boost::make_move_iterator(aux_vect3 + 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));
|
||||
|
||||
for(std::size_t i = 0; i != 50; ++i){
|
||||
StdPairType stdpairtype(-1, -1);
|
||||
stdmap->insert(stdpairtype);
|
||||
stdmultimap->insert(stdpairtype);
|
||||
stdmap->insert(stdpairtype);
|
||||
stdmultimap->insert(stdpairtype);
|
||||
}
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
|
||||
boostmap->erase(boostmap->begin()->first);
|
||||
stdmap->erase(stdmap->begin()->first);
|
||||
boostmultimap->erase(boostmultimap->begin()->first);
|
||||
stdmultimap->erase(stdmultimap->begin()->first);
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
}
|
||||
|
||||
{
|
||||
//This is really nasty, but we have no other simple choice
|
||||
IntPairType aux_vect[max];
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
IntPairType aux_vect3[max];
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
boostmap->insert(boost::move(aux_vect[i]));
|
||||
stdmap->insert(StdPairType(i, i));
|
||||
boostmultimap->insert(boost::move(aux_vect3[i]));
|
||||
stdmultimap->insert(StdPairType(i, i));
|
||||
}
|
||||
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntPairType intpair;
|
||||
{
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
boostmap->insert(boostmap->begin(), boost::move(intpair));
|
||||
stdmap->insert(stdmap->begin(), StdPairType(i, i));
|
||||
//PrintContainers(boostmap, stdmap);
|
||||
{
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
boostmultimap->insert(boostmultimap->begin(), boost::move(intpair));
|
||||
stdmultimap->insert(stdmultimap->begin(), StdPairType(i, i));
|
||||
//PrintContainers(boostmultimap, stdmultimap);
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap))
|
||||
return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap))
|
||||
return 1;
|
||||
{
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
boostmap->insert(boostmap->end(), boost::move(intpair));
|
||||
stdmap->insert(stdmap->end(), StdPairType(i, i));
|
||||
{
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
boostmultimap->insert(boostmultimap->end(), boost::move(intpair));
|
||||
stdmultimap->insert(stdmultimap->end(), StdPairType(i, i));
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap))
|
||||
return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap))
|
||||
return 1;
|
||||
{
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
boostmap->insert(boostmap->lower_bound(IntType(i)), boost::move(intpair));
|
||||
stdmap->insert(stdmap->lower_bound(i), StdPairType(i, i));
|
||||
//PrintContainers(boostmap, stdmap);
|
||||
{
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
{
|
||||
IntType i1(i);
|
||||
boostmultimap->insert(boostmultimap->lower_bound(boost::move(i1)), boost::move(intpair));
|
||||
stdmultimap->insert(stdmultimap->lower_bound(i), StdPairType(i, i));
|
||||
}
|
||||
|
||||
//PrintContainers(boostmultimap, stdmultimap);
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap))
|
||||
return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap))
|
||||
return 1;
|
||||
{ //Check equal_range
|
||||
std::pair<typename MyBoostMultiMap::iterator, typename MyBoostMultiMap::iterator> bret =
|
||||
boostmultimap->equal_range(boostmultimap->begin()->first);
|
||||
|
||||
std::pair<typename MyStdMultiMap::iterator, typename MyStdMultiMap::iterator> sret =
|
||||
stdmultimap->equal_range(stdmultimap->begin()->first);
|
||||
|
||||
if( std::distance(bret.first, bret.second) !=
|
||||
std::distance(sret.first, sret.second) ){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
{
|
||||
IntType i1(i);
|
||||
boostmap->insert(boostmap->upper_bound(boost::move(i1)), boost::move(intpair));
|
||||
stdmap->insert(stdmap->upper_bound(i), StdPairType(i, i));
|
||||
}
|
||||
//PrintContainers(boostmap, stdmap);
|
||||
{
|
||||
IntType i1(i);
|
||||
IntType i2(i);
|
||||
new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
{
|
||||
IntType i1(i);
|
||||
boostmultimap->insert(boostmultimap->upper_bound(boost::move(i1)), boost::move(intpair));
|
||||
stdmultimap->insert(stdmultimap->upper_bound(i), StdPairType(i, i));
|
||||
}
|
||||
//PrintContainers(boostmultimap, stdmultimap);
|
||||
if(!CheckEqualPairContainers(boostmap, stdmap))
|
||||
return 1;
|
||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap))
|
||||
return 1;
|
||||
|
||||
map_test_rebalanceable(*boostmap
|
||||
, container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostMap>::value>());
|
||||
if(!CheckEqualContainers(boostmap, stdmap)){
|
||||
std::cout << "Error in boostmap->rebalance()" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
map_test_rebalanceable(*boostmultimap
|
||||
, container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostMultiMap>::value>());
|
||||
if(!CheckEqualContainers(boostmultimap, stdmultimap)){
|
||||
std::cout << "Error in boostmultimap->rebalance()" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
//Compare count with std containers
|
||||
for(int i = 0; i < max; ++i){
|
||||
if(boostmap->count(IntType(i)) != stdmap->count(i)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(boostmultimap->count(IntType(i)) != stdmultimap->count(i)){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
//Now do count exercise
|
||||
boostmap->erase(boostmap->begin(), boostmap->end());
|
||||
boostmultimap->erase(boostmultimap->begin(), boostmultimap->end());
|
||||
boostmap->clear();
|
||||
boostmultimap->clear();
|
||||
|
||||
for(int j = 0; j < 3; ++j)
|
||||
for(int i = 0; i < 100; ++i){
|
||||
IntPairType intpair;
|
||||
{
|
||||
IntType i1(i), i2(i);
|
||||
new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
boostmap->insert(boost::move(intpair));
|
||||
{
|
||||
IntType i1(i), i2(i);
|
||||
new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
|
||||
}
|
||||
boostmultimap->insert(boost::move(intpair));
|
||||
if(boostmap->count(IntType(i)) != typename MyBoostMultiMap::size_type(1))
|
||||
return 1;
|
||||
if(boostmultimap->count(IntType(i)) != typename MyBoostMultiMap::size_type(j+1))
|
||||
return 1;
|
||||
}
|
||||
boostmultimap.insert(boost::move(intpair));
|
||||
if(boostmap.count(IntType(i)) != typename MyBoostMultiMap::size_type(1))
|
||||
return 1;
|
||||
if(boostmultimap.count(IntType(i)) != typename MyBoostMultiMap::size_type(j+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>
|
||||
(container_detail::bool_<boost::container::test::is_copyable<IntType>::value>())){
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include "print_container.hpp"
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/move/iterator.hpp>
|
||||
#include <boost/move/make_unique.hpp>
|
||||
#include <string>
|
||||
|
||||
#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)
|
||||
{
|
||||
typedef typename MyBoostSet::value_type IntType;
|
||||
const int max = 100;
|
||||
const int max = 50;
|
||||
|
||||
BOOST_TRY{
|
||||
MyBoostSet *boostset = new MyBoostSet;
|
||||
MyStdSet *stdset = new MyStdSet;
|
||||
MyBoostMultiSet *boostmultiset = new MyBoostMultiSet;
|
||||
MyStdMultiSet *stdmultiset = new MyStdMultiSet;
|
||||
::boost::movelib::unique_ptr<MyBoostSet> const pboostset = ::boost::movelib::make_unique<MyBoostSet>();
|
||||
::boost::movelib::unique_ptr<MyStdSet> const pstdset = ::boost::movelib::make_unique<MyStdSet>();
|
||||
::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset = ::boost::movelib::make_unique<MyBoostMultiSet>();
|
||||
::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset = ::boost::movelib::make_unique<MyStdMultiSet>();
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType move_me(i);
|
||||
boostset->insert(boost::move(move_me));
|
||||
stdset->insert(i);
|
||||
IntType move_me2(i);
|
||||
boostmultiset->insert(boost::move(move_me2));
|
||||
stdmultiset->insert(i);
|
||||
}
|
||||
if(!CheckEqualContainers(boostset, stdset)) return 1;
|
||||
if(!CheckEqualContainers(boostmultiset, stdmultiset)) return 1;
|
||||
MyBoostSet &boostset = *pboostset;
|
||||
MyStdSet &stdset = *pstdset;
|
||||
MyBoostMultiSet &boostmultiset = *pboostmultiset;
|
||||
MyStdMultiSet &stdmultiset = *pstdmultiset;
|
||||
|
||||
{
|
||||
//Now, test copy constructor
|
||||
MyBoostSet boostsetcopy(*boostset);
|
||||
MyStdSet stdsetcopy(*stdset);
|
||||
|
||||
if(!CheckEqualContainers(&boostsetcopy, &stdsetcopy))
|
||||
return 1;
|
||||
|
||||
MyBoostMultiSet boostmsetcopy(*boostmultiset);
|
||||
MyStdMultiSet stdmsetcopy(*stdmultiset);
|
||||
|
||||
if(!CheckEqualContainers(&boostmsetcopy, &stdmsetcopy))
|
||||
return 1;
|
||||
|
||||
//And now assignment
|
||||
boostsetcopy = *boostset;
|
||||
stdsetcopy = *stdset;
|
||||
|
||||
if(!CheckEqualContainers(&boostsetcopy, &stdsetcopy))
|
||||
return 1;
|
||||
|
||||
boostmsetcopy = *boostmultiset;
|
||||
stdmsetcopy = *stdmultiset;
|
||||
|
||||
if(!CheckEqualContainers(&boostmsetcopy, &stdmsetcopy))
|
||||
return 1;
|
||||
}
|
||||
delete boostset;
|
||||
delete boostmultiset;
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType move_me(i);
|
||||
boostset.insert(boost::move(move_me));
|
||||
stdset.insert(i);
|
||||
IntType move_me2(i);
|
||||
boostmultiset.insert(boost::move(move_me2));
|
||||
stdmultiset.insert(i);
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
BOOST_RETHROW;
|
||||
if(!CheckEqualContainers(boostset, stdset)) return 1;
|
||||
if(!CheckEqualContainers(boostmultiset, stdmultiset)) return 1;
|
||||
|
||||
{
|
||||
//Now, test copy constructor
|
||||
MyBoostSet boostsetcopy(boostset);
|
||||
MyStdSet stdsetcopy(stdset);
|
||||
|
||||
if(!CheckEqualContainers(boostsetcopy, stdsetcopy))
|
||||
return 1;
|
||||
|
||||
MyBoostMultiSet boostmsetcopy(boostmultiset);
|
||||
MyStdMultiSet stdmsetcopy(stdmultiset);
|
||||
|
||||
if(!CheckEqualContainers(boostmsetcopy, stdmsetcopy))
|
||||
return 1;
|
||||
|
||||
//And now assignment
|
||||
boostsetcopy =boostset;
|
||||
stdsetcopy = stdset;
|
||||
|
||||
if(!CheckEqualContainers(boostsetcopy, stdsetcopy))
|
||||
return 1;
|
||||
|
||||
boostmsetcopy = boostmultiset;
|
||||
stdmsetcopy = stdmultiset;
|
||||
|
||||
if(!CheckEqualContainers(boostmsetcopy, stdmsetcopy))
|
||||
return 1;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -121,12 +119,17 @@ template<class MyBoostSet
|
||||
int set_test ()
|
||||
{
|
||||
typedef typename MyBoostSet::value_type IntType;
|
||||
const int max = 100;
|
||||
const int max = 50;
|
||||
|
||||
MyBoostSet *boostset = new MyBoostSet;
|
||||
MyStdSet *stdset = new MyStdSet;
|
||||
MyBoostMultiSet *boostmultiset = new MyBoostMultiSet;
|
||||
MyStdMultiSet *stdmultiset = new MyStdMultiSet;
|
||||
::boost::movelib::unique_ptr<MyBoostSet> const pboostset = ::boost::movelib::make_unique<MyBoostSet>();
|
||||
::boost::movelib::unique_ptr<MyStdSet> const pstdset = ::boost::movelib::make_unique<MyStdSet>();
|
||||
::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset = ::boost::movelib::make_unique<MyBoostMultiSet>();
|
||||
::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
|
||||
{
|
||||
@@ -145,14 +148,22 @@ int set_test ()
|
||||
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 + 50));
|
||||
MyStdSet *stdset2 = new MyStdSet(aux_vect2, aux_vect2 + 50);
|
||||
MyBoostMultiSet *boostmultiset2 = new MyBoostMultiSet
|
||||
::boost::movelib::unique_ptr<MyStdSet> const pstdset2 = ::boost::movelib::make_unique<MyStdSet>
|
||||
(&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 + 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)){
|
||||
std::cout << "Error in construct<MyBoostSet>(MyBoostSet2)" << std::endl;
|
||||
return 1;
|
||||
@@ -177,16 +188,25 @@ int set_test ()
|
||||
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
|
||||
, boost::make_move_iterator(&aux_vect[0])
|
||||
, boost::make_move_iterator(aux_vect + 50));
|
||||
MyStdSet *stdset3 = new MyStdSet(aux_vect2, aux_vect2 + 50);
|
||||
MyBoostMultiSet *boostmultiset3 = new MyBoostMultiSet
|
||||
, boost::make_move_iterator(&aux_vect[0] + 50));
|
||||
::boost::movelib::unique_ptr<MyStdSet> const pstdset3 = ::boost::movelib::make_unique<MyStdSet>
|
||||
(&aux_vect2[0], &aux_vect2[0] + 50);
|
||||
::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset3 = ::boost::movelib::make_unique<MyBoostMultiSet>
|
||||
( ordered_range
|
||||
, boost::make_move_iterator(&aux_vect3[0])
|
||||
, 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)){
|
||||
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;
|
||||
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){
|
||||
IntType move_me(i);
|
||||
boostset->insert(boost::move(move_me));
|
||||
stdset->insert(i);
|
||||
boostset->insert(IntType(i));
|
||||
stdset->insert(i);
|
||||
boostset.insert(boost::move(move_me));
|
||||
stdset.insert(i);
|
||||
boostset.insert(IntType(i));
|
||||
stdset.insert(i);
|
||||
IntType move_me2(i);
|
||||
boostmultiset->insert(boost::move(move_me2));
|
||||
stdmultiset->insert(i);
|
||||
boostmultiset->insert(IntType(i));
|
||||
stdmultiset->insert(i);
|
||||
boostmultiset.insert(boost::move(move_me2));
|
||||
stdmultiset.insert(i);
|
||||
boostmultiset.insert(IntType(i));
|
||||
stdmultiset.insert(i);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
typename MyBoostSet::iterator it = boostset->begin();
|
||||
typename MyBoostSet::iterator it = boostset.begin();
|
||||
typename MyBoostSet::const_iterator cit = it;
|
||||
(void)cit;
|
||||
|
||||
boostset->erase(boostset->begin());
|
||||
stdset->erase(stdset->begin());
|
||||
boostmultiset->erase(boostmultiset->begin());
|
||||
stdmultiset->erase(stdmultiset->begin());
|
||||
boostset.erase(boostset.begin());
|
||||
stdset.erase(stdset.begin());
|
||||
boostmultiset.erase(boostmultiset.begin());
|
||||
stdmultiset.erase(stdmultiset.begin());
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
boostset->erase(boostset->begin());
|
||||
stdset->erase(stdset->begin());
|
||||
boostmultiset->erase(boostmultiset->begin());
|
||||
stdmultiset->erase(stdmultiset->begin());
|
||||
boostset.erase(boostset.begin());
|
||||
stdset.erase(stdset.begin());
|
||||
boostmultiset.erase(boostmultiset.begin());
|
||||
stdmultiset.erase(stdmultiset.begin());
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -265,20 +276,20 @@ int set_test ()
|
||||
MyStdSet tmpstdset2;
|
||||
MyBoostMultiSet tmpboostemultiset2;
|
||||
MyStdMultiSet tmpstdmultiset2;
|
||||
boostset->swap(tmpboosteset2);
|
||||
stdset->swap(tmpstdset2);
|
||||
boostmultiset->swap(tmpboostemultiset2);
|
||||
stdmultiset->swap(tmpstdmultiset2);
|
||||
boostset->swap(tmpboosteset2);
|
||||
stdset->swap(tmpstdset2);
|
||||
boostmultiset->swap(tmpboostemultiset2);
|
||||
stdmultiset->swap(tmpstdmultiset2);
|
||||
boostset.swap(tmpboosteset2);
|
||||
stdset.swap(tmpstdset2);
|
||||
boostmultiset.swap(tmpboostemultiset2);
|
||||
stdmultiset.swap(tmpstdmultiset2);
|
||||
boostset.swap(tmpboosteset2);
|
||||
stdset.swap(tmpstdset2);
|
||||
boostmultiset.swap(tmpboostemultiset2);
|
||||
stdmultiset.swap(tmpstdmultiset2);
|
||||
if(!CheckEqualContainers(boostset, stdset)){
|
||||
std::cout << "Error in boostset->swap(tmpboosteset2)" << std::endl;
|
||||
std::cout << "Error in boostset.swap(tmpboosteset2)" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
if(!CheckEqualContainers(boostmultiset, stdmultiset)){
|
||||
std::cout << "Error in boostmultiset->swap(tmpboostemultiset2)" << std::endl;
|
||||
std::cout << "Error in boostmultiset.swap(tmpboostemultiset2)" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -300,31 +311,31 @@ int set_test ()
|
||||
aux_vect3[i] = boost::move(move_me);
|
||||
}
|
||||
|
||||
boostset->insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(aux_vect + 50));
|
||||
stdset->insert(aux_vect2, aux_vect2 + 50);
|
||||
boostmultiset->insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(aux_vect3 + 50));
|
||||
stdmultiset->insert(aux_vect2, aux_vect2 + 50);
|
||||
boostset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + 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));
|
||||
stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
boostset->erase(erase_me);
|
||||
stdset->erase(i);
|
||||
boostmultiset->erase(erase_me);
|
||||
stdmultiset->erase(i);
|
||||
boostset.erase(erase_me);
|
||||
stdset.erase(i);
|
||||
boostmultiset.erase(erase_me);
|
||||
stdmultiset.erase(i);
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -357,104 +368,104 @@ int set_test ()
|
||||
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_vect3[0]), boost::make_move_iterator(aux_vect3 + 50));
|
||||
stdset->insert(aux_vect2, aux_vect2 + 50);
|
||||
stdset->insert(aux_vect2, aux_vect2 + 50);
|
||||
boostmultiset->insert(boost::make_move_iterator(&aux_vect4[0]), boost::make_move_iterator(aux_vect4 + 50));
|
||||
boostmultiset->insert(boost::make_move_iterator(&aux_vect5[0]), boost::make_move_iterator(aux_vect5 + 50));
|
||||
stdmultiset->insert(aux_vect2, aux_vect2 + 50);
|
||||
stdmultiset->insert(aux_vect2, aux_vect2 + 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[0] + 50));
|
||||
stdset.insert(&aux_vect2[0], &aux_vect2[0] + 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[0] + 50));
|
||||
boostmultiset.insert(boost::make_move_iterator(&aux_vect5[0]), boost::make_move_iterator(&aux_vect5[0] + 50));
|
||||
stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
|
||||
stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
boostset->erase(*boostset->begin());
|
||||
stdset->erase(*stdset->begin());
|
||||
boostmultiset->erase(*boostmultiset->begin());
|
||||
stdmultiset->erase(*stdmultiset->begin());
|
||||
boostset.erase(*boostset.begin());
|
||||
stdset.erase(*stdset.begin());
|
||||
boostmultiset.erase(*boostmultiset.begin());
|
||||
stdmultiset.erase(*stdmultiset.begin());
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType move_me(i);
|
||||
boostset->insert(boost::move(move_me));
|
||||
stdset->insert(i);
|
||||
boostset.insert(boost::move(move_me));
|
||||
stdset.insert(i);
|
||||
IntType move_me2(i);
|
||||
boostmultiset->insert(boost::move(move_me2));
|
||||
stdmultiset->insert(i);
|
||||
boostmultiset.insert(boost::move(move_me2));
|
||||
stdmultiset.insert(i);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
{
|
||||
IntType move_me(i);
|
||||
boostset->insert(boostset->begin(), boost::move(move_me));
|
||||
stdset->insert(stdset->begin(), i);
|
||||
boostset.insert(boostset.begin(), boost::move(move_me));
|
||||
stdset.insert(stdset.begin(), i);
|
||||
//PrintContainers(boostset, stdset);
|
||||
IntType move_me2(i);
|
||||
boostmultiset->insert(boostmultiset->begin(), boost::move(move_me2));
|
||||
stdmultiset->insert(stdmultiset->begin(), i);
|
||||
boostmultiset.insert(boostmultiset.begin(), boost::move(move_me2));
|
||||
stdmultiset.insert(stdmultiset.begin(), i);
|
||||
//PrintContainers(boostmultiset, stdmultiset);
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
IntType move_me3(i);
|
||||
boostset->insert(boostset->end(), boost::move(move_me3));
|
||||
stdset->insert(stdset->end(), i);
|
||||
boostset.insert(boostset.end(), boost::move(move_me3));
|
||||
stdset.insert(stdset.end(), i);
|
||||
IntType move_me4(i);
|
||||
boostmultiset->insert(boostmultiset->end(), boost::move(move_me4));
|
||||
stdmultiset->insert(stdmultiset->end(), i);
|
||||
boostmultiset.insert(boostmultiset.end(), boost::move(move_me4));
|
||||
stdmultiset.insert(stdmultiset.end(), i);
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
{
|
||||
IntType move_me(i);
|
||||
boostset->insert(boostset->upper_bound(move_me), boost::move(move_me));
|
||||
stdset->insert(stdset->upper_bound(i), i);
|
||||
boostset.insert(boostset.upper_bound(move_me), boost::move(move_me));
|
||||
stdset.insert(stdset.upper_bound(i), i);
|
||||
//PrintContainers(boostset, stdset);
|
||||
IntType move_me2(i);
|
||||
boostmultiset->insert(boostmultiset->upper_bound(move_me2), boost::move(move_me2));
|
||||
stdmultiset->insert(stdmultiset->upper_bound(i), i);
|
||||
boostmultiset.insert(boostmultiset.upper_bound(move_me2), boost::move(move_me2));
|
||||
stdmultiset.insert(stdmultiset.upper_bound(i), i);
|
||||
//PrintContainers(boostmultiset, stdmultiset);
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -462,31 +473,31 @@ int set_test ()
|
||||
{
|
||||
IntType move_me(i);
|
||||
IntType move_me2(i);
|
||||
boostset->insert(boostset->lower_bound(move_me), boost::move(move_me2));
|
||||
stdset->insert(stdset->lower_bound(i), i);
|
||||
boostset.insert(boostset.lower_bound(move_me), boost::move(move_me2));
|
||||
stdset.insert(stdset.lower_bound(i), i);
|
||||
//PrintContainers(boostset, stdset);
|
||||
move_me2 = i;
|
||||
boostmultiset->insert(boostmultiset->lower_bound(move_me2), boost::move(move_me2));
|
||||
stdmultiset->insert(stdmultiset->lower_bound(i), i);
|
||||
boostmultiset.insert(boostmultiset.lower_bound(move_me2), boost::move(move_me2));
|
||||
stdmultiset.insert(stdmultiset.lower_bound(i), i);
|
||||
//PrintContainers(boostmultiset, stdmultiset);
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
set_test_rebalanceable(*boostset
|
||||
set_test_rebalanceable(boostset
|
||||
, container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostSet>::value>());
|
||||
if(!CheckEqualContainers(boostset, stdset)){
|
||||
std::cout << "Error in boostset->rebalance()" << std::endl;
|
||||
std::cout << "Error in boostset.rebalance()" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
set_test_rebalanceable(*boostmultiset
|
||||
set_test_rebalanceable(boostmultiset
|
||||
, container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostMultiSet>::value>());
|
||||
if(!CheckEqualContainers(boostmultiset, stdmultiset)){
|
||||
std::cout << "Error in boostmultiset->rebalance()" << std::endl;
|
||||
std::cout << "Error in boostmultiset.rebalance()" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -495,19 +506,19 @@ int set_test ()
|
||||
//Compare count with std containers
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType count_me(i);
|
||||
if(boostset->count(count_me) != stdset->count(i)){
|
||||
if(boostset.count(count_me) != stdset.count(i)){
|
||||
return -1;
|
||||
}
|
||||
if(boostmultiset->count(count_me) != stdmultiset->count(i)){
|
||||
if(boostmultiset.count(count_me) != stdmultiset.count(i)){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
//Compare find/lower_bound/upper_bound in set
|
||||
{
|
||||
typename MyBoostSet::iterator bs_b = boostset->begin();
|
||||
typename MyBoostSet::iterator bs_e = boostset->end();
|
||||
typename MyStdSet::iterator ss_b = stdset->begin();
|
||||
typename MyBoostSet::iterator bs_b = boostset.begin();
|
||||
typename MyBoostSet::iterator bs_e = boostset.end();
|
||||
typename MyStdSet::iterator ss_b = stdset.begin();
|
||||
|
||||
std::size_t i = 0;
|
||||
while(bs_b != bs_e){
|
||||
@@ -515,21 +526,21 @@ int set_test ()
|
||||
typename MyBoostSet::iterator bs_i;
|
||||
typename MyStdSet::iterator ss_i;
|
||||
//find
|
||||
bs_i = boostset->find(*bs_b);
|
||||
ss_i = stdset->find(*ss_b);
|
||||
if(!CheckEqualIt(bs_i, ss_i, *boostset, *stdset)){
|
||||
bs_i = boostset.find(*bs_b);
|
||||
ss_i = stdset.find(*ss_b);
|
||||
if(!CheckEqualIt(bs_i, ss_i, boostset, stdset)){
|
||||
return -1;
|
||||
}
|
||||
//lower bound
|
||||
bs_i = boostset->lower_bound(*bs_b);
|
||||
ss_i = stdset->lower_bound(*ss_b);
|
||||
if(!CheckEqualIt(bs_i, ss_i, *boostset, *stdset)){
|
||||
bs_i = boostset.lower_bound(*bs_b);
|
||||
ss_i = stdset.lower_bound(*ss_b);
|
||||
if(!CheckEqualIt(bs_i, ss_i, boostset, stdset)){
|
||||
return -1;
|
||||
}
|
||||
//upper bound
|
||||
bs_i = boostset->upper_bound(*bs_b);
|
||||
ss_i = stdset->upper_bound(*ss_b);
|
||||
if(!CheckEqualIt(bs_i, ss_i, *boostset, *stdset)){
|
||||
bs_i = boostset.upper_bound(*bs_b);
|
||||
ss_i = stdset.upper_bound(*ss_b);
|
||||
if(!CheckEqualIt(bs_i, ss_i, boostset, stdset)){
|
||||
return -1;
|
||||
}
|
||||
//equal range
|
||||
@@ -537,12 +548,12 @@ int set_test ()
|
||||
,typename MyBoostSet::iterator> bs_ip;
|
||||
std::pair<typename MyStdSet::iterator
|
||||
,typename MyStdSet::iterator> ss_ip;
|
||||
bs_ip = boostset->equal_range(*bs_b);
|
||||
ss_ip = stdset->equal_range(*ss_b);
|
||||
if(!CheckEqualIt(bs_ip.first, ss_ip.first, *boostset, *stdset)){
|
||||
bs_ip = boostset.equal_range(*bs_b);
|
||||
ss_ip = stdset.equal_range(*ss_b);
|
||||
if(!CheckEqualIt(bs_ip.first, ss_ip.first, boostset, stdset)){
|
||||
return -1;
|
||||
}
|
||||
if(!CheckEqualIt(bs_ip.second, ss_ip.second, *boostset, *stdset)){
|
||||
if(!CheckEqualIt(bs_ip.second, ss_ip.second, boostset, stdset)){
|
||||
return -1;
|
||||
}
|
||||
++bs_b;
|
||||
@@ -551,29 +562,29 @@ int set_test ()
|
||||
}
|
||||
//Compare find/lower_bound/upper_bound in multiset
|
||||
{
|
||||
typename MyBoostMultiSet::iterator bm_b = boostmultiset->begin();
|
||||
typename MyBoostMultiSet::iterator bm_e = boostmultiset->end();
|
||||
typename MyStdMultiSet::iterator sm_b = stdmultiset->begin();
|
||||
typename MyBoostMultiSet::iterator bm_b = boostmultiset.begin();
|
||||
typename MyBoostMultiSet::iterator bm_e = boostmultiset.end();
|
||||
typename MyStdMultiSet::iterator sm_b = stdmultiset.begin();
|
||||
|
||||
while(bm_b != bm_e){
|
||||
typename MyBoostMultiSet::iterator bm_i;
|
||||
typename MyStdMultiSet::iterator sm_i;
|
||||
//find
|
||||
bm_i = boostmultiset->find(*bm_b);
|
||||
sm_i = stdmultiset->find(*sm_b);
|
||||
if(!CheckEqualIt(bm_i, sm_i, *boostmultiset, *stdmultiset)){
|
||||
bm_i = boostmultiset.find(*bm_b);
|
||||
sm_i = stdmultiset.find(*sm_b);
|
||||
if(!CheckEqualIt(bm_i, sm_i, boostmultiset, stdmultiset)){
|
||||
return -1;
|
||||
}
|
||||
//lower bound
|
||||
bm_i = boostmultiset->lower_bound(*bm_b);
|
||||
sm_i = stdmultiset->lower_bound(*sm_b);
|
||||
if(!CheckEqualIt(bm_i, sm_i, *boostmultiset, *stdmultiset)){
|
||||
bm_i = boostmultiset.lower_bound(*bm_b);
|
||||
sm_i = stdmultiset.lower_bound(*sm_b);
|
||||
if(!CheckEqualIt(bm_i, sm_i, boostmultiset, stdmultiset)){
|
||||
return -1;
|
||||
}
|
||||
//upper bound
|
||||
bm_i = boostmultiset->upper_bound(*bm_b);
|
||||
sm_i = stdmultiset->upper_bound(*sm_b);
|
||||
if(!CheckEqualIt(bm_i, sm_i, *boostmultiset, *stdmultiset)){
|
||||
bm_i = boostmultiset.upper_bound(*bm_b);
|
||||
sm_i = stdmultiset.upper_bound(*sm_b);
|
||||
if(!CheckEqualIt(bm_i, sm_i, boostmultiset, stdmultiset)){
|
||||
return -1;
|
||||
}
|
||||
//equal range
|
||||
@@ -581,12 +592,12 @@ int set_test ()
|
||||
,typename MyBoostMultiSet::iterator> bm_ip;
|
||||
std::pair<typename MyStdMultiSet::iterator
|
||||
,typename MyStdMultiSet::iterator> sm_ip;
|
||||
bm_ip = boostmultiset->equal_range(*bm_b);
|
||||
sm_ip = stdmultiset->equal_range(*sm_b);
|
||||
if(!CheckEqualIt(bm_ip.first, sm_ip.first, *boostmultiset, *stdmultiset)){
|
||||
bm_ip = boostmultiset.equal_range(*bm_b);
|
||||
sm_ip = stdmultiset.equal_range(*sm_b);
|
||||
if(!CheckEqualIt(bm_ip.first, sm_ip.first, boostmultiset, stdmultiset)){
|
||||
return -1;
|
||||
}
|
||||
if(!CheckEqualIt(bm_ip.second, sm_ip.second, *boostmultiset, *stdmultiset)){
|
||||
if(!CheckEqualIt(bm_ip.second, sm_ip.second, boostmultiset, stdmultiset)){
|
||||
return -1;
|
||||
}
|
||||
++bm_b;
|
||||
@@ -595,33 +606,28 @@ int set_test ()
|
||||
}
|
||||
|
||||
//Now do count exercise
|
||||
boostset->erase(boostset->begin(), boostset->end());
|
||||
boostmultiset->erase(boostmultiset->begin(), boostmultiset->end());
|
||||
boostset->clear();
|
||||
boostmultiset->clear();
|
||||
boostset.erase(boostset.begin(), boostset.end());
|
||||
boostmultiset.erase(boostmultiset.begin(), boostmultiset.end());
|
||||
boostset.clear();
|
||||
boostmultiset.clear();
|
||||
|
||||
for(int j = 0; j < 3; ++j)
|
||||
for(int i = 0; i < 100; ++i){
|
||||
IntType move_me(i);
|
||||
boostset->insert(boost::move(move_me));
|
||||
boostset.insert(boost::move(move_me));
|
||||
IntType move_me2(i);
|
||||
boostmultiset->insert(boost::move(move_me2));
|
||||
boostmultiset.insert(boost::move(move_me2));
|
||||
IntType count_me(i);
|
||||
if(boostset->count(count_me) != typename MyBoostMultiSet::size_type(1)){
|
||||
std::cout << "Error in boostset->count(count_me)" << std::endl;
|
||||
if(boostset.count(count_me) != typename MyBoostMultiSet::size_type(1)){
|
||||
std::cout << "Error in boostset.count(count_me)" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
if(boostmultiset->count(count_me) != typename MyBoostMultiSet::size_type(j+1)){
|
||||
std::cout << "Error in boostmultiset->count(count_me)" << std::endl;
|
||||
if(boostmultiset.count(count_me) != typename MyBoostMultiSet::size_type(j+1)){
|
||||
std::cout << "Error in boostmultiset.count(count_me)" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
delete boostset;
|
||||
delete stdset;
|
||||
delete boostmultiset;
|
||||
delete stdmultiset;
|
||||
|
||||
if(set_test_copyable<MyBoostSet, MyStdSet, MyBoostMultiSet, MyStdMultiSet>
|
||||
(container_detail::bool_<boost::container::test::is_copyable<IntType>::value>())){
|
||||
return 1;
|
||||
|
@@ -81,27 +81,15 @@ int test_expand_bwd()
|
||||
int_allocator_type;
|
||||
typedef vector<int, int_allocator_type>
|
||||
int_vector;
|
||||
|
||||
if(!test::test_all_expand_bwd<int_vector>())
|
||||
return 1;
|
||||
|
||||
//Now user defined wrapped int
|
||||
typedef test::expand_bwd_test_allocator<test::int_holder>
|
||||
int_holder_allocator_type;
|
||||
typedef vector<test::int_holder, int_holder_allocator_type>
|
||||
int_holder_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>())
|
||||
//Now user defined copyable int
|
||||
typedef test::expand_bwd_test_allocator<test::copyable_int>
|
||||
copyable_int_allocator_type;
|
||||
typedef vector<test::copyable_int, copyable_int_allocator_type>
|
||||
copyable_int_vector;
|
||||
if(!test::test_all_expand_bwd<copyable_int_vector>())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include "input_from_forward_iterator.hpp"
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/move/iterator.hpp>
|
||||
#include <boost/move/make_unique.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include "insert_test.hpp"
|
||||
@@ -39,59 +40,61 @@ namespace container {
|
||||
namespace test{
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//Function to check if both sets are equal
|
||||
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;
|
||||
std::size_t size = boostvector->size();
|
||||
boostvector->insert(boostvector->end(), 50, IntType(1));
|
||||
stdvector->insert(stdvector->end(), 50, 1);
|
||||
std::size_t size = boostvector.size();
|
||||
boostvector.insert(boostvector.end(), 50, IntType(1));
|
||||
stdvector.insert(stdvector.end(), 50, 1);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return false;
|
||||
|
||||
{
|
||||
IntType move_me(1);
|
||||
boostvector->insert(boostvector->begin()+size/2, 50, boost::move(move_me));
|
||||
stdvector->insert(stdvector->begin()+size/2, 50, 1);
|
||||
boostvector.insert(boostvector.begin()+size/2, 50, boost::move(move_me));
|
||||
stdvector.insert(stdvector.begin()+size/2, 50, 1);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return false;
|
||||
}
|
||||
{
|
||||
IntType move_me(2);
|
||||
boostvector->assign(boostvector->size()/2, boost::move(move_me));
|
||||
stdvector->assign(stdvector->size()/2, 2);
|
||||
boostvector.assign(boostvector.size()/2, boost::move(move_me));
|
||||
stdvector.assign(stdvector.size()/2, 2);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return false;
|
||||
}
|
||||
{
|
||||
IntType move_me(3);
|
||||
boostvector->assign(boostvector->size()*3-1, boost::move(move_me));
|
||||
stdvector->assign(stdvector->size()*3-1, 3);
|
||||
boostvector.assign(boostvector.size()*3-1, boost::move(move_me));
|
||||
stdvector.assign(stdvector.size()*3-1, 3);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return false;
|
||||
}
|
||||
|
||||
{
|
||||
IntType copy_me(3);
|
||||
const IntType ccopy_me(3);
|
||||
boostvector->push_back(copy_me);
|
||||
stdvector->push_back(int(3));
|
||||
boostvector->push_back(ccopy_me);
|
||||
stdvector->push_back(int(3));
|
||||
boostvector.push_back(copy_me);
|
||||
stdvector.push_back(int(3));
|
||||
boostvector.push_back(ccopy_me);
|
||||
stdvector.push_back(int(3));
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return false;
|
||||
}
|
||||
{
|
||||
V1 *pv1 = new V1(*boostvector);
|
||||
V2 *pv2 = new V2(*stdvector);
|
||||
boostvector->clear();
|
||||
stdvector->clear();
|
||||
boostvector->assign(pv1->begin(), pv1->end());
|
||||
stdvector->assign(pv2->begin(), pv2->end());
|
||||
::boost::movelib::unique_ptr<V1> const pv1 = ::boost::movelib::make_unique<V1>(boostvector);
|
||||
::boost::movelib::unique_ptr<V2> const pv2 = ::boost::movelib::make_unique<V2>(stdvector);
|
||||
|
||||
V1 &v1 = *pv1;
|
||||
V2 &v2 = *pv2;
|
||||
|
||||
boostvector.clear();
|
||||
stdvector.clear();
|
||||
boostvector.assign(v1.begin(), v1.end());
|
||||
stdvector.assign(v2.begin(), v2.end());
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
delete pv1;
|
||||
delete pv2;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -109,221 +112,212 @@ int vector_test()
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TRY{
|
||||
MyBoostVector *boostvector = new MyBoostVector;
|
||||
MyStdVector *stdvector = new MyStdVector;
|
||||
boostvector->resize(100);
|
||||
stdvector->resize(100);
|
||||
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp = ::boost::movelib::make_unique<MyBoostVector>();
|
||||
::boost::movelib::unique_ptr<MyStdVector> const stdvectorp = ::boost::movelib::make_unique<MyStdVector>();
|
||||
|
||||
MyBoostVector & boostvector = *boostvectorp;
|
||||
MyStdVector & stdvector = *stdvectorp;
|
||||
|
||||
boostvector.resize(100);
|
||||
stdvector.resize(100);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
boostvector.resize(200);
|
||||
stdvector.resize(200);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
boostvector.resize(0);
|
||||
stdvector.resize(0);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType new_int(i);
|
||||
boostvector.insert(boostvector.end(), boost::move(new_int));
|
||||
stdvector.insert(stdvector.end(), i);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
boostvector->resize(200);
|
||||
stdvector->resize(200);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
boostvector->resize(0);
|
||||
stdvector->resize(0);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType new_int(i);
|
||||
boostvector->insert(boostvector->end(), boost::move(new_int));
|
||||
stdvector->insert(stdvector->end(), i);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
}
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
typename MyBoostVector::iterator boostit(boostvector->begin());
|
||||
typename MyStdVector::iterator stdit(stdvector->begin());
|
||||
typename MyBoostVector::const_iterator cboostit = boostit;
|
||||
(void)cboostit;
|
||||
++boostit; ++stdit;
|
||||
boostvector->erase(boostit);
|
||||
stdvector->erase(stdit);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
boostvector->erase(boostvector->begin());
|
||||
stdvector->erase(stdvector->begin());
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
{
|
||||
//Initialize values
|
||||
IntType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType new_int(-1);
|
||||
BOOST_STATIC_ASSERT((boost::container::test::is_copyable<boost::container::test::movable_int>::value == false));
|
||||
aux_vect[i] = boost::move(new_int);
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -1;
|
||||
}
|
||||
typename MyBoostVector::iterator insert_it =
|
||||
boostvector->insert(boostvector->end()
|
||||
,boost::make_move_iterator(&aux_vect[0])
|
||||
,boost::make_move_iterator(aux_vect + 50));
|
||||
if(std::size_t(std::distance(insert_it, boostvector->end())) != 50) return 1;
|
||||
stdvector->insert(stdvector->end(), aux_vect2, aux_vect2 + 50);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
for(int i = 0, j = static_cast<int>(boostvector->size()); i < j; ++i){
|
||||
boostvector->erase(boostvector->begin());
|
||||
stdvector->erase(stdvector->begin());
|
||||
}
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
}
|
||||
{
|
||||
boostvector->resize(100);
|
||||
stdvector->resize(100);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
IntType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType new_int(-i);
|
||||
aux_vect[i] = boost::move(new_int);
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -i;
|
||||
}
|
||||
typename MyBoostVector::size_type old_size = boostvector->size();
|
||||
typename MyBoostVector::iterator insert_it =
|
||||
boostvector->insert(boostvector->begin() + old_size/2
|
||||
,boost::make_move_iterator(&aux_vect[0])
|
||||
,boost::make_move_iterator(aux_vect + 50));
|
||||
if(boostvector->begin() + old_size/2 != insert_it) return 1;
|
||||
stdvector->insert(stdvector->begin() + old_size/2, aux_vect2, aux_vect2 + 50);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType new_int(-i);
|
||||
aux_vect[i] = boost::move(new_int);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -i;
|
||||
}
|
||||
old_size = boostvector->size();
|
||||
//Now try with input iterators instead
|
||||
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 + 50))
|
||||
);
|
||||
if(boostvector->begin() + old_size/2 != insert_it) return 1;
|
||||
stdvector->insert(stdvector->begin() + old_size/2, aux_vect2, aux_vect2 + 50);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
}
|
||||
/* //deque has no reserve
|
||||
boostvector->reserve(boostvector->size()*2);
|
||||
stdvector->reserve(stdvector->size()*2);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
*/
|
||||
boostvector->shrink_to_fit();
|
||||
MyStdVector(*stdvector).swap(*stdvector);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
boostvector->shrink_to_fit();
|
||||
MyStdVector(*stdvector).swap(*stdvector);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
{ //push_back with not enough capacity
|
||||
IntType push_back_this(1);
|
||||
boostvector->push_back(boost::move(push_back_this));
|
||||
stdvector->push_back(int(1));
|
||||
boostvector->push_back(IntType(1));
|
||||
stdvector->push_back(int(1));
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
}
|
||||
|
||||
{ //test back()
|
||||
const IntType test_this(1);
|
||||
if(test_this != boostvector->back()) return 1;
|
||||
}
|
||||
{ //pop_back with enough capacity
|
||||
boostvector->pop_back();
|
||||
boostvector->pop_back();
|
||||
stdvector->pop_back();
|
||||
stdvector->pop_back();
|
||||
|
||||
IntType push_back_this(1);
|
||||
boostvector->push_back(boost::move(push_back_this));
|
||||
stdvector->push_back(int(1));
|
||||
boostvector->push_back(IntType(1));
|
||||
stdvector->push_back(int(1));
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
}
|
||||
|
||||
if(!vector_copyable_only(boostvector, stdvector
|
||||
,container_detail::bool_<boost::container::test::is_copyable<IntType>::value>())){
|
||||
return 1;
|
||||
}
|
||||
|
||||
boostvector->erase(boostvector->begin());
|
||||
stdvector->erase(stdvector->begin());
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType insert_this(i);
|
||||
boostvector->insert(boostvector->begin(), boost::move(insert_this));
|
||||
stdvector->insert(stdvector->begin(), i);
|
||||
boostvector->insert(boostvector->begin(), IntType(i));
|
||||
stdvector->insert(stdvector->begin(), int(i));
|
||||
}
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
//Test insertion from list
|
||||
{
|
||||
std::list<int> l(50, int(1));
|
||||
typename MyBoostVector::iterator it_insert =
|
||||
boostvector->insert(boostvector->begin(), l.begin(), l.end());
|
||||
if(boostvector->begin() != it_insert) return 1;
|
||||
stdvector->insert(stdvector->begin(), l.begin(), l.end());
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
boostvector->assign(l.begin(), l.end());
|
||||
stdvector->assign(l.begin(), l.end());
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
boostvector->clear();
|
||||
stdvector->clear();
|
||||
boostvector->assign(make_input_from_forward_iterator(l.begin()), make_input_from_forward_iterator(l.end()));
|
||||
stdvector->assign(l.begin(), l.end());
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
}
|
||||
/* deque has no reserve or capacity
|
||||
std::size_t cap = boostvector->capacity();
|
||||
boostvector->reserve(cap*2);
|
||||
stdvector->reserve(cap*2);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
boostvector->resize(0);
|
||||
stdvector->resize(0);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
boostvector->resize(cap*2);
|
||||
stdvector->resize(cap*2);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
boostvector->clear();
|
||||
stdvector->clear();
|
||||
boostvector->shrink_to_fit();
|
||||
MyStdVector(*stdvector).swap(*stdvector);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
boostvector->resize(cap*2);
|
||||
stdvector->resize(cap*2);
|
||||
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
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
typename MyBoostVector::iterator boostit(boostvector.begin());
|
||||
typename MyStdVector::iterator stdit(stdvector.begin());
|
||||
typename MyBoostVector::const_iterator cboostit = boostit;
|
||||
(void)cboostit;
|
||||
++boostit; ++stdit;
|
||||
boostvector.erase(boostit);
|
||||
stdvector.erase(stdit);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
boostvector.erase(boostvector.begin());
|
||||
stdvector.erase(stdvector.begin());
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
{
|
||||
//Initialize values
|
||||
IntType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType new_int(-1);
|
||||
BOOST_STATIC_ASSERT((boost::container::test::is_copyable<boost::container::test::movable_int>::value == false));
|
||||
aux_vect[i] = boost::move(new_int);
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -1;
|
||||
}
|
||||
typename MyBoostVector::iterator insert_it =
|
||||
boostvector.insert(boostvector.end()
|
||||
,boost::make_move_iterator(&aux_vect[0])
|
||||
,boost::make_move_iterator(aux_vect + 50));
|
||||
if(std::size_t(std::distance(insert_it, boostvector.end())) != 50) return 1;
|
||||
stdvector.insert(stdvector.end(), aux_vect2, aux_vect2 + 50);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
for(int i = 0, j = static_cast<int>(boostvector.size()); i < j; ++i){
|
||||
boostvector.erase(boostvector.begin());
|
||||
stdvector.erase(stdvector.begin());
|
||||
}
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
}
|
||||
{
|
||||
boostvector.resize(100);
|
||||
stdvector.resize(100);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
IntType aux_vect[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType new_int(-i);
|
||||
aux_vect[i] = boost::move(new_int);
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -i;
|
||||
}
|
||||
typename MyBoostVector::size_type old_size = boostvector.size();
|
||||
typename MyBoostVector::iterator insert_it =
|
||||
boostvector.insert(boostvector.begin() + old_size/2
|
||||
,boost::make_move_iterator(&aux_vect[0])
|
||||
,boost::make_move_iterator(aux_vect + 50));
|
||||
if(boostvector.begin() + old_size/2 != insert_it) return 1;
|
||||
stdvector.insert(stdvector.begin() + old_size/2, aux_vect2, aux_vect2 + 50);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType new_int(-i);
|
||||
aux_vect[i] = boost::move(new_int);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -i;
|
||||
}
|
||||
old_size = boostvector.size();
|
||||
//Now try with input iterators instead
|
||||
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 + 50))
|
||||
);
|
||||
if(boostvector.begin() + old_size/2 != insert_it) return 1;
|
||||
stdvector.insert(stdvector.begin() + old_size/2, aux_vect2, aux_vect2 + 50);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
}
|
||||
/* //deque has no reserve
|
||||
boostvector.reserve(boostvector.size()*2);
|
||||
stdvector.reserve(stdvector.size()*2);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
*/
|
||||
boostvector.shrink_to_fit();
|
||||
MyStdVector(stdvector).swap(stdvector);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
boostvector.shrink_to_fit();
|
||||
MyStdVector(stdvector).swap(stdvector);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
{ //push_back with not enough capacity
|
||||
IntType push_back_this(1);
|
||||
boostvector.push_back(boost::move(push_back_this));
|
||||
stdvector.push_back(int(1));
|
||||
boostvector.push_back(IntType(1));
|
||||
stdvector.push_back(int(1));
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
}
|
||||
|
||||
{ //test back()
|
||||
const IntType test_this(1);
|
||||
if(test_this != boostvector.back()) return 1;
|
||||
}
|
||||
{ //pop_back with enough capacity
|
||||
boostvector.pop_back();
|
||||
boostvector.pop_back();
|
||||
stdvector.pop_back();
|
||||
stdvector.pop_back();
|
||||
|
||||
IntType push_back_this(1);
|
||||
boostvector.push_back(boost::move(push_back_this));
|
||||
stdvector.push_back(int(1));
|
||||
boostvector.push_back(IntType(1));
|
||||
stdvector.push_back(int(1));
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
}
|
||||
|
||||
if(!vector_copyable_only(boostvector, stdvector
|
||||
,container_detail::bool_<boost::container::test::is_copyable<IntType>::value>())){
|
||||
return 1;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
}
|
||||
|
||||
boostvector.erase(boostvector.begin());
|
||||
stdvector.erase(stdvector.begin());
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType insert_this(i);
|
||||
boostvector.insert(boostvector.begin(), boost::move(insert_this));
|
||||
stdvector.insert(stdvector.begin(), i);
|
||||
boostvector.insert(boostvector.begin(), IntType(i));
|
||||
stdvector.insert(stdvector.begin(), int(i));
|
||||
}
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
//Test insertion from list
|
||||
{
|
||||
std::list<int> l(50, int(1));
|
||||
typename MyBoostVector::iterator it_insert =
|
||||
boostvector.insert(boostvector.begin(), l.begin(), l.end());
|
||||
if(boostvector.begin() != it_insert) return 1;
|
||||
stdvector.insert(stdvector.begin(), l.begin(), l.end());
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
boostvector.assign(l.begin(), l.end());
|
||||
stdvector.assign(l.begin(), l.end());
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
boostvector.clear();
|
||||
stdvector.clear();
|
||||
boostvector.assign(make_input_from_forward_iterator(l.begin()), make_input_from_forward_iterator(l.end()));
|
||||
stdvector.assign(l.begin(), l.end());
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
}
|
||||
/* deque has no reserve or capacity
|
||||
std::size_t cap = boostvector.capacity();
|
||||
boostvector.reserve(cap*2);
|
||||
stdvector.reserve(cap*2);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
boostvector.resize(0);
|
||||
stdvector.resize(0);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
boostvector.resize(cap*2);
|
||||
stdvector.resize(cap*2);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
boostvector.clear();
|
||||
stdvector.clear();
|
||||
boostvector.shrink_to_fit();
|
||||
MyStdVector(stdvector).swap(stdvector);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
boostvector.resize(cap*2);
|
||||
stdvector.resize(cap*2);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
*/
|
||||
}
|
||||
std::cout << std::endl << "Test OK!" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
@@ -335,7 +329,7 @@ bool test_vector_methods_with_initializer_list_as_argument_for()
|
||||
{
|
||||
const VectorContainerType testedVector = {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};
|
||||
|
||||
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});
|
||||
|
||||
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});
|
||||
|
||||
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;
|
||||
#else
|
||||
|
Reference in New Issue
Block a user