summaryrefslogtreecommitdiff
path: root/absl/random/uniform_real_distribution_test.cc
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@google.com>2020-09-25 17:10:06 -0400
committerGravatar Benjamin Barenblat <bbaren@google.com>2020-09-25 17:10:06 -0400
commit4e1c98fe594d99494ce26e94a77f0358705f227c (patch)
treea07e9daefa3b5acf716ce89fa1a1c9b500fde795 /absl/random/uniform_real_distribution_test.cc
parent7a1e14d0d29736ba9c2884d0ce81fc0af92f6ab3 (diff)
parentb56cbdd23834a65682c0b46f367f8679e83bc894 (diff)
Merge new upstream LTS 20200923
Diffstat (limited to 'absl/random/uniform_real_distribution_test.cc')
-rw-r--r--absl/random/uniform_real_distribution_test.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/absl/random/uniform_real_distribution_test.cc b/absl/random/uniform_real_distribution_test.cc
index a56374a6..be107cdd 100644
--- a/absl/random/uniform_real_distribution_test.cc
+++ b/absl/random/uniform_real_distribution_test.cc
@@ -27,6 +27,7 @@
#include "absl/base/internal/raw_logging.h"
#include "absl/random/internal/chi_square.h"
#include "absl/random/internal/distribution_test_util.h"
+#include "absl/random/internal/pcg_engine.h"
#include "absl/random/internal/sequence_urbg.h"
#include "absl/random/random.h"
#include "absl/strings/str_cat.h"
@@ -207,7 +208,11 @@ TYPED_TEST(UniformRealDistributionTest, TestMoments) {
constexpr int kSize = 1000000;
std::vector<double> values(kSize);
- absl::InsecureBitGen rng;
+ // We use a fixed bit generator for distribution accuracy tests. This allows
+ // these tests to be deterministic, while still testing the qualify of the
+ // implementation.
+ absl::random_internal::pcg64_2018_engine rng{0x2B7E151628AED2A6};
+
absl::uniform_real_distribution<TypeParam> dist;
for (int i = 0; i < kSize; i++) {
values[i] = dist(rng);
@@ -237,7 +242,11 @@ TYPED_TEST(UniformRealDistributionTest, ChiSquaredTest50) {
const int kThreshold =
absl::random_internal::ChiSquareValue(kBuckets - 1, 0.999999);
- absl::InsecureBitGen rng;
+ // We use a fixed bit generator for distribution accuracy tests. This allows
+ // these tests to be deterministic, while still testing the qualify of the
+ // implementation.
+ absl::random_internal::pcg64_2018_engine rng{0x2B7E151628AED2A6};
+
for (const auto& param : {param_type(0, 1), param_type(5, 12),
param_type(-5, 13), param_type(-5, -2)}) {
const double min_val = param.a();