chromium/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/rand_util_pa_unittest.cc

// Copyright 2011 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <algorithm>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <memory>
#include <vector>

#include "partition_alloc/partition_alloc_base/check.h"
#include "partition_alloc/partition_alloc_base/logging.h"
#include "partition_alloc/partition_alloc_base/rand_util.h"
#include "partition_alloc/partition_alloc_base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace partition_alloc::internal::base {

TEST(PartitionAllocBaseRandUtilTest, RandBytes) {}

// Verify that calling base::RandBytes with an empty buffer doesn't fail.
TEST(PartitionAllocBaseRandUtilTest, RandBytes0) {}

// Make sure that it is still appropriate to use RandGenerator in conjunction
// with std::random_shuffle().
TEST(PartitionAllocBaseRandUtilTest, RandGeneratorForRandomShuffle) {}

TEST(PartitionAllocBaseRandUtilTest, RandGeneratorIsUniform) {}

TEST(PartitionAllocBaseRandUtilTest, RandUint64ProducesBothValuesOfAllBits) {}

// Benchmark test for RandBytes().  Disabled since it's intentionally slow and
// does not test anything that isn't already tested by the existing RandBytes()
// tests.
TEST(PartitionAllocBaseRandUtilTest, DISABLED_RandBytesPerf) {}

TEST(PartitionAllocBaseRandUtilTest,
     InsecureRandomGeneratorProducesBothValuesOfAllBits) {}

namespace {

constexpr double kXp1Percent =;
constexpr double kXp99Percent =;

double ChiSquaredCriticalValue(double nu, double x_p) {}

int ExtractBits(uint64_t value, int from_bit, int num_bits) {}

// Performs a Chi-Squared test on a subset of |num_bits| extracted starting from
// |from_bit| in the generated value.
//
// See TAOCP, Volume 2, Section 3.3.1, and
// https://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test for details.
//
// This is only one of the many, many random number generator test we could do,
// but they are cumbersome, as they are typically very slow, and expected to
// fail from time to time, due to their probabilistic nature.
//
// The generator we use has however been vetted with the BigCrush test suite
// from Marsaglia, so this should suffice as a smoke test that our
// implementation is wrong.
bool ChiSquaredTest(InsecureRandomGenerator& gen,
                    size_t n,
                    int from_bit,
                    int num_bits) {}

}  // namespace

TEST(PartitionAllocBaseRandUtilTest, InsecureRandomGeneratorChiSquared) {}

}  // namespace partition_alloc::internal::base