Improve allocator propagation test with new constructors and refactor code to avoid too many wrappers.

This commit is contained in:
Ion Gaztañaga
2015-02-26 00:31:19 +01:00
parent 7160bea2aa
commit 6c5e527c60
14 changed files with 548 additions and 302 deletions

View File

@@ -432,35 +432,22 @@ bool test_expand_bwd()
return test::test_all_expand_bwd<string_type>();
}
template<class T, class Allocator>
class string_propagate_test_wrapper
: public basic_string<T, std::char_traits<T>, Allocator>
struct boost_container_string;
namespace boost { namespace container { namespace test {
template<>
struct alloc_propagate_base<boost_container_string>
{
BOOST_COPYABLE_AND_MOVABLE(string_propagate_test_wrapper)
typedef basic_string<T, std::char_traits<T>, Allocator> Base;
public:
string_propagate_test_wrapper()
: Base()
{}
string_propagate_test_wrapper(const string_propagate_test_wrapper &x)
: Base(x)
{}
string_propagate_test_wrapper(BOOST_RV_REF(string_propagate_test_wrapper) x)
: Base(boost::move(static_cast<Base&>(x)))
{}
string_propagate_test_wrapper &operator=(BOOST_COPY_ASSIGN_REF(string_propagate_test_wrapper) x)
{ this->Base::operator=(x); return *this; }
string_propagate_test_wrapper &operator=(BOOST_RV_REF(string_propagate_test_wrapper) x)
{ this->Base::operator=(boost::move(static_cast<Base&>(x))); return *this; }
void swap(string_propagate_test_wrapper &x)
{ this->Base::swap(x); }
template <class T, class Allocator>
struct apply
{
typedef boost::container::basic_string<T, std::char_traits<T>, Allocator> type;
};
};
}}} //namespace boost::container::test
int main()
{
if(string_test<char>()){
@@ -480,7 +467,7 @@ int main()
////////////////////////////////////
// Allocator propagation testing
////////////////////////////////////
if(!boost::container::test::test_propagate_allocator<string_propagate_test_wrapper>())
if(!boost::container::test::test_propagate_allocator<boost_container_string>())
return 1;
////////////////////////////////////