}
}
+TEST(Random, FixedSeed) {
+ // clang-format off
+ struct ConstantRNG {
+ typedef uint32_t result_type;
+ result_type operator()() {
+ return 4; // chosen by fair dice roll.
+ // guaranteed to be random.
+ }
+ result_type min() {
+ return std::numeric_limits<result_type>::min();
+ }
+ result_type max() {
+ return std::numeric_limits<result_type>::max();
+ }
+ };
+ // clang-format on
+
+ ConstantRNG gen;
+ // Loop to make sure it really is constant.
+ for (int i = 0; i < 1024; ++i) {
+ auto result = Random::rand32(10, gen);
+ // TODO: This is a little bit brittle; standard library changes could break
+ // it, if it starts implementing distribution types differently.
+ EXPECT_EQ(0, result);
+ }
+}
+
TEST(Random, MultiThreaded) {
const int n = 100;
std::vector<uint32_t> seeds(n);