forked from boostorg/container
Merge from trunk
[SVN r80689]
This commit is contained in:
1 parent
d535f151e7
commit
0519b950f4
40 files changed
+4963
-4220
No files matched your search
+65
-10
@@ -8,6 +8,9 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_CONTAINER_TEST_VECTOR_TEST_HEADER
|
||||
#define BOOST_CONTAINER_TEST_VECTOR_TEST_HEADER
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
@@ -24,6 +27,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "emplace_test.hpp"
|
||||
#include "input_from_forward_iterator.hpp"
|
||||
|
||||
namespace boost{
|
||||
namespace container {
|
||||
@@ -133,10 +137,11 @@ int vector_test()
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -1;
|
||||
}
|
||||
|
||||
boostvector->insert(boostvector->end()
|
||||
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;
|
||||
|
||||
@@ -147,22 +152,47 @@ int vector_test()
|
||||
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(-1);
|
||||
IntType new_int(-2);
|
||||
aux_vect[i] = boost::move(new_int);
|
||||
}
|
||||
int aux_vect2[50];
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -1;
|
||||
aux_vect2[i] = -2;
|
||||
}
|
||||
boostvector->insert(boostvector->begin()
|
||||
typename MyBoostVector::size_type old_size = boostvector->size();
|
||||
typename MyBoostVector::iterator insert_it =
|
||||
boostvector->insert(boostvector->begin() + old_size
|
||||
,boost::make_move_iterator(&aux_vect[0])
|
||||
,boost::make_move_iterator(aux_vect + 50));
|
||||
stdvector->insert(stdvector->begin(), aux_vect2, aux_vect2 + 50);
|
||||
if(boostvector->begin() + old_size != insert_it) return 1;
|
||||
stdvector->insert(stdvector->begin() + old_size, aux_vect2, aux_vect2 + 50);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
IntType new_int(-3);
|
||||
aux_vect[i] = boost::move(new_int);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
aux_vect2[i] = -3;
|
||||
}
|
||||
old_size = boostvector->size();
|
||||
//Now try with input iterators instead
|
||||
insert_it = boostvector->insert(boostvector->begin() + old_size
|
||||
,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 != insert_it) return 1;
|
||||
stdvector->insert(stdvector->begin() + old_size, 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;
|
||||
@@ -175,13 +205,27 @@ int vector_test()
|
||||
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;
|
||||
}
|
||||
{ //push_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>())){
|
||||
@@ -204,14 +248,22 @@ int vector_test()
|
||||
//Test insertion from list
|
||||
{
|
||||
std::list<int> l(50, int(1));
|
||||
boostvector->insert(boostvector->begin(), l.begin(), l.end());
|
||||
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);
|
||||
@@ -252,3 +304,6 @@ int vector_test()
|
||||
} //namespace boost{
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
#endif //BOOST_CONTAINER_TEST_VECTOR_TEST_HEADER
|
||||
|
||||
Reference in new issue
Block a user