#include <algorithm>
#include <climits>
#include "src/base/utils/random-number-generator.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace v8 {
namespace base {
class RandomNumberGeneratorTest : public ::testing::TestWithParam<int> { … };
static const int kMaxRuns = …;
static void CheckSample(std::vector<uint64_t> sample, uint64_t max,
size_t size) { … }
static void CheckSlowSample(const std::vector<uint64_t>& sample, uint64_t max,
size_t size,
const std::unordered_set<uint64_t>& excluded) { … }
static void TestNextSample(RandomNumberGenerator* rng, uint64_t max,
size_t size, bool slow = false) { … }
TEST_P(RandomNumberGeneratorTest, NextIntWithMaxValue) { … }
TEST_P(RandomNumberGeneratorTest, NextBooleanReturnsFalseOrTrue) { … }
TEST_P(RandomNumberGeneratorTest, NextDoubleReturnsValueBetween0And1) { … }
#if !defined(DEBUG) && defined(OFFICIAL_BUILD)
#define FATAL_MSG …
#else
#define FATAL_MSG …
#endif
TEST(RandomNumberGenerator, NextSampleInvalidParam) { … }
TEST(RandomNumberGenerator, NextSampleSlowInvalidParam1) { … }
TEST(RandomNumberGenerator, NextSampleSlowInvalidParam2) { … }
#undef FATAL_MSG
TEST_P(RandomNumberGeneratorTest, NextSample0) { … }
TEST_P(RandomNumberGeneratorTest, NextSampleSlow0) { … }
TEST_P(RandomNumberGeneratorTest, NextSample1) { … }
TEST_P(RandomNumberGeneratorTest, NextSampleSlow1) { … }
TEST_P(RandomNumberGeneratorTest, NextSampleMax) { … }
TEST_P(RandomNumberGeneratorTest, NextSampleSlowMax) { … }
TEST_P(RandomNumberGeneratorTest, NextSampleHalf) { … }
TEST_P(RandomNumberGeneratorTest, NextSampleSlowHalf) { … }
TEST_P(RandomNumberGeneratorTest, NextSampleMoreThanHalf) { … }
TEST_P(RandomNumberGeneratorTest, NextSampleSlowMoreThanHalf) { … }
TEST_P(RandomNumberGeneratorTest, NextSampleLessThanHalf) { … }
TEST_P(RandomNumberGeneratorTest, NextSampleSlowLessThanHalf) { … }
TEST_P(RandomNumberGeneratorTest, NextSampleSlowExcluded) { … }
TEST_P(RandomNumberGeneratorTest, NextSampleSlowExcludedMax1) { … }
TEST_P(RandomNumberGeneratorTest, NextSampleSlowExcludedMax2) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
}