Boost logo

Boost-Commit :

From: daniel_james_at_[hidden]
Date: 2007-12-06 06:42:29


Author: danieljames
Date: 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
New Revision: 41782
URL: http://svn.boost.org/trac/boost/changeset/41782

Log:
Seed the random number generator in tests.
Text files modified:
   sandbox/unordered/libs/unordered/test/exception/assign_tests.cpp | 2 ++
   sandbox/unordered/libs/unordered/test/exception/constructor_tests.cpp | 2 ++
   sandbox/unordered/libs/unordered/test/exception/copy_tests.cpp | 2 ++
   sandbox/unordered/libs/unordered/test/exception/erase_tests.cpp | 2 ++
   sandbox/unordered/libs/unordered/test/exception/insert_tests.cpp | 2 ++
   sandbox/unordered/libs/unordered/test/exception/rehash_tests.cpp | 2 ++
   sandbox/unordered/libs/unordered/test/exception/swap_tests.cpp | 2 ++
   sandbox/unordered/libs/unordered/test/helpers/generators.hpp | 9 +++++++--
   sandbox/unordered/libs/unordered/test/unordered/assign_tests.cpp | 2 ++
   sandbox/unordered/libs/unordered/test/unordered/bucket_tests.cpp | 2 ++
   sandbox/unordered/libs/unordered/test/unordered/constructor_tests.cpp | 2 ++
   sandbox/unordered/libs/unordered/test/unordered/copy_tests.cpp | 2 ++
   sandbox/unordered/libs/unordered/test/unordered/erase_tests.cpp | 2 ++
   sandbox/unordered/libs/unordered/test/unordered/find_tests.cpp | 2 ++
   sandbox/unordered/libs/unordered/test/unordered/insert_tests.cpp | 2 ++
   sandbox/unordered/libs/unordered/test/unordered/load_factor_tests.cpp | 2 ++
   sandbox/unordered/libs/unordered/test/unordered/rehash_tests.cpp | 2 ++
   sandbox/unordered/libs/unordered/test/unordered/swap_tests.cpp | 2 ++
   18 files changed, 41 insertions(+), 2 deletions(-)

Modified: sandbox/unordered/libs/unordered/test/exception/assign_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/exception/assign_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/exception/assign_tests.cpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -11,6 +11,8 @@
 #include "../helpers/random_values.hpp"
 #include "../helpers/invariants.hpp"
 
+test::seed_t seed(12847);
+
 template <class T>
 struct self_assign_base : public test::exception_base
 {

Modified: sandbox/unordered/libs/unordered/test/exception/constructor_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/exception/constructor_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/exception/constructor_tests.cpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -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;

Modified: sandbox/unordered/libs/unordered/test/exception/copy_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/exception/copy_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/exception/copy_tests.cpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -10,6 +10,8 @@
 #include <boost/test/exception_safety.hpp>
 #include "../helpers/random_values.hpp"
 
+test::seed_t seed(73041);
+
 template <class T>
 struct copy_test1 : public test::exception_base
 {

Modified: sandbox/unordered/libs/unordered/test/exception/erase_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/exception/erase_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/exception/erase_tests.cpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -12,6 +12,8 @@
 #include "../helpers/invariants.hpp"
 #include "../helpers/helpers.hpp"
 
+test::seed_t seed(835193);
+
 template <class T>
 struct erase_test_base : public test::exception_base
 {

Modified: sandbox/unordered/libs/unordered/test/exception/insert_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/exception/insert_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/exception/insert_tests.cpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -16,6 +16,8 @@
 
 #include <cmath>
 
+test::seed_t seed(747373);
+
 template <class T>
 struct insert_test_base : public test::exception_base
 {

Modified: sandbox/unordered/libs/unordered/test/exception/rehash_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/exception/rehash_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/exception/rehash_tests.cpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -15,6 +15,8 @@
 
 #include <iostream>
 
+test::seed_t seed(3298597);
+
 template <class T>
 struct rehash_test_base : public test::exception_base
 {

Modified: sandbox/unordered/libs/unordered/test/exception/swap_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/exception/swap_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/exception/swap_tests.cpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -11,6 +11,8 @@
 #include "../helpers/random_values.hpp"
 #include "../helpers/invariants.hpp"
 
+test::seed_t seed(9387);
+
 template <class T>
 struct self_swap_base : public test::exception_base
 {

Modified: sandbox/unordered/libs/unordered/test/helpers/generators.hpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/helpers/generators.hpp (original)
+++ sandbox/unordered/libs/unordered/test/helpers/generators.hpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -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 <class T>
     struct generator;
 

Modified: sandbox/unordered/libs/unordered/test/unordered/assign_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/unordered/assign_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/unordered/assign_tests.cpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -13,6 +13,8 @@
 
 #include <iostream>
 
+test::seed_t seed(96785);
+
 template <class T>
 void assign_tests1(T* = 0)
 {

Modified: sandbox/unordered/libs/unordered/test/unordered/bucket_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/unordered/bucket_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/unordered/bucket_tests.cpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -11,6 +11,8 @@
 #include "../helpers/random_values.hpp"
 #include "../helpers/helpers.hpp"
 
+test::seed_t seed(54635);
+
 template <class X>
 void bucket_tests(X* = 0)
 {

Modified: sandbox/unordered/libs/unordered/test/unordered/constructor_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/unordered/constructor_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/unordered/constructor_tests.cpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -15,6 +15,8 @@
 
 #include <iostream>
 
+test::seed_t seed(356730);
+
 template <class T>
 void constructor_tests1(T* = 0)
 {

Modified: sandbox/unordered/libs/unordered/test/unordered/copy_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/unordered/copy_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/unordered/copy_tests.cpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -12,6 +12,8 @@
 #include "../helpers/equivalent.hpp"
 #include "../helpers/invariants.hpp"
 
+test::seed_t seed(9063);
+
 template <class T>
 void copy_construct_tests1(T* = 0)
 {

Modified: sandbox/unordered/libs/unordered/test/unordered/erase_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/unordered/erase_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/unordered/erase_tests.cpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -15,6 +15,8 @@
 
 #include <iostream>
 
+test::seed_t seed(85638);
+
 template <class Container>
 void erase_tests1(Container* = 0)
 {

Modified: sandbox/unordered/libs/unordered/test/unordered/find_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/unordered/find_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/unordered/find_tests.cpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -11,6 +11,8 @@
 #include "../helpers/tracker.hpp"
 #include "../helpers/helpers.hpp"
 
+test::seed_t seed(78937);
+
 template <class X>
 void find_tests1(X*)
 {

Modified: sandbox/unordered/libs/unordered/test/unordered/insert_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/unordered/insert_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/unordered/insert_tests.cpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -16,6 +16,8 @@
 
 #include <iostream>
     
+test::seed_t seed(243432);
+
 template <class X>
 void unique_insert_tests1(X* = 0)
 {

Modified: sandbox/unordered/libs/unordered/test/unordered/load_factor_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/unordered/load_factor_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/unordered/load_factor_tests.cpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -14,6 +14,8 @@
 #pragma warning(disable:4127) // conditional expression is constant
 #endif
 
+test::seed_t seed(783656);
+
 template <class X>
 void load_factor_tests(X* = 0)
 {

Modified: sandbox/unordered/libs/unordered/test/unordered/rehash_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/unordered/rehash_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/unordered/rehash_tests.cpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -9,6 +9,8 @@
 #include "../helpers/random_values.hpp"
 #include "../helpers/tracker.hpp"
 
+test::seed_t seed(2974);
+
 template <class X>
 bool postcondition(X const& x, typename X::size_type n)
 {

Modified: sandbox/unordered/libs/unordered/test/unordered/swap_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/unordered/swap_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/unordered/swap_tests.cpp 2007-12-06 06:42:28 EST (Thu, 06 Dec 2007)
@@ -14,6 +14,8 @@
 #include "../helpers/tracker.hpp"
 #include "../helpers/invariants.hpp"
 
+test::seed_t seed(783472);
+
 template <class X>
 void swap_test_impl(X& x1, X& x2)
 {


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk