Add test proving max_load() invariants (#156)

This commit is contained in:
Christian Mazakas authored and GitHub committed 2022-11-01 17:05:18 +01:00
1 parent 13e065466a
commit 189e551dc7
4 files changed
+92 -1

No files matched your search

+2 -1
View File
@@ -12,7 +12,8 @@ namespace test {
typedef enum {
default_generator,
generate_collisions,
limited_range
limited_range,
sequential
} random_generator;
int generate(int const*, random_generator);
+12
View File
@@ -12,7 +12,9 @@
#define BOOST_UNORDERED_TEST_HELPERS_GENERATORS_HEADER
#include "./fwd.hpp"
#include <boost/assert.hpp>
#include <boost/type_traits/add_const.hpp>
#include <climits>
#include <cstdlib>
#include <stdexcept>
#include <string>
@@ -34,8 +36,18 @@ namespace test {
return static_cast<std::size_t>(rand()) % max;
}
static int origin = 0;
void reset_sequence() { origin = 0; }
inline int generate(int const*, random_generator g)
{
if (g == sequential) {
BOOST_ASSERT(
g + 1 < INT_MAX && "test::reset_sequence() should be invoked");
return origin++;
}
using namespace std;
int value = rand();
if (g == limited_range) {