From 5aa5d282eac56a21e74611c1cdbaa97bb5db2dca Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 8 Feb 2022 02:05:36 +0300 Subject: chore(3p/abseil_cpp): unvendor abseil_cpp we weren't actually using these sources anymore, okay? Change-Id: If701571d9716de308d3512e1eb22c35db0877a66 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5248 Tested-by: BuildkiteCI Reviewed-by: grfn Autosubmit: tazjin --- .../abseil_cpp/absl/random/generators_test.cc | 179 --------------------- 1 file changed, 179 deletions(-) delete mode 100644 third_party/abseil_cpp/absl/random/generators_test.cc (limited to 'third_party/abseil_cpp/absl/random/generators_test.cc') diff --git a/third_party/abseil_cpp/absl/random/generators_test.cc b/third_party/abseil_cpp/absl/random/generators_test.cc deleted file mode 100644 index 41725f139cd3..000000000000 --- a/third_party/abseil_cpp/absl/random/generators_test.cc +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include -#include - -#include "gtest/gtest.h" -#include "absl/random/distributions.h" -#include "absl/random/random.h" - -namespace { - -template -void TestUniform(URBG* gen) { - // [a, b) default-semantics, inferred types. - absl::Uniform(*gen, 0, 100); // int - absl::Uniform(*gen, 0, 1.0); // Promoted to double - absl::Uniform(*gen, 0.0f, 1.0); // Promoted to double - absl::Uniform(*gen, 0.0, 1.0); // double - absl::Uniform(*gen, -1, 1L); // Promoted to long - - // Roll a die. - absl::Uniform(absl::IntervalClosedClosed, *gen, 1, 6); - - // Get a fraction. - absl::Uniform(absl::IntervalOpenOpen, *gen, 0.0, 1.0); - - // Assign a value to a random element. - std::vector elems = {10, 20, 30, 40, 50}; - elems[absl::Uniform(*gen, 0u, elems.size())] = 5; - elems[absl::Uniform(*gen, 0, elems.size())] = 3; - - // Choose some epsilon around zero. - absl::Uniform(absl::IntervalOpenOpen, *gen, -1.0, 1.0); - - // (a, b) semantics, inferred types. - absl::Uniform(absl::IntervalOpenOpen, *gen, 0, 1.0); // Promoted to double - - // Explict overriding of types. - absl::Uniform(*gen, 0, 100); - absl::Uniform(*gen, 0, 100); - absl::Uniform(*gen, 0, 100); - absl::Uniform(*gen, 0, 100); - absl::Uniform(*gen, 0, 1 << 10); - absl::Uniform(*gen, 0, 1 << 10); - absl::Uniform(*gen, 0, 1 << 10); - absl::Uniform(*gen, 0, 1 << 10); - - absl::Uniform(*gen, 0.0, 1.0); - absl::Uniform(*gen, 0, 1); - absl::Uniform(*gen, -1, 1); - absl::Uniform(*gen, 0.0, 1.0); - - absl::Uniform(*gen, -1.0, 0); - absl::Uniform(*gen, -1.0, 0); - - // Tagged - absl::Uniform(absl::IntervalClosedClosed, *gen, 0, 1); - absl::Uniform(absl::IntervalClosedOpen, *gen, 0, 1); - absl::Uniform(absl::IntervalOpenOpen, *gen, 0, 1); - absl::Uniform(absl::IntervalOpenClosed, *gen, 0, 1); - absl::Uniform(absl::IntervalClosedClosed, *gen, 0, 1); - absl::Uniform(absl::IntervalOpenOpen, *gen, 0, 1); - - absl::Uniform(absl::IntervalClosedClosed, *gen, 0, 100); - absl::Uniform(absl::IntervalClosedOpen, *gen, 0, 100); - absl::Uniform(absl::IntervalOpenOpen, *gen, 0, 100); - absl::Uniform(absl::IntervalOpenClosed, *gen, 0, 100); - absl::Uniform(absl::IntervalClosedClosed, *gen, 0, 100); - absl::Uniform(absl::IntervalOpenOpen, *gen, 0, 100); - - // With *generator as an R-value reference. - absl::Uniform(URBG(), 0, 100); - absl::Uniform(URBG(), 0.0, 1.0); -} - -template -void TestExponential(URBG* gen) { - absl::Exponential(*gen); - absl::Exponential(*gen); - absl::Exponential(URBG()); -} - -template -void TestPoisson(URBG* gen) { - // [rand.dist.pois] Indicates that the std::poisson_distribution - // is parameterized by IntType, however MSVC does not allow 8-bit - // types. - absl::Poisson(*gen); - absl::Poisson(*gen); - absl::Poisson(*gen); - absl::Poisson(*gen); - absl::Poisson(*gen); - absl::Poisson(*gen); - absl::Poisson(*gen); - absl::Poisson(URBG()); -} - -template -void TestBernoulli(URBG* gen) { - absl::Bernoulli(*gen, 0.5); - absl::Bernoulli(*gen, 0.5); -} - -template -void TestZipf(URBG* gen) { - absl::Zipf(*gen, 100); - absl::Zipf(*gen, 100); - absl::Zipf(*gen, 100); - absl::Zipf(*gen, 100); - absl::Zipf(*gen, 1 << 10); - absl::Zipf(*gen, 1 << 10); - absl::Zipf(*gen, 1 << 10); - absl::Zipf(*gen, 1 << 10); - absl::Zipf(URBG(), 1 << 10); -} - -template -void TestGaussian(URBG* gen) { - absl::Gaussian(*gen, 1.0, 1.0); - absl::Gaussian(*gen, 1.0, 1.0); - absl::Gaussian(URBG(), 1.0, 1.0); -} - -template -void TestLogNormal(URBG* gen) { - absl::LogUniform(*gen, 0, 100); - absl::LogUniform(*gen, 0, 100); - absl::LogUniform(*gen, 0, 100); - absl::LogUniform(*gen, 0, 100); - absl::LogUniform(*gen, 0, 1 << 10); - absl::LogUniform(*gen, 0, 1 << 10); - absl::LogUniform(*gen, 0, 1 << 10); - absl::LogUniform(*gen, 0, 1 << 10); - absl::LogUniform(URBG(), 0, 1 << 10); -} - -template -void CompatibilityTest() { - URBG gen; - - TestUniform(&gen); - TestExponential(&gen); - TestPoisson(&gen); - TestBernoulli(&gen); - TestZipf(&gen); - TestGaussian(&gen); - TestLogNormal(&gen); -} - -TEST(std_mt19937_64, Compatibility) { - // Validate with std::mt19937_64 - CompatibilityTest(); -} - -TEST(BitGen, Compatibility) { - // Validate with absl::BitGen - CompatibilityTest(); -} - -TEST(InsecureBitGen, Compatibility) { - // Validate with absl::InsecureBitGen - CompatibilityTest(); -} - -} // namespace -- cgit 1.4.1