diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-28 16:02:05 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-28 16:02:05 +0000 |
commit | 58ad3d45b728357ca71b7d6347aa575148f8d4bb (patch) | |
tree | 2ce94d7f0804ccb77d1fa9b2a1bca00eecdff1e2 /third_party/abseil-cpp/absl/random/gaussian_distribution_test.cc | |
parent | f60eaea2240ba9e1c508e8e0c91d39ee9fc47be5 (diff) | |
parent | 7563023510bf04108a954596ea9393a4c11ac279 (diff) | |
download | webrtc-58ad3d45b728357ca71b7d6347aa575148f8d4bb.tar.gz |
Snap for 8512216 from 7563023510bf04108a954596ea9393a4c11ac279 to tm-frc-art-releaset_frc_art_330443060android13-frc-art-release
Change-Id: I0f5d0c35a5c93d95ec2667742ce37c18773633a4
Diffstat (limited to 'third_party/abseil-cpp/absl/random/gaussian_distribution_test.cc')
-rw-r--r-- | third_party/abseil-cpp/absl/random/gaussian_distribution_test.cc | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/third_party/abseil-cpp/absl/random/gaussian_distribution_test.cc b/third_party/abseil-cpp/absl/random/gaussian_distribution_test.cc index 49c07513bf..c0bac2b0db 100644 --- a/third_party/abseil-cpp/absl/random/gaussian_distribution_test.cc +++ b/third_party/abseil-cpp/absl/random/gaussian_distribution_test.cc @@ -21,12 +21,14 @@ #include <iterator> #include <random> #include <string> +#include <type_traits> #include <vector> #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/base/internal/raw_logging.h" #include "absl/base/macros.h" +#include "absl/numeric/internal/representation.h" #include "absl/random/internal/chi_square.h" #include "absl/random/internal/distribution_test_util.h" #include "absl/random/internal/sequence_urbg.h" @@ -43,7 +45,15 @@ using absl::random_internal::kChiSquared; template <typename RealType> class GaussianDistributionInterfaceTest : public ::testing::Test {}; -using RealTypes = ::testing::Types<float, double, long double>; +// double-double arithmetic is not supported well by either GCC or Clang; see +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99048, +// https://bugs.llvm.org/show_bug.cgi?id=49131, and +// https://bugs.llvm.org/show_bug.cgi?id=49132. Don't bother running these tests +// with double doubles until compiler support is better. +using RealTypes = + std::conditional<absl::numeric_internal::IsDoubleDouble(), + ::testing::Types<float, double>, + ::testing::Types<float, double, long double>>::type; TYPED_TEST_CASE(GaussianDistributionInterfaceTest, RealTypes); TYPED_TEST(GaussianDistributionInterfaceTest, SerializeTest) { @@ -129,29 +139,6 @@ TYPED_TEST(GaussianDistributionInterfaceTest, SerializeTest) { ss >> after; -#if defined(__powerpc64__) || defined(__PPC64__) || defined(__powerpc__) || \ - defined(__ppc__) || defined(__PPC__) - if (std::is_same<TypeParam, long double>::value) { - // Roundtripping floating point values requires sufficient precision - // to reconstruct the exact value. It turns out that long double - // has some errors doing this on ppc, particularly for values - // near {1.0 +/- epsilon}. - if (mean <= std::numeric_limits<double>::max() && - mean >= std::numeric_limits<double>::lowest()) { - EXPECT_EQ(static_cast<double>(before.mean()), - static_cast<double>(after.mean())) - << ss.str(); - } - if (stddev <= std::numeric_limits<double>::max() && - stddev >= std::numeric_limits<double>::lowest()) { - EXPECT_EQ(static_cast<double>(before.stddev()), - static_cast<double>(after.stddev())) - << ss.str(); - } - continue; - } -#endif - EXPECT_EQ(before.mean(), after.mean()); EXPECT_EQ(before.stddev(), after.stddev()) // << ss.str() << " " // @@ -213,7 +200,10 @@ class GaussianDistributionTests : public testing::TestWithParam<Param>, template <typename D> double SingleChiSquaredTest(); - 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}; }; template <typename D> |