diff --git a/test/helpers/accessors.hpp b/test/helpers/accessors.hpp deleted file mode 100644 index f5abfefd..00000000 --- a/test/helpers/accessors.hpp +++ /dev/null @@ -1,12 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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_HELPERS_ACCESSORS_HEADER) -#define BOOST_UNORDERED_TEST_HELPERS_ACCESSORS_HEADER - -namespace test -{ - -} diff --git a/test/helpers/allocator.cpp b/test/helpers/allocator.cpp deleted file mode 100644 index 830dd7bb..00000000 --- a/test/helpers/allocator.cpp +++ /dev/null @@ -1,209 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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) - -#include "./config.hpp" -#include "./allocator.hpp" -#include "./exception_trigger.hpp" -#include "./exception.hpp" -#include -#include - -#if !defined(BOOST_OLD_IOSTREAMS) -# include -#else -# include -#endif - -namespace test -{ - namespace - { - const unsigned int max_track = 1000; - - struct allocate_details - { - int tag; - std::size_t length; - - allocate_details() - : tag(0), length(0) {} - - allocate_details(int t, int l) - : tag(t), length(l) {} - }; - - std::map allocate_map; - unsigned int reference_count = 0; - unsigned int alloc_count = 0; - - static void ref() - { - ++reference_count; - } - - static void unref() - { - if(--reference_count == 0) { - BOOST_CHECK_MESSAGE(alloc_count == 0 && allocate_map.empty(), - "Memory leak found"); - allocate_map.clear(); - } - } - } - - allocator_base::allocator_base(int x) - : tag(x) - { - ref(); - } - - allocator_base::allocator_base(allocator_base const& x) - : tag(x.tag) - { - ref(); - } - - allocator_base::~allocator_base() - { - unref(); - } - - allocator_base::size_type allocator_base::max_size() const - { - return (std::numeric_limits::max)(); - } - - void* allocator_base::allocate(size_type n, void const*, size_type size) - { - BOOST_CHECK(n <= max_size()); - - exception_trigger((allocator_exception*) 0); - - // TODO: This is not exception safe. - void* ptr = ::operator new(n * size); - ++alloc_count; - if(allocate_map.size() < max_track) - allocate_map[ptr] = allocate_details(tag, n); - - return ptr; - } - - void allocator_base::construct(void* ptr) - { - exception_trigger((allocator_exception*) 0); - } - - void allocator_base::destroy(void* ptr) - { - } - - void allocator_base::deallocate(void* ptr, size_type n) - { - BOOST_CHECK(n <= max_size()); - if(allocate_map.find(ptr) == allocate_map.end()) { - if(alloc_count <= allocate_map.size()) - BOOST_ERROR("Deallocating unknown pointer."); - } else { - // TODO: This is not exception safe. - BOOST_CHECK_EQUAL(allocate_map[ptr].tag, tag); - BOOST_CHECK_EQUAL(allocate_map[ptr].length, n); - allocate_map.erase(ptr); - ::operator delete(ptr); - } - --alloc_count; - } - - void allocator_base::swap(allocator_base& x) - { - std::swap(tag, x. tag); - } - - std::ostream& operator<<(std::ostream& out, allocator_base const& x) - { - out<<"Test Allocator("<::max)() / 4; - } - - void* minimal_allocator_base::allocate(size_type n, void const*, size_type size) - { - BOOST_CHECK(n <= max_size()); - - exception_trigger((allocator_exception*) 0); - - // TODO: This is not exception safe. - void* ptr = ::operator new(n * size); - allocate_map[ptr] = allocate_details(tag, n); - - return ptr; - } - - void minimal_allocator_base::construct(void* ptr) - { - exception_trigger((allocator_exception*) 0); - } - - void minimal_allocator_base::destroy(void* ptr) - { - } - - void minimal_allocator_base::deallocate(void* ptr, size_type n) - { - BOOST_CHECK(n <= max_size()); - if(allocate_map.find(ptr) == allocate_map.end()) { - BOOST_ERROR("Deallocating unknown pointer."); - } else { - // TODO: This is not exception safe. - BOOST_CHECK_EQUAL(allocate_map[ptr].tag, tag); - BOOST_CHECK_EQUAL(allocate_map[ptr].length, n); - allocate_map.erase(ptr); - ::operator delete(ptr); - } - } - - void minimal_allocator_base::swap(minimal_allocator_base& x) - { - std::swap(tag, x. tag); - } - - std::ostream& operator<<(std::ostream& out, minimal_allocator_base const& x) - { - out<<"Minimal Allocator("< -#include -#include - -namespace test -{ - struct allocator_base - { - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - int tag; - - allocator_base(int x); - allocator_base(allocator_base const&); - ~allocator_base(); - - size_type max_size() const; - - void* allocate(size_type, void const*, size_type); - void construct(void*); - void destroy(void*); - void deallocate(void*, size_type); - void swap(allocator_base&); - private: - allocator_base& operator=(allocator_base const&); - }; - - std::ostream& operator<<(std::ostream&, allocator_base const&); - bool allocator_equals(allocator_base const& x, allocator_base const& y); - - template - struct allocator : allocator_base - { - typedef T* pointer; - typedef T const* const_pointer; - typedef T& reference; - typedef T const& const_reference; - typedef T value_type; - - template - struct rebind - { - typedef allocator other; - }; - - pointer address(reference x) const - { - return &x; - } - - const_pointer address(const_reference x) const - { - return &x; - } - - allocator(int x = 1) : allocator_base(x) {} - template - allocator(allocator const& x) : allocator_base(x) {} - allocator(allocator const& x) : allocator_base(x) {} - ~allocator() {} - - pointer allocate(size_type n, T const* hint = 0) - { - return static_cast( - allocator_base::allocate(n, hint, sizeof(T))); - } - - void construct(pointer ptr, T const& x) - { - allocator_base::construct(ptr); - new((void*)ptr)T(x); - } - - void destroy(pointer ptr) - { - allocator_base::destroy(ptr); - ptr->~T(); - } - - void deallocate(pointer ptr, size_type n) - { - allocator_base::deallocate(ptr, n); - } - }; - - template - inline bool operator==(allocator const& x, allocator const& y) - { - return test::allocator_equals(x, y); - } - - template - inline bool operator!=(allocator const& x, allocator const& y) - { - return !test::allocator_equals(x, y); - } - - template - void swap(allocator& x, allocator& y) - { - x.swap(y); - } - - template - allocator create_allocator(allocator*) - { - return allocator(); - } - - template - allocator create_allocator(allocator*, int x) - { - return allocator(x); - } - - template struct minimal_allocator; - typedef unsigned short minimal_size_type; - - template - class minimal_pointer_base - { - protected: - typedef minimal_pointer_base pointer_base; - minimal_pointer_base() : ptr_(0) {} - explicit minimal_pointer_base(T* ptr) : ptr_(ptr) {} - ~minimal_pointer_base() {} - Ptr& get() { return *static_cast(this); } - T* ptr_; - public: - typedef void (minimal_pointer_base::*bool_type)() const; - void this_type_does_not_support_comparisons() const {} - - T& operator*() const { return *ptr_; } - T* operator->() const { return ptr_; } - Ptr& operator++() { ++ptr_; return get(); } - Ptr operator++(int) { Ptr tmp(get()); ++ptr_; return tmp; } - - Ptr operator+(minimal_size_type s) const - { - return Ptr(ptr_ + s); - } - - T& operator[](minimal_size_type s) const - { - return ptr_[s]; - } - - operator bool_type() const - { - return ptr_ ? - &minimal_pointer_base::this_type_does_not_support_comparisons - : 0; - } - - bool operator!() const { return !ptr_; } - bool operator==(Ptr const& x) const { return ptr_ == x.ptr_; } - bool operator!=(Ptr const& x) const { return ptr_ != x.ptr_; } - bool operator<(Ptr const& x) const { return ptr_ < x.ptr_; } - bool operator>(Ptr const& x) const { return ptr_ > x.ptr_; } - bool operator<=(Ptr const& x) const { return ptr_ <= x.ptr_; } - bool operator>=(Ptr const& x) const { return ptr_ >= x.ptr_; } - - friend std::ostream& operator<<(std::ostream& out, minimal_pointer_base const& x) - { - out< class minimal_pointer; - template class minimal_const_pointer; - - template - class minimal_pointer - : public minimal_pointer_base, T> - { - friend struct minimal_allocator; - friend class minimal_pointer_base, T>; - friend class minimal_const_pointer; - typedef typename minimal_pointer::pointer_base base; - minimal_pointer(T* ptr) : base(ptr) {} - - typedef minimal_const_pointer const_pointer; - typedef minimal_pointer pointer; - public: - minimal_pointer() : base() {} - - bool operator==(pointer const& x) const { return base::operator==(x); } - bool operator!=(pointer const& x) const { return base::operator!=(x); } - bool operator<(pointer const& x) const { return base::operator<(x);} - bool operator>(pointer const& x) const { return base::operator>(x);} - bool operator<=(pointer const& x) const { return base::operator<=(x);} - bool operator>=(pointer const& x) const { return base::operator<=(x);} - - bool operator==(const_pointer const& x) const { return x == *this; } - bool operator!=(const_pointer const& x) const { return x != *this; } - bool operator<(const_pointer const& x) const { return x > *this; } - bool operator>(const_pointer const& x) const { return x < *this; } - bool operator<=(const_pointer const& x) const { return x >= *this; } - bool operator>=(const_pointer const& x) const { return x <= *this; } - }; - - template - class minimal_const_pointer - : public minimal_pointer_base, T const> - { - friend struct minimal_allocator; - friend class minimal_pointer_base, T const>; - typedef typename minimal_const_pointer::pointer_base base; - minimal_const_pointer(T* ptr) : base(ptr) {} - - typedef minimal_const_pointer const_pointer; - typedef minimal_pointer pointer; - public: - minimal_const_pointer() : base() {} - minimal_const_pointer(minimal_pointer const& x) : base(x.ptr_) {} - - bool operator==(const_pointer const& x) const { return base::operator==(x); } - bool operator!=(const_pointer const& x) const { return base::operator!=(x); } - bool operator<(const_pointer const& x) const { return base::operator<(x);} - bool operator>(const_pointer const& x) const { return base::operator>(x);} - bool operator<=(const_pointer const& x) const { return base::operator<=(x);} - bool operator>=(const_pointer const& x) const { return base::operator<=(x);} - - bool operator==(pointer const& x) const { return operator==(const_pointer(x)); } - bool operator!=(pointer const& x) const { return operator!=(const_pointer(x)); } - bool operator<(pointer const& x) const { return operator<(const_pointer(x));} - bool operator>(pointer const& x) const { return operator>(const_pointer(x));} - bool operator<=(pointer const& x) const { return operator<=(const_pointer(x));} - bool operator>=(pointer const& x) const { return operator<=(const_pointer(x));} - }; - - struct minimal_allocator_base - { - typedef minimal_size_type size_type; - typedef std::ptrdiff_t difference_type; - - int tag; - - minimal_allocator_base(int x); - minimal_allocator_base(minimal_allocator_base const&); - ~minimal_allocator_base(); - - size_type max_size() const; - - void* allocate(size_type, void const*, size_type); - void construct(void*); - void destroy(void*); - void deallocate(void*, size_type); - void swap(minimal_allocator_base&); - private: - minimal_allocator_base& operator=(minimal_allocator_base const&); - }; - - std::ostream& operator<<(std::ostream&, minimal_allocator_base const&); - bool allocator_equals(minimal_allocator_base const&, minimal_allocator_base const&); - - template - struct minimal_allocator : minimal_allocator_base - { - typedef minimal_pointer pointer; - typedef minimal_const_pointer const_pointer; - typedef T& reference; - typedef T const& const_reference; - typedef T value_type; - - template - struct rebind - { - typedef minimal_allocator other; - }; - - pointer address(reference r) - { - return pointer(&r); - } - - const_pointer address(const_reference r) - { - return const_pointer(&r); - } - - pointer allocate(size_type n) - { - return pointer(static_cast( - minimal_allocator_base::allocate(n, 0, sizeof(T)))); - } - - pointer allocate(size_type n, const_pointer u) - { - return pointer(static_cast( - minimal_allocator_base::allocate(n, u.ptr_, sizeof(T)))); - } - - void deallocate(pointer p, size_type n) - { - minimal_allocator_base::deallocate(p.ptr_, n); - } - - minimal_allocator() - : minimal_allocator_base(0) - { - } - - explicit minimal_allocator(int tag) - : minimal_allocator_base(tag) - { - } - - template - minimal_allocator(minimal_allocator const& x) - : minimal_allocator_base(x) - { - } - - minimal_allocator(minimal_allocator const& x) - : minimal_allocator_base(x) - { - } - - void construct(pointer p, T const& t) - { - minimal_allocator_base::construct(p.ptr_); - new((void*)p.ptr_) T(t); - } - - void destroy(pointer p) - { - minimal_allocator_base::destroy(p.ptr_); - ((T*)p.ptr_)->~T(); - } - private: - minimal_allocator& operator=(minimal_allocator const&); - }; - - template - inline bool operator==(minimal_allocator const& x, minimal_allocator const& y) - { - return test::allocator_equals(x, y); - } - - template - inline bool operator!=(minimal_allocator const& x, minimal_allocator const& y) - { - return !test::allocator_equals(x, y); - } - - template - void swap(minimal_allocator& x, minimal_allocator& y) - { - x.swap(y); - } - - template - minimal_allocator create_allocator(minimal_allocator*) - { - return minimal_allocator(); - } - - template - minimal_allocator create_allocator(minimal_allocator*, int x) - { - return minimal_allocator(x); - } -} - -#endif diff --git a/test/helpers/base.cpp b/test/helpers/base.cpp deleted file mode 100644 index d351b08e..00000000 --- a/test/helpers/base.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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) - -#include "./base.hpp" -#include -#include - -namespace test -{ - namespace - { - std::vector end_checks; - } - - void register_end_check(void(*check)()) - { - end_checks.push_back(check); - } - - void call_check(void(*check)()) - { - check(); - } - - void end() - { - std::for_each(end_checks.begin(), end_checks.end(), call_check); - } -} diff --git a/test/helpers/base.hpp b/test/helpers/base.hpp deleted file mode 100644 index 5cc58b1a..00000000 --- a/test/helpers/base.hpp +++ /dev/null @@ -1,15 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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_HELPERS_BASE_HEADER) -#define BOOST_UNORDERED_TEST_HELPERS_BASE_HEADER - -namespace test -{ - void register_end_check(void(*)()); - void end(); -} - -#endif diff --git a/test/helpers/config.hpp b/test/helpers/config.hpp deleted file mode 100644 index 5ac1a11e..00000000 --- a/test/helpers/config.hpp +++ /dev/null @@ -1,18 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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_HELPERS_CONFIG_HEADER) -#define BOOST_UNORDERED_TEST_HELPERS_CONFIG_HEADER - -#include - -// From Boost.Dynamic Bitset: - -// support for pre 3.0 libstdc++ - thanks Phil Edwards! -#if defined (__STL_CONFIG_H) && !defined (__STL_USE_NEW_IOSTREAMS) -# define BOOST_OLD_IOSTREAMS -#endif - -#endif diff --git a/test/helpers/constructors.hpp b/test/helpers/constructors.hpp deleted file mode 100644 index 51925509..00000000 --- a/test/helpers/constructors.hpp +++ /dev/null @@ -1,69 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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_HELPERS_CONSTRUCTORS_HEADER) -#define BOOST_UNORDERED_TEST_HELPERS_CONSTRUCTORS_HEADER - -namespace test -{ - template - Allocator create_allocator(Allocator*, int = 0) - { - return Allocator(); - } - - template - Hasher create_hasher(Hasher*, int = 0) - { - return Hasher(); - } - - template - KeyEqual create_key_equal(KeyEqual*, int = 0) - { - return KeyEqual(); - } - - template - class constructors - { - public: - typedef typename Container::allocator_type allocator_type; - typedef typename Container::hasher hasher_type; - typedef typename Container::key_equal key_equal_type; - - allocator_type allocator() const - { - return create_allocator((allocator_type*) 0); - } - - allocator_type allocator(int x) const - { - return create_allocator((allocator_type*) 0, x); - } - - hasher_type hasher() const - { - return create_hasher((hasher_type*) 0); - } - - hasher_type hasher(int x) const - { - return create_hasher((hasher_type*) 0, x); - } - - key_equal_type key_equal() const - { - return create_key_equal((key_equal_type*) 0); - } - - key_equal_type key_equal(int x) const - { - return create_key_equal((key_equal_type*) 0, x); - } - }; -} - -#endif diff --git a/test/helpers/equivalent.hpp b/test/helpers/equivalent.hpp deleted file mode 100644 index 3416a838..00000000 --- a/test/helpers/equivalent.hpp +++ /dev/null @@ -1,45 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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_HELPERS_EQUIVALENT_HEADER) -#define BOOST_UNORDERED_TEST_HELPERS_EQUIVALENT_HEADER - -#include -#include - -namespace test -{ - template - bool equivalent_impl(std::equal_to, std::equal_to, int) - { - return true; - } - - template - bool equivalent_impl(boost::hash, boost::hash, int) - { - return true; - } - - template - bool equivalent_impl(T const& x, T const& y, float) - { - return x == y; - } - - template - bool equivalent(T const& x, T const& y) - { - return equivalent_impl(x, y, 0); - } - - template - bool equivalent(std::pair const& x, std::pair const& y) - { - return equivalent(x.first, y.first) && equivalent(x.second, y.second); - } -} - -#endif diff --git a/test/helpers/exception.cpp b/test/helpers/exception.cpp deleted file mode 100644 index b50638cd..00000000 --- a/test/helpers/exception.cpp +++ /dev/null @@ -1,85 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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) - -#include "./exception.hpp" - -namespace test -{ - exception::exception() - : message_("Triggered test exception") - { - } - - exception::exception(char const* message) - : message_(message) - { - } - - char const* exception::what() const throw() - { - return message_; - } - - hash_exception::hash_exception() - : exception("Triggered hash exception") - { - } - - hash_exception::hash_exception(char const* message) - : exception(message) - { - } - - hash_copy_exception::hash_copy_exception() - : hash_exception("Triggered hash copy exception") - { - } - - hash_copy_exception::hash_copy_exception(char const* message) - : hash_exception(message) - { - } - - pred_exception::pred_exception() - : exception("Triggered pred exception") - { - } - - pred_exception::pred_exception(char const* message) - : exception(message) - { - } - - pred_copy_exception::pred_copy_exception() - : pred_exception("Triggered pred copy exception") - { - } - - pred_copy_exception::pred_copy_exception(char const* message) - : pred_exception(message) - { - } - - allocator_exception::allocator_exception() - : exception("Triggered pred exception") - { - } - - allocator_exception::allocator_exception(char const* message) - : exception(message) - { - } - - allocator_copy_exception::allocator_copy_exception() - : allocator_exception("Triggered pred copy exception") - { - } - - allocator_copy_exception::allocator_copy_exception(char const* message) - : allocator_exception(message) - { - } -} - diff --git a/test/helpers/exception.hpp b/test/helpers/exception.hpp deleted file mode 100644 index 692ceaf2..00000000 --- a/test/helpers/exception.hpp +++ /dev/null @@ -1,60 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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_HELPERS_EXCEPTION_HEADER) -#define BOOST_UNORDERED_TEST_HELPERS_EXCEPTION_HEADER - -#include - -namespace test -{ - // Exception Handling - - struct exception : std::exception - { - char const* message_; - exception(); - exception(char const*); - char const* what() const throw(); - }; - - struct hash_exception : exception - { - hash_exception(); - hash_exception(char const*); - }; - - struct hash_copy_exception : hash_exception - { - hash_copy_exception(); - hash_copy_exception(char const*); - }; - - struct pred_exception : exception - { - pred_exception(); - pred_exception(char const*); - }; - - struct pred_copy_exception : pred_exception - { - pred_copy_exception(); - pred_copy_exception(char const*); - }; - - struct allocator_exception : exception - { - allocator_exception(); - allocator_exception(char const*); - }; - - struct allocator_copy_exception : allocator_exception - { - allocator_copy_exception(); - allocator_copy_exception(char const*); - }; -} - -#endif diff --git a/test/helpers/exception_test.cpp b/test/helpers/exception_test.cpp deleted file mode 100644 index a8ec3e12..00000000 --- a/test/helpers/exception_test.cpp +++ /dev/null @@ -1,108 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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) - -#include "./exception_test.hpp" -#include -#include -#include - -namespace test -{ - // TODO: (Writing this here instead of the headers to avoid recompiling - // the world) - // - // There are some major design flaws with the exception testing code, - // apart from global variables that is. - - namespace - { - int num_iterations = 0; - int current_iteration = 0; - int trigger_count = 0; - int max_trigger_count = 0; - bool failed = false; - bool exception_testing = false; - bool exceptions_active = false; - } - - void exception_start(int n) - { - num_iterations = n; - current_iteration = 0; - max_trigger_count = 0; - trigger_count = 0; - failed = false; - exception_testing = true; - exceptions_active = true; - } - - void exception_loop() - { - BOOST_CHECK(exceptions_active); - - ++current_iteration; - max_trigger_count = trigger_count; - exception_testing = failed; - exceptions_active = failed; - trigger_count = 0; - failed = false; - } - - bool exception_loop_test() - { - if(exception_testing && current_iteration == num_iterations) { - BOOST_ERROR("Too many iterations"); - return false; - } - else { - return exception_testing; - } - } - - void exception_failure() - { - failed = true; - } - - bool true_once() - { - ++trigger_count; - return !exception_testing || trigger_count > max_trigger_count; - } - - bool exception_trigger_test() - { - ++trigger_count; - return exception_testing && exceptions_active - && trigger_count > max_trigger_count; - } - - void exception_trigger() - { - if(exception_trigger_test()) throw exception(); - } - - void exception_trigger(char const* message) - { - if(exception_trigger_test()) throw exception(message); - } - - bool exceptions_activate(bool value) - { - bool old = exceptions_active; - exceptions_active = value; - return old; - } - - exception_control::exception_control(bool value) - : old_value(exceptions_activate(value)) - { - } - - exception_control::~exception_control() - { - exceptions_activate(old_value); - } -} diff --git a/test/helpers/exception_test.hpp b/test/helpers/exception_test.hpp deleted file mode 100644 index 80fb3db1..00000000 --- a/test/helpers/exception_test.hpp +++ /dev/null @@ -1,33 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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_HELPERS_EXCEPTION_TEST_HEADER) -#define BOOST_UNORDERED_TEST_HELPERS_EXCEPTION_TEST_HEADER - -#include -#include -#include "./exception.hpp" -#include "./exception_trigger.hpp" -#include "./base.hpp" - -namespace test -{ - void exception_start(int); - bool exception_loop_test(); - void exception_loop(); - void exception_failure(); - - bool true_once(); -} - -#define EXCEPTION_TEST(count) \ - for(::test::exception_start(count); ::test::exception_loop_test(); \ - ::test::exception_loop()) \ - try - -#define EXCEPTION_TEST_END \ - catch(::test::exception const&) { ::test::exception_failure(); } - -#endif diff --git a/test/helpers/exception_trigger.hpp b/test/helpers/exception_trigger.hpp deleted file mode 100644 index 358ea7f6..00000000 --- a/test/helpers/exception_trigger.hpp +++ /dev/null @@ -1,49 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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_HELPERS_EXCEPTION_TRIGGER_HEADER) -#define BOOST_UNORDERED_TEST_HELPERS_EXCEPTION_TRIGGER_HEADER - -#include - -namespace test -{ - // Exception Handling - - bool exception_trigger_test(); - void exception_trigger(); - void exception_trigger(char const*); - - template - void exception_trigger(T*) - { - if(exception_trigger_test()) throw T(); - } - - template - void exception_trigger(T*, char const* msg) - { - if(exception_trigger_test()) throw T(msg); - } - - struct exception_control - { - bool old_value; - - exception_control(bool); - ~exception_control(); - }; - -} - -#define ACTIVATE_EXCEPTIONS \ - ::test::exception_control BOOST_PP_CAT(ACTIVATE_EXCEPTIONS_, __LINE__) \ - (true) -#define DEACTIVATE_EXCEPTIONS \ - ::test::exception_control BOOST_PP_CAT(ACTIVATE_EXCEPTIONS_, __LINE__) \ - (false) - -#endif - diff --git a/test/helpers/functional.cpp b/test/helpers/functional.cpp deleted file mode 100644 index 03458b41..00000000 --- a/test/helpers/functional.cpp +++ /dev/null @@ -1,140 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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) - -#include "./config.hpp" -#include "./functional.hpp" -#include "./exception.hpp" -#include "./exception_trigger.hpp" -#include -#include - -#if !defined(BOOST_OLD_IOSTREAMS) -# include -#else -# include -#endif - -namespace test -{ - // Hash - - hash::hash(int x) - : offset(x) {} - - hash::hash(hash const& x) - : offset(x.offset) - { - exception_trigger((hash_copy_exception*) 0); - } - - hash& hash::operator=(hash const& x) - { - exception_trigger((hash_copy_exception*) 0); - offset = x.offset; - exception_trigger((hash_copy_exception*) 0); - - return *this; - } - - std::size_t hash::calculate_hash(std::size_t x) const - { - exception_trigger((hash_exception*) 0); - return x + offset; - } - - std::size_t hash::operator()(char const* x) const - { - return calculate_hash(boost::hash()(x)); - } - - bool hash::operator==(hash const& x) const - { - return offset == x.offset; - } - - std::ostream& operator<<(std::ostream& out, hash x) - { - out<<"Test Hash("< -#include - -namespace test -{ - struct hash - { - int offset; - - explicit hash(int x = 1); - hash(hash const&); - hash& operator=(hash const&); - - std::size_t calculate_hash(std::size_t) const; - - template - std::size_t operator()(T const& x) const - { - return calculate_hash(boost::hash()(x)); - } - - std::size_t operator()(char const* x) const; - bool operator==(hash const& x) const; - }; - - std::ostream& operator<<(std::ostream& out, hash x); - hash create_hasher(hash*); - hash create_hasher(hash*, int x); - - struct equals - { - int tag; - - explicit equals(int x = 1); - equals(equals const&); - equals& operator=(equals const&); - - bool calculate_equals(bool) const; - - template - bool operator()(T1 const& x, T2 const& y) const - { - return calculate_equals(x == y); - } - - bool operator()(char const*, char const*) const; - bool operator==(equals const& x) const; - }; - - std::ostream& operator<<(std::ostream& out, equals x); - equals create_key_equal(equals*); - equals create_key_equal(equals*, int x); - - struct less - { - int tag; - - explicit less(int x = 0); - - template - bool operator()(T1 const& x, T2 const& y) const - { - return x < y; - } - - bool operator()(char const*, char const*) const; - }; - - std::ostream& operator<<(std::ostream& out, less x); -} - -#endif diff --git a/test/helpers/generators.cpp b/test/helpers/generators.cpp deleted file mode 100644 index 247a795c..00000000 --- a/test/helpers/generators.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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) - -#include "generators.hpp" - -// Generators - -namespace test -{ - int generate(int const*) - { - using namespace std; - return rand(); - } - - char generate(char const*) - { - using namespace std; - return (char)(rand() % 26) + 'a'; - } - - std::string generate(std::string const*) - { - using namespace std; - - static test::generator char_gen; - - std::string result; - - int length = rand() % 10; - for(int i = 0; i < length; ++i) - result += char_gen(); - - //std::generate_n( - // std::back_inserter(result), - // rand() % 10, - // char_gen); - - return result; - } -} diff --git a/test/helpers/generators.hpp b/test/helpers/generators.hpp deleted file mode 100644 index 3cbb9e37..00000000 --- a/test/helpers/generators.hpp +++ /dev/null @@ -1,41 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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_HELPERS_GENERATORS_HEADER) -#define BOOST_UNORDERED_TEST_HELPERS_GENERATORS_HEADER - -#include -#include -#include - -namespace test -{ - int generate(int const*); - char generate(char const*); - std::string generate(std::string const*); - template std::pair generate( - std::pair const*); - - template - struct generator - { - typedef T value_type; - value_type operator()() - { - return generate((T const*) 0); - } - }; - - template - std::pair generate(std::pair const*) - { - static generator g1; - static generator g2; - - return std::pair(g1(), g2()); - } -} - -#endif diff --git a/test/helpers/input_iterator_adaptor.hpp b/test/helpers/input_iterator_adaptor.hpp deleted file mode 100644 index 715e123a..00000000 --- a/test/helpers/input_iterator_adaptor.hpp +++ /dev/null @@ -1,35 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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_HELPERS_INPUT_ITERATOR_HEADER) -#define BOOST_UNORDERED_TEST_HELPERS_INPUT_ITERATOR_HEADER - -#include - -namespace test -{ - template - struct input_iterator_adaptor - : boost::iterator_adaptor< - input_iterator_adaptor, Iterator, - boost::use_default, std::input_iterator_tag> - { - typedef boost::iterator_adaptor< - input_iterator_adaptor, Iterator, - boost::use_default, std::input_iterator_tag> base; - - explicit input_iterator_adaptor(Iterator it = Iterator()) - : base(it) {} - }; - - template - input_iterator_adaptor make_input_iterator(Iterator it) - { - return input_iterator_adaptor(it); - } -} - -#endif - diff --git a/test/helpers/invariant_checker.cpp b/test/helpers/invariant_checker.cpp deleted file mode 100644 index 2f74750a..00000000 --- a/test/helpers/invariant_checker.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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) - -#include -#include "./invariant_checker.hpp" -#include -#include -#include - -namespace test -{ - namespace - { - typedef std::set check_set; - check_set checks; - } - - invariant_checker_base::invariant_checker_base() - { - } - - invariant_checker_base::~invariant_checker_base() - { - } - - void check_invariants() - { - // This was causing compile errors on Visual C++, because check - // has return type void. - //std::for_each(checks.begin(), checks.end(), - // boost::mem_fun(&invariant_checker_base::check)); - - check_set::iterator end = checks.end(); - for(check_set::iterator it = checks.begin(); it != end; ++it) - (*it)->check(); - } - - void invariant_add(invariant_checker_base* check) - { - checks.insert(check); - } - - void invariant_remove(invariant_checker_base* check) - { - checks.erase(check); - } - - void initial_check(invariant_checker_base const& x) - { - x.check(); - } -} diff --git a/test/helpers/invariant_checker.hpp b/test/helpers/invariant_checker.hpp deleted file mode 100644 index a678e3b3..00000000 --- a/test/helpers/invariant_checker.hpp +++ /dev/null @@ -1,78 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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_HELPERS_INVARIANT_HEADER) -#define BOOST_UNORDERED_TEST_HELPERS_INVARIANT_HEADER - -#include -#include "./exception_trigger.hpp" - -namespace test -{ - struct invariant_checker_base - { - invariant_checker_base(); - virtual void check() const = 0; - protected: - virtual ~invariant_checker_base(); - }; - - void check_invariants(); - void invariant_add(invariant_checker_base*); - void invariant_remove(invariant_checker_base*); - - template - struct invariant_checker : invariant_checker_base - { - T& object_; - - invariant_checker(T& o) : object_(o) - { - invariant_add(this); - } - - ~invariant_checker() - { - check(); - invariant_remove(this); - } - - void check() const - { - DEACTIVATE_EXCEPTIONS; - invariant_impl(object_); - } - }; - - // On compilers without RVO check() will be called multiple times. - // No big deal I suppose. - template - invariant_checker make_invariant_checker(T& o) - { - return invariant_checker(o); - } - - // Calling this also prevents an unused variable warning when using - // an invariant checker. - void initial_check(::test::invariant_checker_base const&); - - // A one time invariant check. - template - void invariant_check(T const& x) - { - DEACTIVATE_EXCEPTIONS; - invariant_impl(x); - } -} - -#define INVARIANT_CHECK(o) \ - INVARIANT_CHECK2(o, BOOST_PP_CAT(invariant_checker_, __LINE__)) - -#define INVARIANT_CHECK2(o, name) \ - ::test::invariant_checker_base const& name = \ - ::test::make_invariant_checker(o); \ - ::test::initial_check(name) - -#endif diff --git a/test/helpers/less.hpp b/test/helpers/less.hpp deleted file mode 100644 index 9151685f..00000000 --- a/test/helpers/less.hpp +++ /dev/null @@ -1,37 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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_HELPERS_LESS_HEADER) -#define BOOST_UNORDERED_TEST_HELPERS_LESS_HEADER - -#include - -namespace test -{ - template - bool compare_impl(T const& x, T const& y, float) - { - return x < y; - } - - template - bool compare_impl(std::pair const& x, - std::pair const& y, int) - { - return x.first < y.first || - (x.first == y.first && x.second < y.second); - } - - struct compare { - template - bool operator()(T const& x, T const& y) - { - return compare_impl(x, y, 0); - } - }; -} - -#endif - diff --git a/test/helpers/member.cpp b/test/helpers/member.cpp deleted file mode 100644 index 7edfc27e..00000000 --- a/test/helpers/member.cpp +++ /dev/null @@ -1,79 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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) - -#include "./config.hpp" -#include "./member.hpp" -#include "./exception_trigger.hpp" -#include "./generators.hpp" - -#if !defined(BOOST_OLD_IOSTREAMS) -# include -#else -# include -#endif - -namespace test -{ - member::member(int x) - : value(x) - { - exception_trigger(); - } - - member::member(member const& x) - : value(x.value) - { - exception_trigger(); - } - - member& member::operator=(member const& x) - { - exception_trigger(); - value = x.value; - exception_trigger(); - - return *this; - } - - member::~member() - { - value = -1; - } - - bool member::operator==(member const& x) const - { - exception_trigger(); - return value == x.value; - } - - bool member::operator<(member const& x) const - { - exception_trigger(); - return value < x.value; - } - - std::ostream& operator<<(std::ostream& out, member const& x) - { - out<<"Test class("<()()); - } -} - -#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) -namespace test -#else -namespace boost -#endif -{ - std::size_t hash_value(test::member const& x) - { - return x.value; - } -} diff --git a/test/helpers/member.hpp b/test/helpers/member.hpp deleted file mode 100644 index 2ea51c11..00000000 --- a/test/helpers/member.hpp +++ /dev/null @@ -1,40 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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_HELPERS_MEMBER_HEADER) -#define BOOST_UNORDERED_TEST_HELPERS_MEMBER_HEADER - -#include -#include - -namespace test -{ - struct member - { - int value; - - explicit member(int x = 0); - member(member const&); - member& operator=(member const&); - ~member(); - - bool operator==(member const&) const; - bool operator<(member const&) const; - }; - - std::ostream& operator<<(std::ostream&, member const&); - test::member generate(test::member const*); -} - -#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) -namespace test -#else -namespace boost -#endif -{ - std::size_t hash_value(test::member const& x); -} - -#endif diff --git a/test/helpers/metafunctions.hpp b/test/helpers/metafunctions.hpp deleted file mode 100644 index 26702abb..00000000 --- a/test/helpers/metafunctions.hpp +++ /dev/null @@ -1,100 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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_HELPERS_METAFUNCTIONS_HEADER) -#define BOOST_UNORDERED_TEST_HELPERS_METAFUNCTIONS_HEADER - -#include -#include -#include -#include -#include - -namespace test -{ - struct unordered_set_type { char x[100]; }; - struct unordered_multiset_type { char x[200]; }; - struct unordered_map_type { char x[300]; }; - struct unordered_multimap_type { char x[400]; }; - - template - unordered_set_type container_type( - boost::unordered_set const*); - template - unordered_multiset_type container_type( - boost::unordered_multiset const*); - template - unordered_map_type container_type( - boost::unordered_map const*); - template - unordered_multimap_type container_type( - boost::unordered_multimap const*); - - template - struct is_set - { - BOOST_STATIC_CONSTANT(bool, value = - sizeof(container_type((Container const*)0)) - == sizeof(unordered_set_type) || - sizeof(container_type((Container const*)0)) - == sizeof(unordered_multiset_type) - ); - }; - - template - struct is_map - { - BOOST_STATIC_CONSTANT(bool, value = - sizeof(container_type((Container const*)0)) - == sizeof(unordered_map_type) || - sizeof(container_type((Container const*)0)) - == sizeof(unordered_multimap_type) - ); - }; - - template - struct has_unique_keys - { - BOOST_STATIC_CONSTANT(bool, value = - sizeof(container_type((Container const*)0)) - == sizeof(unordered_set_type) || - sizeof(container_type((Container const*)0)) - == sizeof(unordered_map_type) - ); - }; - - template - struct has_equivalent_keys - { - BOOST_STATIC_CONSTANT(bool, value = - sizeof(container_type((Container const*)0)) - == sizeof(unordered_multiset_type) || - sizeof(container_type((Container const*)0)) - == sizeof(unordered_multimap_type) - ); - }; - - // Non Const Value Type - - template - struct map_non_const_value_type - { - typedef std::pair< - typename Container::key_type, - typename Container::mapped_type> type; - }; - - - template - struct non_const_value_type - : boost::mpl::eval_if, - map_non_const_value_type, - boost::mpl::identity > - { - }; -} - -#endif - diff --git a/test/helpers/random_values.hpp b/test/helpers/random_values.hpp deleted file mode 100644 index 4ba605c3..00000000 --- a/test/helpers/random_values.hpp +++ /dev/null @@ -1,203 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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_HELPERS_RANDOM_VALUES_HEADER) -#define BOOST_UNORDERED_TEST_HELPERS_RANDOM_VALUES_HEADER - -#include "./generators.hpp" -#include "./metafunctions.hpp" -#include -#include -#include - -namespace test -{ - template - struct accessors - { - // get_key - // - // Given either the value_type or the key_type returns the key. - static typename Container::key_type const& - get_key(typename Container::key_type const& x) - { - return x; - } - - template - static typename Container::key_type const& - get_key(std::pair const& x) - { - return x.first; - } - - static typename Container::value_type const& - get_mapped(typename Container::key_type const& x) - { - return x; - } - - template - static M const& - get_mapped(std::pair const& x) - { - return x.second; - } - }; - - template - struct random_values : public accessors - { - typedef accessors base; - - typedef typename non_const_value_type::type value_type; - typedef typename Container::key_type key_type; - - std::vector values_; - typedef typename std::vector::iterator iterator; - typedef typename std::vector::const_iterator const_iterator; - - explicit random_values(std::size_t count) - { - values_.reserve(count); - std::generate_n(std::back_inserter(values_), - count, test::generator()); - } - - iterator begin() { return values_.begin(); } - iterator end() { return values_.end(); } - const_iterator begin() const { return values_.begin(); } - const_iterator end() const { return values_.end(); } - - value_type const& operator[](std::size_t i) const { return values_[i]; } - - struct key_matcher0 - { - template - bool operator()(X const& x, Y const& y) const - { - return base::get_key(x) == base::get_key(y); - } - }; - - // No, I don't know why didn't I just use bind. - struct key_matcher1 - { - key_type x; - - key_matcher1(key_type const& x) : x(x) {} - - bool operator()(key_type const& y) - { - return x == y; - } - - template - bool operator()(std::pair const& y) - { - return x == y.first; - } - }; - - static key_matcher0 key_match() - { - return key_matcher0(); - } - - static key_matcher1 key_match(key_type const& x) - { - return key_matcher1(x); - } - - template - static key_matcher1 key_match(std::pair const& x) - { - return key_matcher1(x.first); - } - - template - iterator find(K const& x) - { - return std::find_if(values_.begin(), values_.end(), key_match(x)); - } - - template - std::size_t count(K const& x) - { - return std::count_if(values_.begin(), values_.end(), - key_match(x)); - } - - template - std::size_t key_count(K const& x) - { - if(has_unique_keys::value) - return find(x) != values_.end(); - else - return count(x); - } - - static bool is_unique() - { - return has_unique_keys::value; - } - }; - - template - struct sorted_random_values : public random_values - { - typedef random_values base; - typedef typename base::value_type value_type; - typedef typename base::key_type key_type; - typedef typename base::iterator iterator; - typedef typename base::const_iterator const_iterator; - - explicit sorted_random_values(std::size_t count) - : base(count) - { - std::stable_sort(this->begin(), this->end()); - } - - struct key_compare0 - { - template - bool operator()(X const& x, Y const& y) const - { - return base::get_key(x) < base::get_key(y); - } - }; - - static key_compare0 key_compare() - { - return key_compare0(); - } - - template - iterator find(K const& x) - { - iterator pos = std::lower_bound(this->begin(), this->end(), x, key_compare()); - return this->key_match()(x, *pos) ? pos : this->end(); - } - - template - std::size_t count(K const& x) - { - std::pair range = - std::equal_range(this->begin(), this->end(), x, key_compare()); - return range.second - range.first; - } - - template - std::size_t key_count(K const& x) - { - if(has_unique_keys::value) - return find(x) != this->end(); - else - return count(x); - } - }; -} - -#endif diff --git a/test/helpers/strong.cpp b/test/helpers/strong.cpp deleted file mode 100644 index 0290f42f..00000000 --- a/test/helpers/strong.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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) - -#include "./strong.hpp" -#include - -namespace test -{ - strong_tester::strong_tester() : dismissed_(false) {} - strong_tester::~strong_tester() { BOOST_CHECK(dismissed_); } - void strong_tester::dismiss() const { dismissed_ = true; } - bool strong_tester::is_dismissed() const { return dismissed_; } - void strong_tester::call_test() { - if(!is_dismissed()) - { - DEACTIVATE_EXCEPTIONS; - try { - test(); - } catch(...) { - BOOST_ERROR("Exception thrown in strong test."); - } - dismissed_ = true; - } - } - - strong_test_holder::strong_test_holder(strong_tester_ptr const& x) : ptr_(x) {} - strong_test_holder::~strong_test_holder() { ptr_->call_test(); } - bool strong_test_holder::is_dismissed() const { return ptr_->is_dismissed(); } - void strong_test_holder::dismiss() { ptr_->dismiss(); } -} diff --git a/test/helpers/strong.hpp b/test/helpers/strong.hpp deleted file mode 100644 index c90c80e8..00000000 --- a/test/helpers/strong.hpp +++ /dev/null @@ -1,78 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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_HELPERS_STRONG_HEADER) -#define BOOST_UNORDERED_TEST_HELPERS_STRONG_HEADER - -#include -#include "./exception_trigger.hpp" - -namespace test -{ - class strong_tester - { - mutable bool dismissed_; - protected: - strong_tester(); - public: - virtual ~strong_tester(); - void dismiss() const; - bool is_dismissed() const; - void call_test(); - virtual void test() = 0; - }; - - template - class default_strong_tester - : public strong_tester - { - T const& reference; - T copy; - public: - default_strong_tester(T const& x) : reference(x), copy(x) {} - - void test() - { - BOOST_CHECK(reference == copy); - } - }; - - typedef boost::shared_ptr strong_tester_ptr; - - //template - //strong_tester_ptr create_tester_impl(T const& x, float) - //{ - // return strong_tester_ptr(new default_strong_tester(x)); - //} - - template - strong_tester_ptr create_tester(T const& x) - { - DEACTIVATE_EXCEPTIONS; - return create_tester_impl(x, 0); - } - - class strong_test_holder - { - strong_tester_ptr ptr_; - public: - strong_test_holder(strong_tester_ptr const&); - ~strong_test_holder(); - bool is_dismissed() const; - void dismiss(); - private: - strong_test_holder(strong_test_holder const&); - strong_test_holder& operator=(strong_test_holder const&); - }; -} - -#define STRONG_TEST_ANON(x) \ - STRONG_TEST(BOOST_PP_CAT(STRONG_TEST_tester, __LINE__), x) - -#define STRONG_TEST(tester, x) \ - for(::test::strong_test_holder tester(::test::create_tester(x)); \ - !tester.is_dismissed(); tester.dismiss()) - -#endif diff --git a/test/helpers/unit_test.hpp b/test/helpers/unit_test.hpp deleted file mode 100644 index 3fe6efee..00000000 --- a/test/helpers/unit_test.hpp +++ /dev/null @@ -1,77 +0,0 @@ - -// Copyright Daniel James 2005. Use, modification, and distribution are -// subject to 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_HELPERS_AUTO_UNIT_TEST_HEADER) -#define BOOST_UNORDERED_TEST_HELPERS_AUTO_UNIT_TEST_HEADER - -#include "./base.hpp" -#include -#include -#include -#include -#include - - -#define AUTO_UNIT_TEST(name) \ - AUTO_UNIT_TEST2(name, BOOST_PP_CAT(name##_, impl)) - -#define AUTO_UNIT_TEST2(name, impl_name) \ - void impl_name(); \ - BOOST_AUTO_UNIT_TEST(name) \ - { \ - impl_name(); \ - ::test::end(); \ - } \ - void impl_name() - -#define AUTO_TEMPLATE_TEST(name, T, type_seq) \ - AUTO_TEMPLATE_TEST2(name, BOOST_PP_CAT(name##_, impl), T, type_seq) - -#define AUTO_TEMPLATE_TEST2(name, impl_name, T, type_seq) \ - template \ - void impl_name(); \ - BOOST_PP_SEQ_FOR_EACH(AUTO_TEMPLATE_TEST_OP, name, type_seq) \ - template \ - void impl_name() - -#define AUTO_TEMPLATE_TEST_OP(r, name, type) \ - static boost::unit_test::ut_detail::auto_unit_test_registrar \ - BOOST_PP_CAT(test_registrar_##name##_, type) \ - ( BOOST_TEST_CASE( BOOST_PP_CAT(name##_, impl) ) ); - -#define META_FUNC_TEST_CASE(name, T) \ - META_FUNC_TEST_CASE2(name, T, BOOST_PP_CAT(name##_, impl)) - -#define META_FUNC_TEST_CASE2(name, T, impl_name) \ - template \ - void impl_name(T* = 0); \ - template \ - void name(T* x = 0) { \ - impl_name(x); \ - ::test::end(); \ - } \ - template \ - void impl_name(T*) - -#define RUN_TEST_OP(r, product) \ - RUN_TEST_OP2( \ - 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 RUN_TEST_OP2(name, test_func, type) \ - BOOST_AUTO_UNIT_TEST(name) \ - { \ - test_func((type*) 0); \ - ::test::end(); \ - } - -#define AUTO_META_TESTS(test_seq, param_seq) \ - BOOST_PP_SEQ_FOR_EACH_PRODUCT(RUN_TEST_OP, (test_seq)(param_seq)) - -#endif