forked from boostorg/unordered
Merge in latest changes to Boost.Unordered. Some compiler workarounds and
starting to clean up the tests a little. [SVN r42724]
This commit is contained in:
@@ -131,7 +131,7 @@ namespace boost {
|
||||
|
||||
void destroy(link_ptr ptr)
|
||||
{
|
||||
node_ptr n(node_alloc_.address(static_cast<node&>(*ptr)));
|
||||
node_ptr n(node_alloc_.address(*static_cast<node*>(&*ptr)));
|
||||
value_alloc_.destroy(value_alloc_.address(n->value_));
|
||||
node_base_alloc_.destroy(node_base_alloc_.address(*n));
|
||||
node_alloc_.deallocate(n, 1);
|
||||
@@ -224,7 +224,7 @@ namespace boost {
|
||||
|
||||
#if BOOST_UNORDERED_EQUIVALENT_KEYS
|
||||
static inline link_ptr& prev_in_group(link_ptr n) {
|
||||
return static_cast<node&>(*n).group_prev_;
|
||||
return static_cast<node*>(&*n)->group_prev_;
|
||||
}
|
||||
|
||||
// pre: Must be pointing to the first node in a group.
|
||||
@@ -242,13 +242,13 @@ namespace boost {
|
||||
// pre: Must be pointing to a node
|
||||
static inline node& get_node(link_ptr p) {
|
||||
BOOST_ASSERT(p);
|
||||
return static_cast<node&>(*p);
|
||||
return *static_cast<node*>(&*p);
|
||||
}
|
||||
|
||||
// pre: Must be pointing to a node
|
||||
static inline reference get_value(link_ptr p) {
|
||||
BOOST_ASSERT(p);
|
||||
return static_cast<node&>(*p).value_;
|
||||
return static_cast<node*>(&*p)->value_;
|
||||
}
|
||||
|
||||
class iterator_base
|
||||
|
@@ -43,6 +43,13 @@ namespace test
|
||||
}
|
||||
|
||||
pointer allocate(size_type n, const_pointer u) { return allocate(n); }
|
||||
|
||||
#if defined(__IBMCPP__)
|
||||
// Workaround for IBM Visual Age which seems to use a void pointer
|
||||
// for the second argument.
|
||||
pointer allocate(size_type n, void const* u) { return allocate(n); }
|
||||
#endif
|
||||
|
||||
void deallocate(pointer p, size_type) {
|
||||
using namespace std;
|
||||
free(p);
|
||||
|
238
test/helpers/exception_test.hpp
Normal file
238
test/helpers/exception_test.hpp
Normal file
@@ -0,0 +1,238 @@
|
||||
|
||||
// Copyright 2006-2007 Daniel James.
|
||||
// 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)
|
||||
|
||||
#if !defined(BOOST_UNORDERED_EXCEPTION_TEST_HEADER)
|
||||
#define BOOST_UNORDERED_EXCEPTION_TEST_HEADER
|
||||
|
||||
#include "./test.hpp"
|
||||
|
||||
#if defined(BOOST_UNORDERED_USE_TEST)
|
||||
# define BOOST_TEST_MAIN
|
||||
# include <boost/test/exception_safety.hpp>
|
||||
# include <boost/test/unit_test.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/preprocessor/seq/for_each_product.hpp>
|
||||
#include <boost/preprocessor/seq/elem.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
|
||||
#if defined(BOOST_UNORDERED_USE_TEST)
|
||||
# define UNORDERED_EXCEPTION_TEST_PREFIX
|
||||
# define UNORDERED_EXCEPTION_TEST_CASE(name, test_func, type) \
|
||||
BOOST_AUTO_TEST_CASE(name) \
|
||||
{ \
|
||||
test_func< type > fixture; \
|
||||
::test::exception_safety(fixture, BOOST_STRINGIZE(test_func<type>)); \
|
||||
}
|
||||
# define UNORDERED_EXCEPTION_TEST_POSTFIX
|
||||
# define UNORDERED_EPOINT_IMPL BOOST_ITEST_EPOINT
|
||||
#else
|
||||
# define UNORDERED_EXCEPTION_TEST_PREFIX int main() {
|
||||
# define UNORDERED_EXCEPTION_TEST_CASE(name, test_func, type) \
|
||||
{ \
|
||||
test_func< type > fixture; \
|
||||
::test::lightweight::exception_safety(fixture, BOOST_STRINGIZE(test_func<type>)); \
|
||||
}
|
||||
# define UNORDERED_EXCEPTION_TEST_POSTFIX return boost::report_errors(); }
|
||||
# define UNORDERED_EPOINT_IMPL ::test::lightweight::epoint
|
||||
#endif
|
||||
|
||||
#define RUN_EXCEPTION_TESTS(test_seq, param_seq) \
|
||||
UNORDERED_EXCEPTION_TEST_PREFIX \
|
||||
BOOST_PP_SEQ_FOR_EACH_PRODUCT(RUN_EXCEPTION_TESTS_OP, (test_seq)(param_seq)) \
|
||||
UNORDERED_EXCEPTION_TEST_POSTFIX
|
||||
|
||||
#define RUN_EXCEPTION_TESTS_OP(r, product) \
|
||||
UNORDERED_EXCEPTION_TEST_CASE( \
|
||||
BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(0, product), \
|
||||
BOOST_PP_CAT(_, BOOST_PP_SEQ_ELEM(1, product)) \
|
||||
), \
|
||||
BOOST_PP_SEQ_ELEM(0, product), \
|
||||
BOOST_PP_SEQ_ELEM(1, product) \
|
||||
)
|
||||
|
||||
#define UNORDERED_SCOPE(scope_name) \
|
||||
for(::test::scope_guard unordered_test_guard( \
|
||||
BOOST_STRINGIZE(scope_name)); \
|
||||
!unordered_test_guard.dismissed(); \
|
||||
unordered_test_guard.dismiss())
|
||||
|
||||
#define UNORDERED_EPOINT(name) \
|
||||
if(::test::exceptions_enabled) { \
|
||||
UNORDERED_EPOINT_IMPL(name); \
|
||||
}
|
||||
|
||||
#define ENABLE_EXCEPTIONS \
|
||||
::test::exceptions_enable BOOST_PP_CAT(ENABLE_EXCEPTIONS_, __LINE__)(true)
|
||||
#define DISABLE_EXCEPTIONS \
|
||||
::test::exceptions_enable BOOST_PP_CAT(ENABLE_EXCEPTIONS_, __LINE__)(false)
|
||||
|
||||
namespace test {
|
||||
static char const* scope = "";
|
||||
bool exceptions_enabled = false;
|
||||
|
||||
class scope_guard {
|
||||
scope_guard& operator=(scope_guard const&);
|
||||
scope_guard(scope_guard const&);
|
||||
|
||||
char const* old_scope_;
|
||||
char const* scope_;
|
||||
bool dismissed_;
|
||||
public:
|
||||
scope_guard(char const* name)
|
||||
: old_scope_(scope),
|
||||
scope_(name),
|
||||
dismissed_(false)
|
||||
{
|
||||
scope = scope_;
|
||||
}
|
||||
|
||||
~scope_guard() {
|
||||
if(dismissed_) scope = old_scope_;
|
||||
}
|
||||
|
||||
void dismiss() {
|
||||
dismissed_ = true;
|
||||
}
|
||||
|
||||
bool dismissed() const {
|
||||
return dismissed_;
|
||||
}
|
||||
};
|
||||
|
||||
class exceptions_enable
|
||||
{
|
||||
exceptions_enable& operator=(exceptions_enable const&);
|
||||
exceptions_enable(exceptions_enable const&);
|
||||
|
||||
bool old_value_;
|
||||
public:
|
||||
exceptions_enable(bool enable)
|
||||
: old_value_(exceptions_enabled)
|
||||
{
|
||||
exceptions_enabled = enable;
|
||||
}
|
||||
|
||||
~exceptions_enable()
|
||||
{
|
||||
exceptions_enabled = old_value_;
|
||||
}
|
||||
};
|
||||
|
||||
struct exception_base {
|
||||
struct data_type {};
|
||||
struct strong_type {
|
||||
template <class T> void store(T const&) {}
|
||||
template <class T> void test(T const&) const {}
|
||||
};
|
||||
data_type init() const { return data_type(); }
|
||||
void check() const {}
|
||||
};
|
||||
|
||||
template <class T, class P1, class P2, class T2>
|
||||
inline void call_ignore_extra_parameters(void (T::*fn)() const, T2 const& obj,
|
||||
P1&, P2&)
|
||||
{
|
||||
(obj.*fn)();
|
||||
}
|
||||
|
||||
template <class T, class P1, class P2, class T2>
|
||||
inline void call_ignore_extra_parameters(void (T::*fn)(P1&) const, T2 const& obj,
|
||||
P1& p1, P2&)
|
||||
{
|
||||
(obj.*fn)(p1);
|
||||
}
|
||||
|
||||
template <class T, class P1, class P2, class T2>
|
||||
inline void call_ignore_extra_parameters(void (T::*fn)(P1&, P2&) const, T2 const& obj,
|
||||
P1& p1, P2& p2)
|
||||
{
|
||||
(obj.*fn)(p1, p2);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T const& constant(T const& x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
template <class Test>
|
||||
class test_runner
|
||||
{
|
||||
Test const& test_;
|
||||
public:
|
||||
test_runner(Test const& t) : test_(t) {}
|
||||
void operator()() const {
|
||||
DISABLE_EXCEPTIONS;
|
||||
BOOST_DEDUCED_TYPENAME Test::data_type x(test_.init());
|
||||
BOOST_DEDUCED_TYPENAME Test::strong_type strong;
|
||||
strong.store(x);
|
||||
try {
|
||||
ENABLE_EXCEPTIONS;
|
||||
call_ignore_extra_parameters<Test, BOOST_DEDUCED_TYPENAME Test::data_type, BOOST_DEDUCED_TYPENAME Test::strong_type>(&Test::run, test_, x, strong);
|
||||
}
|
||||
catch(...) {
|
||||
call_ignore_extra_parameters<Test, BOOST_DEDUCED_TYPENAME Test::data_type const, BOOST_DEDUCED_TYPENAME Test::strong_type const>(&Test::check, test_,
|
||||
constant(x), constant(strong));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#if defined(BOOST_UNORDERED_USE_TEST)
|
||||
template <class Test>
|
||||
void exception_safety(Test const& f, char const* name) {
|
||||
test_runner<Test> runner(f);
|
||||
::boost::itest::exception_safety(runner, name);
|
||||
}
|
||||
#else
|
||||
// Quick exception testing based on lightweight test
|
||||
|
||||
namespace lightweight {
|
||||
static int iteration;
|
||||
static int count;
|
||||
|
||||
struct test_exception {
|
||||
char const* name;
|
||||
test_exception(char const* n) : name(n) {}
|
||||
};
|
||||
|
||||
struct test_failure {
|
||||
};
|
||||
|
||||
void epoint(char const* name) {
|
||||
++count;
|
||||
if(count == iteration) {
|
||||
throw test_exception(name);
|
||||
}
|
||||
}
|
||||
|
||||
template <class Test>
|
||||
void exception_safety(Test const& f, char const* name) {
|
||||
test_runner<Test> runner(f);
|
||||
|
||||
iteration = 0;
|
||||
bool success = false;
|
||||
do {
|
||||
++iteration;
|
||||
count = 0;
|
||||
|
||||
try {
|
||||
runner();
|
||||
success = true;
|
||||
}
|
||||
catch(test_failure) {
|
||||
break;
|
||||
}
|
||||
catch(...) {
|
||||
}
|
||||
} while(!success);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
@@ -3,253 +3,18 @@
|
||||
// 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)
|
||||
|
||||
#if !defined(BOOST_UNORDERED_TEST_OBJECTS_HEADER)
|
||||
#define BOOST_UNORDERED_TEST_OBJECTS_HEADER
|
||||
#if !defined(BOOST_UNORDERED_EXCEPTION_TEST_OBJECTS_HEADER)
|
||||
#define BOOST_UNORDERED_EXCEPTION_TEST_OBJECTS_HEADER
|
||||
|
||||
#if defined(BOOST_UNORDERED_USE_TEST)
|
||||
#define BOOST_TEST_MAIN
|
||||
#include <boost/test/exception_safety.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#else
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#endif
|
||||
#include "../helpers/exception_test.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/preprocessor/seq/for_each_product.hpp>
|
||||
#include <boost/preprocessor/seq/elem.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include "../helpers/fwd.hpp"
|
||||
#include "../helpers/allocator.hpp"
|
||||
#include "./memory.hpp"
|
||||
|
||||
#define RUN_EXCEPTION_TESTS(test_seq, param_seq) \
|
||||
UNORDERED_EXCEPTION_TEST_PREFIX \
|
||||
BOOST_PP_SEQ_FOR_EACH_PRODUCT(RUN_EXCEPTION_TESTS_OP, (test_seq)(param_seq)) \
|
||||
UNORDERED_EXCEPTION_TEST_POSTFIX
|
||||
|
||||
#define RUN_EXCEPTION_TESTS_OP(r, product) \
|
||||
UNORDERED_EXCEPTION_TEST_CASE( \
|
||||
BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(0, product), \
|
||||
BOOST_PP_CAT(_, BOOST_PP_SEQ_ELEM(1, product)) \
|
||||
), \
|
||||
BOOST_PP_SEQ_ELEM(0, product), \
|
||||
BOOST_PP_SEQ_ELEM(1, product) \
|
||||
)
|
||||
|
||||
|
||||
#if defined(BOOST_UNORDERED_USE_TEST)
|
||||
#define UNORDERED_EXCEPTION_TEST_PREFIX
|
||||
#define UNORDERED_EXCEPTION_TEST_CASE(name, test_func, type) \
|
||||
BOOST_AUTO_TEST_CASE(name) \
|
||||
{ \
|
||||
test_func< type > fixture; \
|
||||
::test::exception_safety(fixture, BOOST_STRINGIZE(test_func<type>)); \
|
||||
}
|
||||
#define UNORDERED_EXCEPTION_TEST_POSTFIX
|
||||
#else
|
||||
#define UNORDERED_EXCEPTION_TEST_PREFIX int main() {
|
||||
#define UNORDERED_EXCEPTION_TEST_CASE(name, test_func, type) \
|
||||
{ \
|
||||
test_func< type > fixture; \
|
||||
::test::lightweight::exception_safety(fixture, BOOST_STRINGIZE(test_func<type>)); \
|
||||
}
|
||||
#define UNORDERED_EXCEPTION_TEST_POSTFIX return boost::report_errors(); }
|
||||
#endif
|
||||
|
||||
#define SCOPE(scope_name) \
|
||||
for(::test::scope_guard unordered_test_guard( \
|
||||
BOOST_STRINGIZE(scope_name)); \
|
||||
!unordered_test_guard.dismissed(); \
|
||||
unordered_test_guard.dismiss())
|
||||
|
||||
#if defined(BOOST_UNORDERED_USE_TEST)
|
||||
#define EPOINT(name) \
|
||||
if(::test::exceptions_enabled) { \
|
||||
BOOST_ITEST_EPOINT(name); \
|
||||
}
|
||||
#else
|
||||
#define EPOINT(name) \
|
||||
if(::test::exceptions_enabled) { \
|
||||
::test::lightweight::epoint(name); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ENABLE_EXCEPTIONS \
|
||||
::test::exceptions_enable BOOST_PP_CAT(ENABLE_EXCEPTIONS_, __LINE__)(true)
|
||||
#define DISABLE_EXCEPTIONS \
|
||||
::test::exceptions_enable BOOST_PP_CAT(ENABLE_EXCEPTIONS_, __LINE__)(false)
|
||||
|
||||
namespace test {
|
||||
static char const* scope = "";
|
||||
bool exceptions_enabled = false;
|
||||
|
||||
class scope_guard {
|
||||
scope_guard& operator=(scope_guard const&);
|
||||
scope_guard(scope_guard const&);
|
||||
|
||||
char const* old_scope_;
|
||||
char const* scope_;
|
||||
bool dismissed_;
|
||||
public:
|
||||
scope_guard(char const* name)
|
||||
: old_scope_(scope),
|
||||
scope_(name),
|
||||
dismissed_(false)
|
||||
{
|
||||
scope = scope_;
|
||||
}
|
||||
|
||||
~scope_guard() {
|
||||
if(dismissed_) scope = old_scope_;
|
||||
}
|
||||
|
||||
void dismiss() {
|
||||
dismissed_ = true;
|
||||
}
|
||||
|
||||
bool dismissed() const {
|
||||
return dismissed_;
|
||||
}
|
||||
};
|
||||
|
||||
class exceptions_enable
|
||||
{
|
||||
exceptions_enable& operator=(exceptions_enable const&);
|
||||
exceptions_enable(exceptions_enable const&);
|
||||
|
||||
bool old_value_;
|
||||
public:
|
||||
exceptions_enable(bool enable)
|
||||
: old_value_(exceptions_enabled)
|
||||
{
|
||||
exceptions_enabled = enable;
|
||||
}
|
||||
|
||||
~exceptions_enable()
|
||||
{
|
||||
exceptions_enabled = old_value_;
|
||||
}
|
||||
};
|
||||
|
||||
struct exception_base {
|
||||
struct data_type {};
|
||||
struct strong_type {
|
||||
template <class T> void store(T const&) {}
|
||||
template <class T> void test(T const&) const {}
|
||||
};
|
||||
data_type init() const { return data_type(); }
|
||||
void check() const {}
|
||||
};
|
||||
|
||||
template <class T, class P1, class P2, class T2>
|
||||
inline void call_ignore_extra_parameters(void (T::*fn)() const, T2 const& obj,
|
||||
P1&, P2&)
|
||||
{
|
||||
(obj.*fn)();
|
||||
}
|
||||
|
||||
template <class T, class P1, class P2, class T2>
|
||||
inline void call_ignore_extra_parameters(void (T::*fn)(P1&) const, T2 const& obj,
|
||||
P1& p1, P2&)
|
||||
{
|
||||
(obj.*fn)(p1);
|
||||
}
|
||||
|
||||
template <class T, class P1, class P2, class T2>
|
||||
inline void call_ignore_extra_parameters(void (T::*fn)(P1&, P2&) const, T2 const& obj,
|
||||
P1& p1, P2& p2)
|
||||
{
|
||||
(obj.*fn)(p1, p2);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T const& constant(T const& x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
template <class Test>
|
||||
class test_runner
|
||||
{
|
||||
Test const& test_;
|
||||
public:
|
||||
test_runner(Test const& t) : test_(t) {}
|
||||
void operator()() const {
|
||||
DISABLE_EXCEPTIONS;
|
||||
BOOST_DEDUCED_TYPENAME Test::data_type x(test_.init());
|
||||
BOOST_DEDUCED_TYPENAME Test::strong_type strong;
|
||||
strong.store(x);
|
||||
try {
|
||||
ENABLE_EXCEPTIONS;
|
||||
call_ignore_extra_parameters<Test, BOOST_DEDUCED_TYPENAME Test::data_type, BOOST_DEDUCED_TYPENAME Test::strong_type>(&Test::run, test_, x, strong);
|
||||
}
|
||||
catch(...) {
|
||||
call_ignore_extra_parameters<Test, BOOST_DEDUCED_TYPENAME Test::data_type const, BOOST_DEDUCED_TYPENAME Test::strong_type const>(&Test::check, test_,
|
||||
constant(x), constant(strong));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#if defined(BOOST_UNORDERED_USE_TEST)
|
||||
template <class Test>
|
||||
void exception_safety(Test const& f, char const* name) {
|
||||
test_runner<Test> runner(f);
|
||||
::boost::itest::exception_safety(runner, name);
|
||||
}
|
||||
#else
|
||||
|
||||
// Quick exception testing based on lightweight test
|
||||
|
||||
namespace lightweight {
|
||||
static int iteration;
|
||||
static int count;
|
||||
|
||||
struct test_exception {
|
||||
char const* name;
|
||||
test_exception(char const* n) : name(n) {}
|
||||
};
|
||||
|
||||
struct test_failure {
|
||||
};
|
||||
|
||||
void epoint(char const* name) {
|
||||
++count;
|
||||
if(count == iteration) {
|
||||
throw test_exception(name);
|
||||
}
|
||||
}
|
||||
|
||||
template <class Test>
|
||||
void exception_safety(Test const& f, char const* name) {
|
||||
test_runner<Test> runner(f);
|
||||
|
||||
iteration = 0;
|
||||
bool success = false;
|
||||
do {
|
||||
++iteration;
|
||||
count = 0;
|
||||
|
||||
try {
|
||||
runner();
|
||||
success = true;
|
||||
}
|
||||
catch(test_failure) {
|
||||
break;
|
||||
}
|
||||
catch(...) {
|
||||
}
|
||||
} while(!success);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
namespace test
|
||||
{
|
||||
namespace exception
|
||||
@@ -280,23 +45,23 @@ namespace exception
|
||||
|
||||
explicit object() : tag1_(0), tag2_(0)
|
||||
{
|
||||
SCOPE(object::object()) {
|
||||
EPOINT("Mock object default constructor.");
|
||||
UNORDERED_SCOPE(object::object()) {
|
||||
UNORDERED_EPOINT("Mock object default constructor.");
|
||||
}
|
||||
}
|
||||
|
||||
explicit object(int t1, int t2 = 0) : tag1_(t1), tag2_(t2)
|
||||
{
|
||||
SCOPE(object::object(int)) {
|
||||
EPOINT("Mock object constructor by value.");
|
||||
UNORDERED_SCOPE(object::object(int)) {
|
||||
UNORDERED_EPOINT("Mock object constructor by value.");
|
||||
}
|
||||
}
|
||||
|
||||
object(object const& x)
|
||||
: tag1_(x.tag1_), tag2_(x.tag2_)
|
||||
{
|
||||
SCOPE(object::object(object)) {
|
||||
EPOINT("Mock object copy constructor.");
|
||||
UNORDERED_SCOPE(object::object(object)) {
|
||||
UNORDERED_EPOINT("Mock object copy constructor.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,26 +72,26 @@ namespace exception
|
||||
|
||||
object& operator=(object const& x)
|
||||
{
|
||||
SCOPE(object::operator=(object)) {
|
||||
UNORDERED_SCOPE(object::operator=(object)) {
|
||||
tag1_ = x.tag1_;
|
||||
EPOINT("Mock object assign operator 1.");
|
||||
UNORDERED_EPOINT("Mock object assign operator 1.");
|
||||
tag2_ = x.tag2_;
|
||||
//EPOINT("Mock object assign operator 2.");
|
||||
//UNORDERED_EPOINT("Mock object assign operator 2.");
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend bool operator==(object const& x1, object const& x2) {
|
||||
SCOPE(operator==(object, object)) {
|
||||
EPOINT("Mock object equality operator.");
|
||||
UNORDERED_SCOPE(operator==(object, object)) {
|
||||
UNORDERED_EPOINT("Mock object equality operator.");
|
||||
}
|
||||
|
||||
return x1.tag1_ == x2.tag1_ && x1.tag2_ == x2.tag2_;
|
||||
}
|
||||
|
||||
friend bool operator!=(object const& x1, object const& x2) {
|
||||
SCOPE(operator!=(object, object)) {
|
||||
EPOINT("Mock object inequality operator.");
|
||||
UNORDERED_SCOPE(operator!=(object, object)) {
|
||||
UNORDERED_EPOINT("Mock object inequality operator.");
|
||||
}
|
||||
|
||||
return !(x1.tag1_ == x2.tag1_ && x1.tag2_ == x2.tag2_);
|
||||
@@ -356,32 +121,32 @@ namespace exception
|
||||
public:
|
||||
hash(int t = 0) : tag_(t)
|
||||
{
|
||||
SCOPE(hash::object()) {
|
||||
EPOINT("Mock hash default constructor.");
|
||||
UNORDERED_SCOPE(hash::object()) {
|
||||
UNORDERED_EPOINT("Mock hash default constructor.");
|
||||
}
|
||||
}
|
||||
|
||||
hash(hash const& x)
|
||||
: tag_(x.tag_)
|
||||
{
|
||||
SCOPE(hash::hash(hash)) {
|
||||
EPOINT("Mock hash copy constructor.");
|
||||
UNORDERED_SCOPE(hash::hash(hash)) {
|
||||
UNORDERED_EPOINT("Mock hash copy constructor.");
|
||||
}
|
||||
}
|
||||
|
||||
hash& operator=(hash const& x)
|
||||
{
|
||||
SCOPE(hash::operator=(hash)) {
|
||||
EPOINT("Mock hash assign operator 1.");
|
||||
UNORDERED_SCOPE(hash::operator=(hash)) {
|
||||
UNORDERED_EPOINT("Mock hash assign operator 1.");
|
||||
tag_ = x.tag_;
|
||||
EPOINT("Mock hash assign operator 2.");
|
||||
UNORDERED_EPOINT("Mock hash assign operator 2.");
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::size_t operator()(object const& x) const {
|
||||
SCOPE(hash::operator()(object)) {
|
||||
EPOINT("Mock hash function.");
|
||||
UNORDERED_SCOPE(hash::operator()(object)) {
|
||||
UNORDERED_EPOINT("Mock hash function.");
|
||||
}
|
||||
|
||||
switch(tag_) {
|
||||
@@ -395,15 +160,15 @@ namespace exception
|
||||
}
|
||||
|
||||
friend bool operator==(hash const& x1, hash const& x2) {
|
||||
SCOPE(operator==(hash, hash)) {
|
||||
EPOINT("Mock hash equality function.");
|
||||
UNORDERED_SCOPE(operator==(hash, hash)) {
|
||||
UNORDERED_EPOINT("Mock hash equality function.");
|
||||
}
|
||||
return x1.tag_ == x2.tag_;
|
||||
}
|
||||
|
||||
friend bool operator!=(hash const& x1, hash const& x2) {
|
||||
SCOPE(hash::operator!=(hash, hash)) {
|
||||
EPOINT("Mock hash inequality function.");
|
||||
UNORDERED_SCOPE(hash::operator!=(hash, hash)) {
|
||||
UNORDERED_EPOINT("Mock hash inequality function.");
|
||||
}
|
||||
return x1.tag_ != x2.tag_;
|
||||
}
|
||||
@@ -415,32 +180,32 @@ namespace exception
|
||||
public:
|
||||
equal_to(int t = 0) : tag_(t)
|
||||
{
|
||||
SCOPE(equal_to::equal_to()) {
|
||||
EPOINT("Mock equal_to default constructor.");
|
||||
UNORDERED_SCOPE(equal_to::equal_to()) {
|
||||
UNORDERED_EPOINT("Mock equal_to default constructor.");
|
||||
}
|
||||
}
|
||||
|
||||
equal_to(equal_to const& x)
|
||||
: tag_(x.tag_)
|
||||
{
|
||||
SCOPE(equal_to::equal_to(equal_to)) {
|
||||
EPOINT("Mock equal_to copy constructor.");
|
||||
UNORDERED_SCOPE(equal_to::equal_to(equal_to)) {
|
||||
UNORDERED_EPOINT("Mock equal_to copy constructor.");
|
||||
}
|
||||
}
|
||||
|
||||
equal_to& operator=(equal_to const& x)
|
||||
{
|
||||
SCOPE(equal_to::operator=(equal_to)) {
|
||||
EPOINT("Mock equal_to assign operator 1.");
|
||||
UNORDERED_SCOPE(equal_to::operator=(equal_to)) {
|
||||
UNORDERED_EPOINT("Mock equal_to assign operator 1.");
|
||||
tag_ = x.tag_;
|
||||
EPOINT("Mock equal_to assign operator 2.");
|
||||
UNORDERED_EPOINT("Mock equal_to assign operator 2.");
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator()(object const& x1, object const& x2) const {
|
||||
SCOPE(equal_to::operator()(object, object)) {
|
||||
EPOINT("Mock equal_to function.");
|
||||
UNORDERED_SCOPE(equal_to::operator()(object, object)) {
|
||||
UNORDERED_EPOINT("Mock equal_to function.");
|
||||
}
|
||||
|
||||
switch(tag_) {
|
||||
@@ -454,15 +219,15 @@ namespace exception
|
||||
}
|
||||
|
||||
friend bool operator==(equal_to const& x1, equal_to const& x2) {
|
||||
SCOPE(operator==(equal_to, equal_to)) {
|
||||
EPOINT("Mock equal_to equality function.");
|
||||
UNORDERED_SCOPE(operator==(equal_to, equal_to)) {
|
||||
UNORDERED_EPOINT("Mock equal_to equality function.");
|
||||
}
|
||||
return x1.tag_ == x2.tag_;
|
||||
}
|
||||
|
||||
friend bool operator!=(equal_to const& x1, equal_to const& x2) {
|
||||
SCOPE(operator!=(equal_to, equal_to)) {
|
||||
EPOINT("Mock equal_to inequality function.");
|
||||
UNORDERED_SCOPE(operator!=(equal_to, equal_to)) {
|
||||
UNORDERED_EPOINT("Mock equal_to inequality function.");
|
||||
}
|
||||
return x1.tag_ != x2.tag_;
|
||||
}
|
||||
@@ -485,24 +250,24 @@ namespace exception
|
||||
|
||||
explicit allocator(int t = 0) : tag_(t)
|
||||
{
|
||||
SCOPE(allocator::allocator()) {
|
||||
EPOINT("Mock allocator default constructor.");
|
||||
UNORDERED_SCOPE(allocator::allocator()) {
|
||||
UNORDERED_EPOINT("Mock allocator default constructor.");
|
||||
}
|
||||
detail::tracker.allocator_ref();
|
||||
}
|
||||
|
||||
template <class Y> allocator(allocator<Y> const& x) : tag_(x.tag_)
|
||||
{
|
||||
SCOPE(allocator::allocator()) {
|
||||
EPOINT("Mock allocator template copy constructor.");
|
||||
UNORDERED_SCOPE(allocator::allocator()) {
|
||||
UNORDERED_EPOINT("Mock allocator template copy constructor.");
|
||||
}
|
||||
detail::tracker.allocator_ref();
|
||||
}
|
||||
|
||||
allocator(allocator const& x) : tag_(x.tag_)
|
||||
{
|
||||
SCOPE(allocator::allocator()) {
|
||||
EPOINT("Mock allocator copy constructor.");
|
||||
UNORDERED_SCOPE(allocator::allocator()) {
|
||||
UNORDERED_EPOINT("Mock allocator copy constructor.");
|
||||
}
|
||||
detail::tracker.allocator_ref();
|
||||
}
|
||||
@@ -512,8 +277,8 @@ namespace exception
|
||||
}
|
||||
|
||||
allocator& operator=(allocator const& x) {
|
||||
SCOPE(allocator::allocator()) {
|
||||
EPOINT("Mock allocator assignment operator.");
|
||||
UNORDERED_SCOPE(allocator::allocator()) {
|
||||
UNORDERED_EPOINT("Mock allocator assignment operator.");
|
||||
tag_ = x.tag_;
|
||||
}
|
||||
return *this;
|
||||
@@ -524,23 +289,23 @@ namespace exception
|
||||
// this.
|
||||
|
||||
pointer address(reference r) {
|
||||
//SCOPE(allocator::address(reference)) {
|
||||
// EPOINT("Mock allocator address function.");
|
||||
//UNORDERED_SCOPE(allocator::address(reference)) {
|
||||
// UNORDERED_EPOINT("Mock allocator address function.");
|
||||
//}
|
||||
return pointer(&r);
|
||||
}
|
||||
|
||||
const_pointer address(const_reference r) {
|
||||
//SCOPE(allocator::address(const_reference)) {
|
||||
// EPOINT("Mock allocator const address function.");
|
||||
//UNORDERED_SCOPE(allocator::address(const_reference)) {
|
||||
// UNORDERED_EPOINT("Mock allocator const address function.");
|
||||
//}
|
||||
return const_pointer(&r);
|
||||
}
|
||||
|
||||
pointer allocate(size_type n) {
|
||||
T* ptr = 0;
|
||||
SCOPE(allocator::allocate(size_type)) {
|
||||
EPOINT("Mock allocator allocate function.");
|
||||
UNORDERED_SCOPE(allocator::allocate(size_type)) {
|
||||
UNORDERED_EPOINT("Mock allocator allocate function.");
|
||||
|
||||
using namespace std;
|
||||
ptr = (T*) malloc(n * sizeof(T));
|
||||
@@ -555,8 +320,8 @@ namespace exception
|
||||
pointer allocate(size_type n, const_pointer u)
|
||||
{
|
||||
T* ptr = 0;
|
||||
SCOPE(allocator::allocate(size_type, const_pointer)) {
|
||||
EPOINT("Mock allocator allocate function.");
|
||||
UNORDERED_SCOPE(allocator::allocate(size_type, const_pointer)) {
|
||||
UNORDERED_EPOINT("Mock allocator allocate function.");
|
||||
|
||||
using namespace std;
|
||||
ptr = (T*) malloc(n * sizeof(T));
|
||||
@@ -579,8 +344,8 @@ namespace exception
|
||||
}
|
||||
|
||||
void construct(pointer p, T const& t) {
|
||||
SCOPE(allocator::construct(pointer, T)) {
|
||||
EPOINT("Mock allocator construct function.");
|
||||
UNORDERED_SCOPE(allocator::construct(pointer, T)) {
|
||||
UNORDERED_EPOINT("Mock allocator construct function.");
|
||||
new(p) T(t);
|
||||
}
|
||||
detail::tracker.track_construct((void*) p, sizeof(T), tag_);
|
||||
@@ -592,8 +357,8 @@ namespace exception
|
||||
}
|
||||
|
||||
size_type max_size() const {
|
||||
SCOPE(allocator::construct(pointer, T)) {
|
||||
EPOINT("Mock allocator max_size function.");
|
||||
UNORDERED_SCOPE(allocator::construct(pointer, T)) {
|
||||
UNORDERED_EPOINT("Mock allocator max_size function.");
|
||||
}
|
||||
return (std::numeric_limits<std::size_t>::max)();
|
||||
}
|
||||
@@ -611,8 +376,8 @@ namespace exception
|
||||
template <class T>
|
||||
inline bool operator==(allocator<T> const& x, allocator<T> const& y)
|
||||
{
|
||||
//SCOPE(operator==(allocator, allocator)) {
|
||||
// EPOINT("Mock allocator equality operator.");
|
||||
//UNORDERED_SCOPE(operator==(allocator, allocator)) {
|
||||
// UNORDERED_EPOINT("Mock allocator equality operator.");
|
||||
//}
|
||||
return x.tag_ == y.tag_;
|
||||
}
|
||||
@@ -620,8 +385,8 @@ namespace exception
|
||||
template <class T>
|
||||
inline bool operator!=(allocator<T> const& x, allocator<T> const& y)
|
||||
{
|
||||
//SCOPE(operator!=(allocator, allocator)) {
|
||||
// EPOINT("Mock allocator inequality operator.");
|
||||
//UNORDERED_SCOPE(operator!=(allocator, allocator)) {
|
||||
// UNORDERED_EPOINT("Mock allocator inequality operator.");
|
||||
//}
|
||||
return x.tag_ != y.tag_;
|
||||
}
|
||||
|
@@ -77,8 +77,8 @@ void erase_tests1(Container* = 0)
|
||||
BOOST_TEST(next == x.erase(pos));
|
||||
--size;
|
||||
if(size > 0)
|
||||
BOOST_TEST(next ==
|
||||
(index == 0 ? x.begin() : boost::next(prev)));
|
||||
BOOST_TEST(index == 0 ? next == x.begin() :
|
||||
next == boost::next(prev));
|
||||
BOOST_TEST(x.count(key) == count - 1);
|
||||
BOOST_TEST(x.size() == size);
|
||||
}
|
||||
|
Reference in New Issue
Block a user