From 6e8f9e1c6781cab68d99a2da696d042842d3bec8 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 6 Dec 2007 11:42:28 +0000 Subject: [PATCH] Seed the random number generator in tests. [SVN r41782] --- test/exception/assign_tests.cpp | 2 ++ test/exception/constructor_tests.cpp | 2 ++ test/exception/copy_tests.cpp | 2 ++ test/exception/erase_tests.cpp | 2 ++ test/exception/insert_tests.cpp | 2 ++ test/exception/rehash_tests.cpp | 2 ++ test/exception/swap_tests.cpp | 2 ++ test/helpers/generators.hpp | 9 +++++++-- test/unordered/assign_tests.cpp | 2 ++ test/unordered/bucket_tests.cpp | 2 ++ test/unordered/constructor_tests.cpp | 2 ++ test/unordered/copy_tests.cpp | 2 ++ test/unordered/erase_tests.cpp | 2 ++ test/unordered/find_tests.cpp | 2 ++ test/unordered/insert_tests.cpp | 2 ++ test/unordered/load_factor_tests.cpp | 2 ++ test/unordered/rehash_tests.cpp | 2 ++ test/unordered/swap_tests.cpp | 2 ++ 18 files changed, 41 insertions(+), 2 deletions(-) diff --git a/test/exception/assign_tests.cpp b/test/exception/assign_tests.cpp index bacac5a8..dfff9727 100644 --- a/test/exception/assign_tests.cpp +++ b/test/exception/assign_tests.cpp @@ -11,6 +11,8 @@ #include "../helpers/random_values.hpp" #include "../helpers/invariants.hpp" +test::seed_t seed(12847); + template struct self_assign_base : public test::exception_base { diff --git a/test/exception/constructor_tests.cpp b/test/exception/constructor_tests.cpp index 0581161b..d822e315 100644 --- a/test/exception/constructor_tests.cpp +++ b/test/exception/constructor_tests.cpp @@ -11,6 +11,8 @@ #include "../helpers/random_values.hpp" #include "../helpers/input_iterator.hpp" +test::seed_t seed(91274); + struct objects { test::exception::object obj; diff --git a/test/exception/copy_tests.cpp b/test/exception/copy_tests.cpp index b4bc3412..53a66514 100644 --- a/test/exception/copy_tests.cpp +++ b/test/exception/copy_tests.cpp @@ -10,6 +10,8 @@ #include #include "../helpers/random_values.hpp" +test::seed_t seed(73041); + template struct copy_test1 : public test::exception_base { diff --git a/test/exception/erase_tests.cpp b/test/exception/erase_tests.cpp index 318a0262..240e98b0 100644 --- a/test/exception/erase_tests.cpp +++ b/test/exception/erase_tests.cpp @@ -12,6 +12,8 @@ #include "../helpers/invariants.hpp" #include "../helpers/helpers.hpp" +test::seed_t seed(835193); + template struct erase_test_base : public test::exception_base { diff --git a/test/exception/insert_tests.cpp b/test/exception/insert_tests.cpp index e0375521..be498a70 100644 --- a/test/exception/insert_tests.cpp +++ b/test/exception/insert_tests.cpp @@ -16,6 +16,8 @@ #include +test::seed_t seed(747373); + template struct insert_test_base : public test::exception_base { diff --git a/test/exception/rehash_tests.cpp b/test/exception/rehash_tests.cpp index 5fac9b9f..1178f4ef 100644 --- a/test/exception/rehash_tests.cpp +++ b/test/exception/rehash_tests.cpp @@ -15,6 +15,8 @@ #include +test::seed_t seed(3298597); + template struct rehash_test_base : public test::exception_base { diff --git a/test/exception/swap_tests.cpp b/test/exception/swap_tests.cpp index 248260ab..2812e007 100644 --- a/test/exception/swap_tests.cpp +++ b/test/exception/swap_tests.cpp @@ -11,6 +11,8 @@ #include "../helpers/random_values.hpp" #include "../helpers/invariants.hpp" +test::seed_t seed(9387); + template struct self_swap_base : public test::exception_base { diff --git a/test/helpers/generators.hpp b/test/helpers/generators.hpp index 792b240e..4322d5be 100644 --- a/test/helpers/generators.hpp +++ b/test/helpers/generators.hpp @@ -7,8 +7,6 @@ // 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 // 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) #define BOOST_UNORDERED_TEST_HELPERS_GENERATORS_HEADER @@ -22,6 +20,13 @@ namespace test { + struct seed_t { + seed_t(unsigned int x) { + using namespace std; + srand(x); + } + }; + template struct generator; diff --git a/test/unordered/assign_tests.cpp b/test/unordered/assign_tests.cpp index 36e75936..5b5f0d85 100644 --- a/test/unordered/assign_tests.cpp +++ b/test/unordered/assign_tests.cpp @@ -13,6 +13,8 @@ #include +test::seed_t seed(96785); + template void assign_tests1(T* = 0) { diff --git a/test/unordered/bucket_tests.cpp b/test/unordered/bucket_tests.cpp index 84013f63..ff819f4f 100644 --- a/test/unordered/bucket_tests.cpp +++ b/test/unordered/bucket_tests.cpp @@ -11,6 +11,8 @@ #include "../helpers/random_values.hpp" #include "../helpers/helpers.hpp" +test::seed_t seed(54635); + template void bucket_tests(X* = 0) { diff --git a/test/unordered/constructor_tests.cpp b/test/unordered/constructor_tests.cpp index 36f15bef..f2109410 100644 --- a/test/unordered/constructor_tests.cpp +++ b/test/unordered/constructor_tests.cpp @@ -15,6 +15,8 @@ #include +test::seed_t seed(356730); + template void constructor_tests1(T* = 0) { diff --git a/test/unordered/copy_tests.cpp b/test/unordered/copy_tests.cpp index 7cc46b72..5dde9782 100644 --- a/test/unordered/copy_tests.cpp +++ b/test/unordered/copy_tests.cpp @@ -12,6 +12,8 @@ #include "../helpers/equivalent.hpp" #include "../helpers/invariants.hpp" +test::seed_t seed(9063); + template void copy_construct_tests1(T* = 0) { diff --git a/test/unordered/erase_tests.cpp b/test/unordered/erase_tests.cpp index 449ac392..bea51013 100644 --- a/test/unordered/erase_tests.cpp +++ b/test/unordered/erase_tests.cpp @@ -15,6 +15,8 @@ #include +test::seed_t seed(85638); + template void erase_tests1(Container* = 0) { diff --git a/test/unordered/find_tests.cpp b/test/unordered/find_tests.cpp index b551f509..a402df91 100644 --- a/test/unordered/find_tests.cpp +++ b/test/unordered/find_tests.cpp @@ -11,6 +11,8 @@ #include "../helpers/tracker.hpp" #include "../helpers/helpers.hpp" +test::seed_t seed(78937); + template void find_tests1(X*) { diff --git a/test/unordered/insert_tests.cpp b/test/unordered/insert_tests.cpp index 9bdc2218..06606d5e 100644 --- a/test/unordered/insert_tests.cpp +++ b/test/unordered/insert_tests.cpp @@ -16,6 +16,8 @@ #include +test::seed_t seed(243432); + template void unique_insert_tests1(X* = 0) { diff --git a/test/unordered/load_factor_tests.cpp b/test/unordered/load_factor_tests.cpp index 97687892..93a078ec 100644 --- a/test/unordered/load_factor_tests.cpp +++ b/test/unordered/load_factor_tests.cpp @@ -14,6 +14,8 @@ #pragma warning(disable:4127) // conditional expression is constant #endif +test::seed_t seed(783656); + template void load_factor_tests(X* = 0) { diff --git a/test/unordered/rehash_tests.cpp b/test/unordered/rehash_tests.cpp index 398c316c..b364ffa2 100644 --- a/test/unordered/rehash_tests.cpp +++ b/test/unordered/rehash_tests.cpp @@ -9,6 +9,8 @@ #include "../helpers/random_values.hpp" #include "../helpers/tracker.hpp" +test::seed_t seed(2974); + template bool postcondition(X const& x, typename X::size_type n) { diff --git a/test/unordered/swap_tests.cpp b/test/unordered/swap_tests.cpp index c58c87ac..d62c6e54 100644 --- a/test/unordered/swap_tests.cpp +++ b/test/unordered/swap_tests.cpp @@ -14,6 +14,8 @@ #include "../helpers/tracker.hpp" #include "../helpers/invariants.hpp" +test::seed_t seed(783472); + template void swap_test_impl(X& x1, X& x2) {