mirror of
https://github.com/boostorg/unordered.git
synced 2025-05-10 07:34:00 +00:00
https://svn.boost.org/svn/boost/branches/unordered/trunk ........ r43840 | danieljames | 2008-03-24 17:25:07 +0000 (Mon, 24 Mar 2008) | 1 line Fix a g++ warning. ........ r43844 | danieljames | 2008-03-24 17:56:28 +0000 (Mon, 24 Mar 2008) | 1 line It's a new-ish year. ........ r43885 | danieljames | 2008-03-27 20:36:10 +0000 (Thu, 27 Mar 2008) | 1 line The release script doesn't need to copy images and css - because that's now done in the jamfiles. Also tweak the shell script a tad bit. ........ r43890 | danieljames | 2008-03-27 23:01:40 +0000 (Thu, 27 Mar 2008) | 1 line Starting to add a docbook bibliography. ........ r43894 | danieljames | 2008-03-27 23:24:18 +0000 (Thu, 27 Mar 2008) | 1 line Redeclare 'data' in iterator_base to help compilers which have trouble with accessing the nested typedef. ........ [SVN r43895]
82 lines
2.0 KiB
C++
82 lines
2.0 KiB
C++
|
|
// Copyright 2006-2008 Daniel James.
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
#include "./containers.hpp"
|
|
#include <string>
|
|
#include "../helpers/random_values.hpp"
|
|
#include "../helpers/invariants.hpp"
|
|
#include "../helpers/strong.hpp"
|
|
|
|
#include <iostream>
|
|
|
|
test::seed_t seed(3298597);
|
|
|
|
template <class T>
|
|
struct rehash_test_base : public test::exception_base
|
|
{
|
|
test::random_values<T> values;
|
|
unsigned int n;
|
|
rehash_test_base(unsigned int count = 100, unsigned int n = 0) : values(count), n(n) {}
|
|
|
|
typedef T data_type;
|
|
typedef test::strong<T> strong_type;
|
|
|
|
data_type init() const {
|
|
T x(values.begin(), values.end(), n);
|
|
return x;
|
|
}
|
|
|
|
void check(T const& x, strong_type const& strong) const {
|
|
std::string scope(test::scope);
|
|
|
|
if(scope.find("hash::operator()") == std::string::npos &&
|
|
scope.find("equal_to::operator()") == std::string::npos &&
|
|
scope != "operator==(object, object)")
|
|
strong.test(x);
|
|
|
|
test::check_equivalent_keys(x);
|
|
}
|
|
};
|
|
|
|
template <class T>
|
|
struct rehash_test0 : rehash_test_base<T>
|
|
{
|
|
rehash_test0() : rehash_test_base<T>(0) {}
|
|
void run(T& x) const { x.rehash(0); }
|
|
};
|
|
|
|
template <class T>
|
|
struct rehash_test1 : rehash_test_base<T>
|
|
{
|
|
rehash_test1() : rehash_test_base<T>(0) {}
|
|
void run(T& x) const { x.rehash(200); }
|
|
};
|
|
|
|
template <class T>
|
|
struct rehash_test2 : rehash_test_base<T>
|
|
{
|
|
rehash_test2() : rehash_test_base<T>(0, 200) {}
|
|
void run(T& x) const { x.rehash(0); }
|
|
};
|
|
|
|
template <class T>
|
|
struct rehash_test3 : rehash_test_base<T>
|
|
{
|
|
rehash_test3() : rehash_test_base<T>(10, 0) {}
|
|
void run(T& x) const { x.rehash(200); }
|
|
};
|
|
|
|
template <class T>
|
|
struct rehash_test4 : rehash_test_base<T>
|
|
{
|
|
rehash_test4() : rehash_test_base<T>(10, 200) {}
|
|
void run(T& x) const { x.rehash(0); }
|
|
};
|
|
|
|
RUN_EXCEPTION_TESTS(
|
|
(rehash_test0)(rehash_test1)(rehash_test2)(rehash_test3)(rehash_test4),
|
|
CONTAINER_SEQ)
|
|
|