BIND 10 trac2850_3, updated. 5f830557d25aba7e55c03350707f81219f74778d Revert "[2850] Add a way to pass a seed to the random number generator"

BIND 10 source code commits bind10-changes at lists.isc.org
Thu May 16 13:57:02 UTC 2013


The branch, trac2850_3 has been updated
       via  5f830557d25aba7e55c03350707f81219f74778d (commit)
      from  0d8512ac4efe7293ee5239d7202965971011be8d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5f830557d25aba7e55c03350707f81219f74778d
Author: Mukund Sivaraman <muks at isc.org>
Date:   Thu May 16 19:18:40 2013 +0530

    Revert "[2850] Add a way to pass a seed to the random number generator"
    
    This reverts commit 3599c07417b1bcf40ae8e59959278b4a59ede827.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/util/random/random_number_generator.h      |    9 ++-------
 .../util/tests/random_number_generator_unittest.cc |   18 ------------------
 2 files changed, 2 insertions(+), 25 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/util/random/random_number_generator.h b/src/lib/util/random/random_number_generator.h
index 3f2a907..c765835 100644
--- a/src/lib/util/random/random_number_generator.h
+++ b/src/lib/util/random/random_number_generator.h
@@ -60,9 +60,7 @@ public:
     ///
     /// \param min The minimum number in the range
     /// \param max The maximum number in the range
-    /// \param seed A seed for the RNG. If 0 is passed, the current time
-    /// is used.
-    UniformRandomIntegerGenerator(int min, int max, unsigned int seed = 0):
+    UniformRandomIntegerGenerator(int min, int max):
         min_(std::min(min, max)), max_(std::max(min, max)),
         dist_(min_, max_), generator_(rng_, dist_)
     {
@@ -75,10 +73,7 @@ public:
         }
 
         // Init with the current time
-        if (seed == 0) {
-            seed = time(NULL);
-        }
-        rng_.seed(seed);
+        rng_.seed(time(NULL));
     }
 
     /// \brief Generate uniformly distributed integer
diff --git a/src/lib/util/tests/random_number_generator_unittest.cc b/src/lib/util/tests/random_number_generator_unittest.cc
index 2c6bec8..639d354 100644
--- a/src/lib/util/tests/random_number_generator_unittest.cc
+++ b/src/lib/util/tests/random_number_generator_unittest.cc
@@ -20,10 +20,7 @@
 #include <boost/shared_ptr.hpp>
 
 #include <iostream>
-#include <climits>
 
-#include <sys/types.h>
-#include <unistd.h>
 
 namespace isc {
 namespace util {
@@ -87,21 +84,6 @@ TEST_F(UniformRandomIntegerGeneratorTest, IntegerRange) {
     ASSERT_EQ(it - numbers.begin(), max() - min() + 1);
 }
 
-TEST_F(UniformRandomIntegerGeneratorTest, withSeed) {
-    // Test that two generators with the same seed return the same
-    // sequence.
-    UniformRandomIntegerGenerator gen1(0, INT_MAX, getpid());
-    vector<int> numbers;
-    for (int i = 0; i < 1024; ++i) {
-        numbers.push_back(gen1());
-    }
-
-    UniformRandomIntegerGenerator gen2(0, INT_MAX, getpid());
-    for (int i = 0; i < 1024; ++i) {
-        EXPECT_EQ(numbers[i], gen2());
-    }
-}
-
 /// \brief Test Fixture Class for weighted random number generator
 class WeightedRandomIntegerGeneratorTest : public ::testing::Test {
 public:



More information about the bind10-changes mailing list