summaryrefslogtreecommitdiff
path: root/absl/random/beta_distribution_test.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-05-12 16:07:27 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-05-12 16:07:59 -0700
commitf7a250aa9ae11ed88645e0f0ce3a583f44443cc7 (patch)
tree9934ac9113a4b0d7d31a1a65bdb2da80e837bb8a /absl/random/beta_distribution_test.cc
parent3af16ffea816504d44a60fcc083d9f58b7d40d0d (diff)
Internal change
PiperOrigin-RevId: 448361090 Change-Id: Iec6063b88a778dfe815081612650eaa456503265
Diffstat (limited to 'absl/random/beta_distribution_test.cc')
-rw-r--r--absl/random/beta_distribution_test.cc28
1 files changed, 19 insertions, 9 deletions
diff --git a/absl/random/beta_distribution_test.cc b/absl/random/beta_distribution_test.cc
index 9a3eb2b7..c16fbb4f 100644
--- a/absl/random/beta_distribution_test.cc
+++ b/absl/random/beta_distribution_test.cc
@@ -45,15 +45,25 @@ namespace {
template <typename IntType>
class BetaDistributionInterfaceTest : public ::testing::Test {};
-// 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;
+constexpr bool ShouldExerciseLongDoubleTests() {
+ // long double arithmetic is not supported well by either GCC or Clang on
+ // most platforms specifically not when implemented in terms of double-double;
+ // 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.
+ // So a conservative choice here is to disable long-double tests pretty much
+ // everywhere except on x64 but only if long double is not implemented as
+ // double-double.
+#if defined(__i686__) && defined(__x86_64__)
+ return !absl::numeric_internal::IsDoubleDouble();
+#else
+ return false;
+#endif
+}
+
+using RealTypes = std::conditional<ShouldExerciseLongDoubleTests(),
+ ::testing::Types<float, double, long double>,
+ ::testing::Types<float, double>>::type;
TYPED_TEST_SUITE(BetaDistributionInterfaceTest, RealTypes);
TYPED_TEST(BetaDistributionInterfaceTest, SerializeTest) {