[SVN r82429]
This commit is contained in:
Ion Gaztañaga committed 2013-01-10 10:55:50 +00:00
1 parent 71e9c48f32
commit 99c8d5d9d7
26 files changed
+487 -96

No files matched your search

+6 -2
View File
@@ -29,6 +29,7 @@
#include "emplace_test.hpp"
#include "propagate_allocator_test.hpp"
#include "vector_test.hpp"
#include <boost/detail/no_exceptions_support.hpp>
using namespace boost::container;
@@ -143,7 +144,7 @@ bool do_test()
typedef deque<IntType> MyCntDeque;
typedef std::deque<int> MyStdDeque;
const int max = 100;
try{
BOOST_TRY{
//Shared memory allocator must be always be initialized
//since it has no default constructor
MyCntDeque *cntdeque = new MyCntDeque;
@@ -268,10 +269,13 @@ bool do_test()
delete cntdeque;
delete stddeque;
}
catch(std::exception &ex){
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;
+1 -1
View File
@@ -26,11 +26,11 @@
#include <boost/container/detail/mpl.hpp>
#include <boost/container/detail/version_type.hpp>
#include <boost/container/detail/multiallocation_chain.hpp>
#include <boost/container/throw_exception.hpp>
#include <boost/move/utility.hpp>
#include <memory>
#include <algorithm>
#include <cstddef>
#include <stdexcept>
#include <cassert>
//!\file
+3 -3
View File
@@ -19,6 +19,7 @@
#include <boost/container/detail/workaround.hpp>
#include <boost/container/container_fwd.hpp>
#include <boost/container/throw_exception.hpp>
#include <boost/container/detail/allocation_type.hpp>
#include <boost/assert.hpp>
#include <boost/container/detail/utilities.hpp>
@@ -26,7 +27,6 @@
#include <memory>
#include <algorithm>
#include <cstddef>
#include <stdexcept>
#include <cassert>
//!\file
@@ -146,8 +146,8 @@ class expand_bwd_test_allocator
return std::pair<pointer, bool>(mp_buffer, true);
}
else{
assert(0);
throw std::bad_alloc();
throw_bad_alloc();
return std::pair<pointer, bool>(mp_buffer, true);
}
}
+8 -6
View File
@@ -135,7 +135,7 @@ bool test_insert_with_expand_bwd()
for(int iteration = 0; iteration < Iterations; ++iteration)
{
value_type *memory = new value_type[MemorySize];
try {
BOOST_TRY {
std::vector<non_volatile_value_type> initial_data;
initial_data.resize(InitialSize[iteration]);
for(int i = 0; i < InitialSize[iteration]; ++i){
@@ -165,10 +165,11 @@ bool test_insert_with_expand_bwd()
return false;
}
}
catch(...){
BOOST_CATCH(...){
delete [](const_cast<non_volatile_value_type*>(memory));
throw;
BOOST_RETHROW;
}
BOOST_CATCH_END
delete [](const_cast<non_volatile_value_type*>(memory));
}
@@ -193,7 +194,7 @@ bool test_assign_with_expand_bwd()
for(int iteration = 0; iteration <Iterations; ++iteration)
{
value_type *memory = new value_type[MemorySize];
try {
BOOST_TRY {
//Create initial data
std::vector<non_volatile_value_type> initial_data;
initial_data.resize(InitialSize[iteration]);
@@ -227,10 +228,11 @@ bool test_assign_with_expand_bwd()
return false;
}
}
catch(...){
BOOST_CATCH(...){
delete [](const_cast<typename boost::remove_volatile<value_type>::type*>(memory));
throw;
BOOST_RETHROW;
}
BOOST_CATCH_END
delete [](const_cast<typename boost::remove_volatile<value_type>::type*>(memory));
}
-1
View File
@@ -28,7 +28,6 @@
#include <memory>
#include <algorithm>
#include <cstddef>
#include <stdexcept>
//!\file
//!Describes an heap_allocator_v1 that allocates portions of fixed size
+4 -3
View File
@@ -148,7 +148,7 @@ int list_test (bool copied_allocators_equal = true)
const int max = 100;
typedef list_push_data_function<DoublyLinked> push_data_t;
try{
BOOST_TRY{
MyBoostList *boostlist = new MyBoostList;
MyStdList *stdlist = new MyStdList;
@@ -338,9 +338,10 @@ int list_test (bool copied_allocators_equal = true)
delete boostlist;
delete stdlist;
}
catch(...){
throw;
BOOST_CATCH(...){
BOOST_RETHROW;
}
BOOST_CATCH_END
return 0;
}
+8 -6
View File
@@ -44,7 +44,7 @@ int map_test ()
typedef typename MyStdMap::value_type StdPairType;
const int max = 100;
try{
BOOST_TRY{
MyBoostMap *boostmap = new MyBoostMap;
MyStdMap *stdmap = new MyStdMap;
MyBoostMultiMap *boostmultimap = new MyBoostMultiMap;
@@ -467,9 +467,10 @@ int map_test ()
delete boostmultimap;
delete stdmultimap;
}
catch(...){
throw;
BOOST_CATCH(...){
BOOST_RETHROW;
}
BOOST_CATCH_END
return 0;
}
@@ -485,7 +486,7 @@ int map_test_copyable ()
const int max = 100;
try{
BOOST_TRY{
MyBoostMap *boostmap = new MyBoostMap;
MyStdMap *stdmap = new MyStdMap;
MyBoostMultiMap *boostmultimap = new MyBoostMultiMap;
@@ -537,9 +538,10 @@ int map_test_copyable ()
delete stdmultimap;
}
}
catch(...){
throw;
BOOST_CATCH(...){
BOOST_RETHROW;
}
BOOST_CATCH_END
return 0;
}
+4 -3
View File
@@ -443,7 +443,7 @@ int set_test_copyable ()
typedef typename MyBoostSet::value_type IntType;
const int max = 100;
try{
BOOST_TRY{
//Shared memory allocator must be always be initialized
//since it has no default constructor
MyBoostSet *boostset = new MyBoostSet;
@@ -492,9 +492,10 @@ int set_test_copyable ()
delete boostset;
delete boostmultiset;
}
catch(...){
throw;
BOOST_CATCH(...){
BOOST_RETHROW;
}
BOOST_CATCH_END
return 0;
}
+62
View File
@@ -0,0 +1,62 @@
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2012-2013. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/container for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#define BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS
#include <boost/container/detail/config_begin.hpp>
#include <boost/container/throw_exception.hpp>
#include <boost/detail/lightweight_test.hpp>
using namespace boost::container;
static bool bad_alloc_called = false;
static bool out_of_range_called = false;
static bool length_error_called = false;
static bool logic_error_called = false;
static bool runtime_error_called = false;
//User defined throw implementations
namespace boost {
namespace container {
void throw_bad_alloc()
{ bad_alloc_called = true; }
void throw_out_of_range(const char* str)
{ (void)str; out_of_range_called = true; }
void throw_length_error(const char* str)
{ (void)str; length_error_called = true; }
void throw_logic_error(const char* str)
{ (void)str; logic_error_called = true; }
void throw_runtime_error(const char* str)
{ (void)str; runtime_error_called = true; }
}} //boost::container
int main()
{
//Check user-defined throw callbacks are called
throw_bad_alloc();
BOOST_TEST(bad_alloc_called == true);
throw_out_of_range("dummy");
BOOST_TEST(out_of_range_called == true);
throw_length_error("dummy");
BOOST_TEST(length_error_called == true);
throw_logic_error("dummy");
BOOST_TEST(logic_error_called == true);
throw_runtime_error("dummy");
BOOST_TEST(runtime_error_called == true);
return ::boost::report_errors();
}
#include <boost/container/detail/config_end.hpp>
+6 -2
View File
@@ -30,6 +30,7 @@
#include "input_from_forward_iterator.hpp"
#include <boost/move/utility.hpp>
#include <boost/move/iterator.hpp>
#include <boost/detail/no_exceptions_support.hpp>
namespace boost{
namespace container {
@@ -91,7 +92,7 @@ int vector_test()
const int max = 100;
{
try{
BOOST_TRY{
MyBoostVector *boostvector = new MyBoostVector;
MyStdVector *stdvector = new MyStdVector;
boostvector->resize(100);
@@ -292,10 +293,13 @@ int vector_test()
delete stdvector;
delete boostvector;
}
catch(std::exception &ex){
BOOST_CATCH(std::exception &ex){
#ifndef BOOST_NO_EXCEPTIONS
std::cout << ex.what() << std::endl;
#endif
return 1;
}
BOOST_CATCH_END
}
std::cout << std::endl << "Test OK!" << std::endl;
return 0;