forked from boostorg/unordered
		
	Remove more of the old unordered containers test files.
[SVN r2878]
This commit is contained in:
		@@ -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
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -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 <boost/test/test_tools.hpp>
 | 
			
		||||
#include <map>
 | 
			
		||||
 | 
			
		||||
#if !defined(BOOST_OLD_IOSTREAMS)                
 | 
			
		||||
# include <ostream>
 | 
			
		||||
#else
 | 
			
		||||
# include <ostream.h>
 | 
			
		||||
#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<void*, allocate_details> 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<size_type>::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("<<x.tag<<")\n";
 | 
			
		||||
        return out;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool allocator_equals(allocator_base const& x, allocator_base const& y)
 | 
			
		||||
    {
 | 
			
		||||
        return x.tag == y.tag;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
//////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    minimal_allocator_base::minimal_allocator_base(int x)
 | 
			
		||||
        : tag(x)
 | 
			
		||||
    {
 | 
			
		||||
        ref();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    minimal_allocator_base::minimal_allocator_base(minimal_allocator_base const& x)
 | 
			
		||||
        : tag(x.tag)
 | 
			
		||||
    {
 | 
			
		||||
        ref();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    minimal_allocator_base::~minimal_allocator_base()
 | 
			
		||||
    {
 | 
			
		||||
        unref();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    minimal_allocator_base::size_type minimal_allocator_base::max_size() const
 | 
			
		||||
    {
 | 
			
		||||
        return (std::numeric_limits<size_type>::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("<<x.tag<<")\n";
 | 
			
		||||
        return out;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool allocator_equals(minimal_allocator_base const& x, minimal_allocator_base const& y)
 | 
			
		||||
    {
 | 
			
		||||
        return x.tag == y.tag;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,376 +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_ALLOCATOR_HEADER)
 | 
			
		||||
#define BOOST_UNORDERED_TEST_HELPERS_ALLOCATOR_HEADER
 | 
			
		||||
 | 
			
		||||
#include <iosfwd>
 | 
			
		||||
#include <cstddef>
 | 
			
		||||
#include <boost/limits.hpp>
 | 
			
		||||
 | 
			
		||||
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 <class T>
 | 
			
		||||
    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 <class T1>
 | 
			
		||||
        struct rebind
 | 
			
		||||
        {
 | 
			
		||||
            typedef allocator<T1> 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 <class T1>
 | 
			
		||||
        allocator(allocator<T1> 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<pointer>(
 | 
			
		||||
                    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 <class T>
 | 
			
		||||
    inline bool operator==(allocator<T> const& x, allocator<T> const& y)
 | 
			
		||||
    {
 | 
			
		||||
        return test::allocator_equals(x, y);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class T>
 | 
			
		||||
    inline bool operator!=(allocator<T> const& x, allocator<T> const& y)
 | 
			
		||||
    {
 | 
			
		||||
        return !test::allocator_equals(x, y);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class T>
 | 
			
		||||
    void swap(allocator<T>& x, allocator<T>& y)
 | 
			
		||||
    {
 | 
			
		||||
        x.swap(y);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class T>
 | 
			
		||||
    allocator<T> create_allocator(allocator<T>*)
 | 
			
		||||
    {
 | 
			
		||||
        return allocator<T>();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class T>
 | 
			
		||||
    allocator<T> create_allocator(allocator<T>*, int x)
 | 
			
		||||
    {
 | 
			
		||||
        return allocator<T>(x);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class T> struct minimal_allocator;
 | 
			
		||||
    typedef unsigned short minimal_size_type;
 | 
			
		||||
 | 
			
		||||
    template <class Ptr, class T>
 | 
			
		||||
    class minimal_pointer_base
 | 
			
		||||
    {
 | 
			
		||||
    protected:
 | 
			
		||||
        typedef minimal_pointer_base<Ptr, T> pointer_base;
 | 
			
		||||
        minimal_pointer_base() : ptr_(0) {}
 | 
			
		||||
        explicit minimal_pointer_base(T* ptr) : ptr_(ptr) {}
 | 
			
		||||
        ~minimal_pointer_base() {}
 | 
			
		||||
        Ptr& get() { return *static_cast<Ptr*>(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<<x.ptr_;
 | 
			
		||||
            return out;
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    template <class T> class minimal_pointer;
 | 
			
		||||
    template <class T> class minimal_const_pointer;
 | 
			
		||||
 | 
			
		||||
    template <class T>
 | 
			
		||||
    class minimal_pointer
 | 
			
		||||
        : public minimal_pointer_base<minimal_pointer<T>, T>
 | 
			
		||||
    {
 | 
			
		||||
        friend struct minimal_allocator<T>;
 | 
			
		||||
        friend class minimal_pointer_base<minimal_pointer<T>, T>;
 | 
			
		||||
        friend class minimal_const_pointer<T>;
 | 
			
		||||
        typedef typename minimal_pointer::pointer_base base;
 | 
			
		||||
        minimal_pointer(T* ptr) : base(ptr) {}
 | 
			
		||||
 | 
			
		||||
        typedef minimal_const_pointer<T> const_pointer;
 | 
			
		||||
        typedef minimal_pointer<T> 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 T>
 | 
			
		||||
    class minimal_const_pointer
 | 
			
		||||
        : public minimal_pointer_base<minimal_const_pointer<T>, T const>
 | 
			
		||||
    {
 | 
			
		||||
        friend struct minimal_allocator<T>;
 | 
			
		||||
        friend class minimal_pointer_base<minimal_const_pointer<T>, T const>;
 | 
			
		||||
        typedef typename minimal_const_pointer::pointer_base base;
 | 
			
		||||
        minimal_const_pointer(T* ptr) : base(ptr) {}
 | 
			
		||||
 | 
			
		||||
        typedef minimal_const_pointer<T> const_pointer;
 | 
			
		||||
        typedef minimal_pointer<T> pointer;
 | 
			
		||||
    public:
 | 
			
		||||
        minimal_const_pointer() : base() {}
 | 
			
		||||
        minimal_const_pointer(minimal_pointer<T> 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 <class T>
 | 
			
		||||
    struct minimal_allocator : minimal_allocator_base
 | 
			
		||||
    {
 | 
			
		||||
        typedef minimal_pointer<T> pointer;
 | 
			
		||||
        typedef minimal_const_pointer<T> const_pointer;
 | 
			
		||||
        typedef T& reference;
 | 
			
		||||
        typedef T const& const_reference;
 | 
			
		||||
        typedef T value_type;
 | 
			
		||||
 | 
			
		||||
        template <class U>
 | 
			
		||||
        struct rebind
 | 
			
		||||
        {
 | 
			
		||||
            typedef minimal_allocator<U> 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<T*>(
 | 
			
		||||
                    minimal_allocator_base::allocate(n, 0, sizeof(T))));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        pointer allocate(size_type n, const_pointer u)
 | 
			
		||||
        {
 | 
			
		||||
            return pointer(static_cast<T*>(
 | 
			
		||||
                    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 <class Y>
 | 
			
		||||
        minimal_allocator(minimal_allocator<Y> 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 <class T>
 | 
			
		||||
    inline bool operator==(minimal_allocator<T> const& x, minimal_allocator<T> const& y)
 | 
			
		||||
    {
 | 
			
		||||
        return test::allocator_equals(x, y);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class T>
 | 
			
		||||
    inline bool operator!=(minimal_allocator<T> const& x, minimal_allocator<T> const& y)
 | 
			
		||||
    {
 | 
			
		||||
        return !test::allocator_equals(x, y);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class T>
 | 
			
		||||
    void swap(minimal_allocator<T>& x, minimal_allocator<T>& y)
 | 
			
		||||
    {
 | 
			
		||||
        x.swap(y);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class T>
 | 
			
		||||
    minimal_allocator<T> create_allocator(minimal_allocator<T>*)
 | 
			
		||||
    {
 | 
			
		||||
        return minimal_allocator<T>();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class T>
 | 
			
		||||
    minimal_allocator<T> create_allocator(minimal_allocator<T>*, int x)
 | 
			
		||||
    {
 | 
			
		||||
        return minimal_allocator<T>(x);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
@@ -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 <vector>
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
 | 
			
		||||
namespace test
 | 
			
		||||
{
 | 
			
		||||
    namespace
 | 
			
		||||
    {
 | 
			
		||||
        std::vector<void(*)()> 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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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
 | 
			
		||||
@@ -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 <boost/config.hpp>
 | 
			
		||||
 | 
			
		||||
// 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
 | 
			
		||||
@@ -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 <class Allocator>
 | 
			
		||||
    Allocator create_allocator(Allocator*, int = 0)
 | 
			
		||||
    {
 | 
			
		||||
        return Allocator();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class Hasher>
 | 
			
		||||
    Hasher create_hasher(Hasher*, int = 0)
 | 
			
		||||
    {
 | 
			
		||||
        return Hasher();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class KeyEqual>
 | 
			
		||||
    KeyEqual create_key_equal(KeyEqual*, int = 0)
 | 
			
		||||
    {
 | 
			
		||||
        return KeyEqual();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class Container>
 | 
			
		||||
    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
 | 
			
		||||
@@ -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 <functional>
 | 
			
		||||
#include <boost/functional/hash.hpp>
 | 
			
		||||
 | 
			
		||||
namespace test
 | 
			
		||||
{
 | 
			
		||||
    template <class T>
 | 
			
		||||
    bool equivalent_impl(std::equal_to<T>, std::equal_to<T>, int)
 | 
			
		||||
    {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class T>
 | 
			
		||||
    bool equivalent_impl(boost::hash<T>, boost::hash<T>, int)
 | 
			
		||||
    {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class T>
 | 
			
		||||
    bool equivalent_impl(T const& x, T const& y, float)
 | 
			
		||||
    {
 | 
			
		||||
        return x == y;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class T>
 | 
			
		||||
    bool equivalent(T const& x, T const& y)
 | 
			
		||||
    {
 | 
			
		||||
        return equivalent_impl(x, y, 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class X1, class X2, class Y1, class Y2>
 | 
			
		||||
    bool equivalent(std::pair<X1, X2> const& x, std::pair<Y1, Y2> const& y)
 | 
			
		||||
    {
 | 
			
		||||
        return equivalent(x.first, y.first) && equivalent(x.second, y.second);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
@@ -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)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -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 <exception>
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
@@ -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 <boost/test/test_tools.hpp>
 | 
			
		||||
#include <cassert>
 | 
			
		||||
#include <cstdlib>
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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 <boost/preprocessor/cat.hpp>
 | 
			
		||||
#include <exception>
 | 
			
		||||
#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
 | 
			
		||||
@@ -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 <boost/preprocessor/cat.hpp>
 | 
			
		||||
 | 
			
		||||
namespace test
 | 
			
		||||
{
 | 
			
		||||
    // Exception Handling
 | 
			
		||||
 | 
			
		||||
    bool exception_trigger_test();
 | 
			
		||||
    void exception_trigger();
 | 
			
		||||
    void exception_trigger(char const*);
 | 
			
		||||
 | 
			
		||||
    template <class T>
 | 
			
		||||
    void exception_trigger(T*)
 | 
			
		||||
    {
 | 
			
		||||
        if(exception_trigger_test()) throw T();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class T>
 | 
			
		||||
    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
 | 
			
		||||
 | 
			
		||||
@@ -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 <cstddef>
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
#if !defined(BOOST_OLD_IOSTREAMS)
 | 
			
		||||
# include <ostream>
 | 
			
		||||
#else
 | 
			
		||||
# include <ostream.h>
 | 
			
		||||
#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<std::string>()(x));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool hash::operator==(hash const& x) const
 | 
			
		||||
    {
 | 
			
		||||
        return offset == x.offset;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    std::ostream& operator<<(std::ostream& out, hash x)
 | 
			
		||||
    {
 | 
			
		||||
        out<<"Test Hash("<<x.offset<<")\n";
 | 
			
		||||
        return out;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    hash create_hasher(hash*)
 | 
			
		||||
    {
 | 
			
		||||
        return hash();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    hash create_hasher(hash*, int x)
 | 
			
		||||
    {
 | 
			
		||||
        return hash(x);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Equals
 | 
			
		||||
 | 
			
		||||
    equals::equals(int x)
 | 
			
		||||
        : tag(x) {}
 | 
			
		||||
 | 
			
		||||
    equals::equals(equals const& x)
 | 
			
		||||
        : tag(x.tag)
 | 
			
		||||
    {
 | 
			
		||||
        exception_trigger((pred_copy_exception*) 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    equals& equals::operator=(equals const& x)
 | 
			
		||||
    {
 | 
			
		||||
        exception_trigger((pred_copy_exception*) 0);
 | 
			
		||||
        tag = x.tag;
 | 
			
		||||
        exception_trigger((pred_copy_exception*) 0);
 | 
			
		||||
 | 
			
		||||
        return *this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool equals::calculate_equals(bool x) const
 | 
			
		||||
    {
 | 
			
		||||
        exception_trigger((pred_exception*) 0);
 | 
			
		||||
        return x;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool equals::operator()(char const* x, char const* y) const
 | 
			
		||||
    {
 | 
			
		||||
        return calculate_equals(std::string(x) == std::string(y));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool equals::operator==(equals const& x) const
 | 
			
		||||
    {
 | 
			
		||||
        return tag == x.tag;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    std::ostream& operator<<(std::ostream& out, equals x)
 | 
			
		||||
    {
 | 
			
		||||
        out<<"Test Equals("<<x.tag<<")\n";
 | 
			
		||||
        return out;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    equals create_key_equal(equals*)
 | 
			
		||||
    {
 | 
			
		||||
        return equals();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    equals create_key_equal(equals*, int x)
 | 
			
		||||
    {
 | 
			
		||||
        return equals(x);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    less::less(int x)
 | 
			
		||||
        : tag(x)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool less::operator()(char const* x, char const* y) const
 | 
			
		||||
    {
 | 
			
		||||
        return std::string(x) < std::string(y);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    std::ostream& operator<<(std::ostream& out, less x)
 | 
			
		||||
    {
 | 
			
		||||
        out<<"Test Less("<<x.tag<<")\n";
 | 
			
		||||
        return out;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,80 +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_FUNCTIONAL_HEADER)
 | 
			
		||||
#define BOOST_UNORDERED_TEST_HELPERS_FUNCTIONAL_HEADER
 | 
			
		||||
 | 
			
		||||
#include <iosfwd>
 | 
			
		||||
#include <boost/functional/hash.hpp>
 | 
			
		||||
 | 
			
		||||
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 <class T>
 | 
			
		||||
        std::size_t operator()(T const& x) const
 | 
			
		||||
        {
 | 
			
		||||
            return calculate_hash(boost::hash<T>()(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 <class T1, class T2>
 | 
			
		||||
        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 <class T1, class T2>
 | 
			
		||||
        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
 | 
			
		||||
@@ -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> 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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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 <cstdlib>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <utility>
 | 
			
		||||
 | 
			
		||||
namespace test
 | 
			
		||||
{
 | 
			
		||||
    int generate(int const*);
 | 
			
		||||
    char generate(char const*);
 | 
			
		||||
    std::string generate(std::string const*);
 | 
			
		||||
    template <class T1, class T2> std::pair<T1, T2> generate(
 | 
			
		||||
            std::pair<T1, T2>  const*);
 | 
			
		||||
 | 
			
		||||
    template <class T>
 | 
			
		||||
    struct generator
 | 
			
		||||
    {
 | 
			
		||||
        typedef T value_type;
 | 
			
		||||
        value_type operator()()
 | 
			
		||||
        {
 | 
			
		||||
            return generate((T  const*) 0);
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    template <class T1, class T2>
 | 
			
		||||
    std::pair<T1, T2> generate(std::pair<T1, T2>  const*)
 | 
			
		||||
    {
 | 
			
		||||
        static generator<T1> g1;
 | 
			
		||||
        static generator<T2> g2;
 | 
			
		||||
 | 
			
		||||
        return std::pair<T1, T2>(g1(), g2());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
@@ -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 <boost/iterator_adaptors.hpp>
 | 
			
		||||
 | 
			
		||||
namespace test
 | 
			
		||||
{
 | 
			
		||||
    template <class Iterator>
 | 
			
		||||
    struct input_iterator_adaptor
 | 
			
		||||
        : boost::iterator_adaptor<
 | 
			
		||||
            input_iterator_adaptor<Iterator>, Iterator,
 | 
			
		||||
            boost::use_default, std::input_iterator_tag>
 | 
			
		||||
    {
 | 
			
		||||
        typedef boost::iterator_adaptor<
 | 
			
		||||
            input_iterator_adaptor<Iterator>, Iterator,
 | 
			
		||||
            boost::use_default, std::input_iterator_tag> base;
 | 
			
		||||
 | 
			
		||||
        explicit input_iterator_adaptor(Iterator it = Iterator())
 | 
			
		||||
            : base(it) {}
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    template <class Iterator>
 | 
			
		||||
    input_iterator_adaptor<Iterator> make_input_iterator(Iterator it)
 | 
			
		||||
    {
 | 
			
		||||
        return input_iterator_adaptor<Iterator>(it);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@@ -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 <boost/config.hpp>
 | 
			
		||||
#include "./invariant_checker.hpp"
 | 
			
		||||
#include <set>
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <boost/functional.hpp>
 | 
			
		||||
 | 
			
		||||
namespace test
 | 
			
		||||
{
 | 
			
		||||
    namespace
 | 
			
		||||
    {
 | 
			
		||||
        typedef std::set<invariant_checker_base*> 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();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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 <boost/preprocessor/cat.hpp>
 | 
			
		||||
#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 <class T>
 | 
			
		||||
    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 <class T>
 | 
			
		||||
    invariant_checker<T> make_invariant_checker(T& o)
 | 
			
		||||
    {
 | 
			
		||||
        return invariant_checker<T>(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 <class T>
 | 
			
		||||
    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
 | 
			
		||||
@@ -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 <utility>
 | 
			
		||||
 | 
			
		||||
namespace test
 | 
			
		||||
{
 | 
			
		||||
    template <class T>
 | 
			
		||||
    bool compare_impl(T const& x, T const& y, float)
 | 
			
		||||
    {
 | 
			
		||||
        return x < y;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class T1, class T2>
 | 
			
		||||
    bool compare_impl(std::pair<T1, T2> const& x,
 | 
			
		||||
            std::pair<T1, T2> const& y, int)
 | 
			
		||||
    {
 | 
			
		||||
        return x.first < y.first ||
 | 
			
		||||
            (x.first == y.first && x.second < y.second);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    struct compare {
 | 
			
		||||
        template <class T>
 | 
			
		||||
        bool operator()(T const& x, T const& y)
 | 
			
		||||
        {
 | 
			
		||||
            return compare_impl(x, y, 0);
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@@ -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 <ostream>
 | 
			
		||||
#else
 | 
			
		||||
# include <ostream.h>
 | 
			
		||||
#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("<<x.value<<")";
 | 
			
		||||
        return out;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    test::member generate(test::member const*)
 | 
			
		||||
    {
 | 
			
		||||
        return test::member(test::generator<int>()());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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 <iosfwd>
 | 
			
		||||
#include <cstddef>
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
@@ -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 <boost/config.hpp>
 | 
			
		||||
#include <boost/mpl/eval_if.hpp>
 | 
			
		||||
#include <boost/mpl/identity.hpp>
 | 
			
		||||
#include <boost/unordered_set.hpp>
 | 
			
		||||
#include <boost/unordered_map.hpp>
 | 
			
		||||
 | 
			
		||||
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 <class V, class H, class P, class A>
 | 
			
		||||
    unordered_set_type container_type(
 | 
			
		||||
            boost::unordered_set<V, H, P, A> const*);
 | 
			
		||||
    template <class V, class H, class P, class A>
 | 
			
		||||
    unordered_multiset_type container_type(
 | 
			
		||||
            boost::unordered_multiset<V, H, P, A> const*);
 | 
			
		||||
    template <class K, class M, class H, class P, class A>
 | 
			
		||||
    unordered_map_type container_type(
 | 
			
		||||
            boost::unordered_map<K, M, H, P, A> const*);
 | 
			
		||||
    template <class K, class M, class H, class P, class A>
 | 
			
		||||
    unordered_multimap_type container_type(
 | 
			
		||||
            boost::unordered_multimap<K, M, H, P, A> const*);
 | 
			
		||||
 | 
			
		||||
    template <class Container>
 | 
			
		||||
    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 <class Container>
 | 
			
		||||
    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 <class Container>
 | 
			
		||||
    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 <class Container>
 | 
			
		||||
    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 <class Container>
 | 
			
		||||
    struct map_non_const_value_type
 | 
			
		||||
    {
 | 
			
		||||
        typedef std::pair<
 | 
			
		||||
            typename Container::key_type,
 | 
			
		||||
            typename Container::mapped_type> type;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    template <class Container>
 | 
			
		||||
    struct non_const_value_type
 | 
			
		||||
        : boost::mpl::eval_if<is_map<Container>,
 | 
			
		||||
            map_non_const_value_type<Container>,
 | 
			
		||||
            boost::mpl::identity<typename Container::value_type> >
 | 
			
		||||
    {
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@@ -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 <vector>
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <iterator>
 | 
			
		||||
 | 
			
		||||
namespace test
 | 
			
		||||
{
 | 
			
		||||
    template <class Container>
 | 
			
		||||
    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 <class K, class M>
 | 
			
		||||
        static typename Container::key_type const&
 | 
			
		||||
            get_key(std::pair<K, M> const& x)
 | 
			
		||||
        {
 | 
			
		||||
            return x.first;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static typename Container::value_type const& 
 | 
			
		||||
            get_mapped(typename Container::key_type const& x)
 | 
			
		||||
        {
 | 
			
		||||
            return x;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        template <class K, class M>
 | 
			
		||||
        static M const&
 | 
			
		||||
            get_mapped(std::pair<K, M> const& x)
 | 
			
		||||
        {
 | 
			
		||||
            return x.second;
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    template <class Container>
 | 
			
		||||
    struct random_values : public accessors<Container>
 | 
			
		||||
    {
 | 
			
		||||
        typedef accessors<Container> base;
 | 
			
		||||
 | 
			
		||||
        typedef typename non_const_value_type<Container>::type value_type;
 | 
			
		||||
        typedef typename Container::key_type key_type;
 | 
			
		||||
 | 
			
		||||
        std::vector<value_type> values_;
 | 
			
		||||
        typedef typename std::vector<value_type>::iterator iterator;
 | 
			
		||||
        typedef typename std::vector<value_type>::const_iterator const_iterator;
 | 
			
		||||
 | 
			
		||||
        explicit random_values(std::size_t count)
 | 
			
		||||
        {
 | 
			
		||||
            values_.reserve(count);
 | 
			
		||||
            std::generate_n(std::back_inserter(values_),
 | 
			
		||||
                    count, test::generator<value_type>());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        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 <class X, class Y>
 | 
			
		||||
            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 <class M>
 | 
			
		||||
            bool operator()(std::pair<key_type, M> 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 <class M>
 | 
			
		||||
        static key_matcher1 key_match(std::pair<key_type, M> const& x)
 | 
			
		||||
        {
 | 
			
		||||
            return key_matcher1(x.first);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        template <class K>
 | 
			
		||||
        iterator find(K const& x)
 | 
			
		||||
        {
 | 
			
		||||
            return std::find_if(values_.begin(), values_.end(), key_match(x));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        template <class K>
 | 
			
		||||
        std::size_t count(K const& x)
 | 
			
		||||
        {
 | 
			
		||||
            return std::count_if(values_.begin(), values_.end(),
 | 
			
		||||
                    key_match(x));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        template <class K>
 | 
			
		||||
        std::size_t key_count(K const& x)
 | 
			
		||||
        {
 | 
			
		||||
            if(has_unique_keys<Container>::value)
 | 
			
		||||
                return find(x) != values_.end();
 | 
			
		||||
            else
 | 
			
		||||
                return count(x);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static bool is_unique()
 | 
			
		||||
        {
 | 
			
		||||
            return has_unique_keys<Container>::value;
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    template <class Container>
 | 
			
		||||
    struct sorted_random_values : public random_values<Container>
 | 
			
		||||
    {
 | 
			
		||||
        typedef random_values<Container> 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 <class X, class Y>
 | 
			
		||||
            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 <class K>
 | 
			
		||||
        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 <class K>
 | 
			
		||||
        std::size_t count(K const& x)
 | 
			
		||||
        {
 | 
			
		||||
            std::pair<iterator, iterator> range =
 | 
			
		||||
                std::equal_range(this->begin(), this->end(), x, key_compare());
 | 
			
		||||
            return range.second - range.first;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        template <class K>
 | 
			
		||||
        std::size_t key_count(K const& x)
 | 
			
		||||
        {
 | 
			
		||||
            if(has_unique_keys<Container>::value)
 | 
			
		||||
                return find(x) != this->end();
 | 
			
		||||
            else
 | 
			
		||||
                return count(x);
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
@@ -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 <boost/test/test_tools.hpp>
 | 
			
		||||
 | 
			
		||||
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(); }
 | 
			
		||||
}
 | 
			
		||||
@@ -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 <boost/shared_ptr.hpp>
 | 
			
		||||
#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 T>
 | 
			
		||||
    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> strong_tester_ptr;
 | 
			
		||||
 | 
			
		||||
    //template <class T>
 | 
			
		||||
    //strong_tester_ptr create_tester_impl(T const& x, float)
 | 
			
		||||
    //{
 | 
			
		||||
    //    return strong_tester_ptr(new default_strong_tester<T>(x));
 | 
			
		||||
    //}
 | 
			
		||||
 | 
			
		||||
    template <class T>
 | 
			
		||||
    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
 | 
			
		||||
@@ -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 <boost/preprocessor/cat.hpp>
 | 
			
		||||
#include <boost/preprocessor/seq/for_each.hpp>
 | 
			
		||||
#include <boost/preprocessor/seq/cat.hpp>
 | 
			
		||||
#include <boost/preprocessor/seq/elem.hpp>
 | 
			
		||||
#include <boost/preprocessor/seq/for_each_product.hpp>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#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 <class T> \
 | 
			
		||||
    void impl_name(); \
 | 
			
		||||
    BOOST_PP_SEQ_FOR_EACH(AUTO_TEMPLATE_TEST_OP, name, type_seq) \
 | 
			
		||||
    template <class T> \
 | 
			
		||||
    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)<type> ) );
 | 
			
		||||
 | 
			
		||||
#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 <class T> \
 | 
			
		||||
    void impl_name(T* = 0); \
 | 
			
		||||
    template <class T> \
 | 
			
		||||
    void name(T* x = 0) { \
 | 
			
		||||
        impl_name(x); \
 | 
			
		||||
        ::test::end(); \
 | 
			
		||||
    } \
 | 
			
		||||
    template <class T> \
 | 
			
		||||
    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
 | 
			
		||||
		Reference in New Issue
	
	Block a user