Seed the random number generator in tests.

[SVN r41782]
This commit is contained in:
Daniel James
2007-12-06 11:42:28 +00:00
parent 322f7d6ec6
commit 6e8f9e1c67
18 changed files with 41 additions and 2 deletions

View File

@@ -11,6 +11,8 @@
#include "../helpers/random_values.hpp" #include "../helpers/random_values.hpp"
#include "../helpers/invariants.hpp" #include "../helpers/invariants.hpp"
test::seed_t seed(12847);
template <class T> template <class T>
struct self_assign_base : public test::exception_base struct self_assign_base : public test::exception_base
{ {

View File

@@ -11,6 +11,8 @@
#include "../helpers/random_values.hpp" #include "../helpers/random_values.hpp"
#include "../helpers/input_iterator.hpp" #include "../helpers/input_iterator.hpp"
test::seed_t seed(91274);
struct objects struct objects
{ {
test::exception::object obj; test::exception::object obj;

View File

@@ -10,6 +10,8 @@
#include <boost/test/exception_safety.hpp> #include <boost/test/exception_safety.hpp>
#include "../helpers/random_values.hpp" #include "../helpers/random_values.hpp"
test::seed_t seed(73041);
template <class T> template <class T>
struct copy_test1 : public test::exception_base struct copy_test1 : public test::exception_base
{ {

View File

@@ -12,6 +12,8 @@
#include "../helpers/invariants.hpp" #include "../helpers/invariants.hpp"
#include "../helpers/helpers.hpp" #include "../helpers/helpers.hpp"
test::seed_t seed(835193);
template <class T> template <class T>
struct erase_test_base : public test::exception_base struct erase_test_base : public test::exception_base
{ {

View File

@@ -16,6 +16,8 @@
#include <cmath> #include <cmath>
test::seed_t seed(747373);
template <class T> template <class T>
struct insert_test_base : public test::exception_base struct insert_test_base : public test::exception_base
{ {

View File

@@ -15,6 +15,8 @@
#include <iostream> #include <iostream>
test::seed_t seed(3298597);
template <class T> template <class T>
struct rehash_test_base : public test::exception_base struct rehash_test_base : public test::exception_base
{ {

View File

@@ -11,6 +11,8 @@
#include "../helpers/random_values.hpp" #include "../helpers/random_values.hpp"
#include "../helpers/invariants.hpp" #include "../helpers/invariants.hpp"
test::seed_t seed(9387);
template <class T> template <class T>
struct self_swap_base : public test::exception_base struct self_swap_base : public test::exception_base
{ {

View File

@@ -7,8 +7,6 @@
// Which is not good as different platforms will be running different tests. // Which is not good as different platforms will be running different tests.
// It would be much better to use Boost.Random, but it doesn't // It would be much better to use Boost.Random, but it doesn't
// support all the compilers that I want to test on. // support all the compilers that I want to test on.
// TODO: seed the random generator.
// TODO: check that this is actually working...
#if !defined(BOOST_UNORDERED_TEST_HELPERS_GENERATORS_HEADER) #if !defined(BOOST_UNORDERED_TEST_HELPERS_GENERATORS_HEADER)
#define BOOST_UNORDERED_TEST_HELPERS_GENERATORS_HEADER #define BOOST_UNORDERED_TEST_HELPERS_GENERATORS_HEADER
@@ -22,6 +20,13 @@
namespace test namespace test
{ {
struct seed_t {
seed_t(unsigned int x) {
using namespace std;
srand(x);
}
};
template <class T> template <class T>
struct generator; struct generator;

View File

@@ -13,6 +13,8 @@
#include <iostream> #include <iostream>
test::seed_t seed(96785);
template <class T> template <class T>
void assign_tests1(T* = 0) void assign_tests1(T* = 0)
{ {

View File

@@ -11,6 +11,8 @@
#include "../helpers/random_values.hpp" #include "../helpers/random_values.hpp"
#include "../helpers/helpers.hpp" #include "../helpers/helpers.hpp"
test::seed_t seed(54635);
template <class X> template <class X>
void bucket_tests(X* = 0) void bucket_tests(X* = 0)
{ {

View File

@@ -15,6 +15,8 @@
#include <iostream> #include <iostream>
test::seed_t seed(356730);
template <class T> template <class T>
void constructor_tests1(T* = 0) void constructor_tests1(T* = 0)
{ {

View File

@@ -12,6 +12,8 @@
#include "../helpers/equivalent.hpp" #include "../helpers/equivalent.hpp"
#include "../helpers/invariants.hpp" #include "../helpers/invariants.hpp"
test::seed_t seed(9063);
template <class T> template <class T>
void copy_construct_tests1(T* = 0) void copy_construct_tests1(T* = 0)
{ {

View File

@@ -15,6 +15,8 @@
#include <iostream> #include <iostream>
test::seed_t seed(85638);
template <class Container> template <class Container>
void erase_tests1(Container* = 0) void erase_tests1(Container* = 0)
{ {

View File

@@ -11,6 +11,8 @@
#include "../helpers/tracker.hpp" #include "../helpers/tracker.hpp"
#include "../helpers/helpers.hpp" #include "../helpers/helpers.hpp"
test::seed_t seed(78937);
template <class X> template <class X>
void find_tests1(X*) void find_tests1(X*)
{ {

View File

@@ -16,6 +16,8 @@
#include <iostream> #include <iostream>
test::seed_t seed(243432);
template <class X> template <class X>
void unique_insert_tests1(X* = 0) void unique_insert_tests1(X* = 0)
{ {

View File

@@ -14,6 +14,8 @@
#pragma warning(disable:4127) // conditional expression is constant #pragma warning(disable:4127) // conditional expression is constant
#endif #endif
test::seed_t seed(783656);
template <class X> template <class X>
void load_factor_tests(X* = 0) void load_factor_tests(X* = 0)
{ {

View File

@@ -9,6 +9,8 @@
#include "../helpers/random_values.hpp" #include "../helpers/random_values.hpp"
#include "../helpers/tracker.hpp" #include "../helpers/tracker.hpp"
test::seed_t seed(2974);
template <class X> template <class X>
bool postcondition(X const& x, typename X::size_type n) bool postcondition(X const& x, typename X::size_type n)
{ {

View File

@@ -14,6 +14,8 @@
#include "../helpers/tracker.hpp" #include "../helpers/tracker.hpp"
#include "../helpers/invariants.hpp" #include "../helpers/invariants.hpp"
test::seed_t seed(783472);
template <class X> template <class X>
void swap_test_impl(X& x1, X& x2) void swap_test_impl(X& x1, X& x2)
{ {