From 52747821480e6cadd8b27a0947af5d7933f9dfb4 Mon Sep 17 00:00:00 2001 From: Andy Getzendanner Date: Tue, 23 May 2023 15:46:35 -0700 Subject: Migrate most RAW_LOGs and RAW_CHECKs in tests to regular LOG and CHECK. The non-RAW_ versions provide better output but weren't available when most of these tests were written. There are just a couple spots where RAW_ is actually needed, e.g. signal handlers and malloc hooks. Also fix a couple warnings in layout_test.cc newly surfaced because the optimizer understands CHECK_XX differently than INTERNAL_CHECK. PiperOrigin-RevId: 534584435 Change-Id: I8d36fa809ffdaae5a3813064bd602cb8611c1613 --- absl/random/poisson_distribution_test.cc | 45 +++++++++++++++----------------- 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'absl/random/poisson_distribution_test.cc') diff --git a/absl/random/poisson_distribution_test.cc b/absl/random/poisson_distribution_test.cc index 4f585b9b..54755960 100644 --- a/absl/random/poisson_distribution_test.cc +++ b/absl/random/poisson_distribution_test.cc @@ -25,9 +25,9 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "absl/base/internal/raw_logging.h" #include "absl/base/macros.h" #include "absl/container/flat_hash_map.h" +#include "absl/log/log.h" #include "absl/random/internal/chi_square.h" #include "absl/random/internal/distribution_test_util.h" #include "absl/random/internal/pcg_engine.h" @@ -134,8 +134,8 @@ TYPED_TEST(PoissonDistributionInterfaceTest, SerializeTest) { if (sample < sample_min) sample_min = sample; } - ABSL_INTERNAL_LOG(INFO, absl::StrCat("Range {", param.mean(), "}: ", - +sample_min, ", ", +sample_max)); + LOG(INFO) << "Range {" << param.mean() << "}: " << sample_min << ", " + << sample_max; // Validate stream serialization. std::stringstream ss; @@ -188,10 +188,9 @@ class PoissonModel { } void LogCDF() { - ABSL_INTERNAL_LOG(INFO, absl::StrCat("CDF (mean = ", mean_, ")")); + LOG(INFO) << "CDF (mean = " << mean_ << ")"; for (const auto c : cdf_) { - ABSL_INTERNAL_LOG(INFO, - absl::StrCat(c.index, ": pmf=", c.pmf, " cdf=", c.cdf)); + LOG(INFO) << c.index << ": pmf=" << c.pmf << " cdf=" << c.cdf; } } @@ -286,16 +285,15 @@ bool PoissonDistributionZTest::SingleZTest(const double p, const bool pass = absl::random_internal::Near("z", z, 0.0, max_err); if (!pass) { - ABSL_INTERNAL_LOG( - INFO, absl::StrFormat("p=%f max_err=%f\n" - " mean=%f vs. %f\n" - " stddev=%f vs. %f\n" - " skewness=%f vs. %f\n" - " kurtosis=%f vs. %f\n" - " z=%f", - p, max_err, m.mean, mean(), std::sqrt(m.variance), - stddev(), m.skewness, skew(), m.kurtosis, - kurtosis(), z)); + // clang-format off + LOG(INFO) + << "p=" << p << " max_err=" << max_err << "\n" + " mean=" << m.mean << " vs. " << mean() << "\n" + " stddev=" << std::sqrt(m.variance) << " vs. " << stddev() << "\n" + " skewness=" << m.skewness << " vs. " << skew() << "\n" + " kurtosis=" << m.kurtosis << " vs. " << kurtosis() << "\n" + " z=" << z; + // clang-format on } return pass; } @@ -439,17 +437,16 @@ double PoissonDistributionChiSquaredTest::ChiSquaredTestImpl() { if (chi_square > threshold) { LogCDF(); - ABSL_INTERNAL_LOG(INFO, absl::StrCat("VALUES buckets=", counts.size(), - " samples=", kSamples)); + LOG(INFO) << "VALUES buckets=" << counts.size() + << " samples=" << kSamples; for (size_t i = 0; i < counts.size(); i++) { - ABSL_INTERNAL_LOG( - INFO, absl::StrCat(cutoffs_[i], ": ", counts[i], " vs. E=", e[i])); + LOG(INFO) << cutoffs_[i] << ": " << counts[i] << " vs. E=" << e[i]; } - ABSL_INTERNAL_LOG( - INFO, - absl::StrCat(kChiSquared, "(data, dof=", dof, ") = ", chi_square, " (", - p, ")\n", " vs.\n", kChiSquared, " @ 0.98 = ", threshold)); + LOG(INFO) << kChiSquared << "(data, dof=" << dof << ") = " << chi_square + << " (" << p << ")\n" + << " vs.\n" + << kChiSquared << " @ 0.98 = " << threshold; } return p; } -- cgit v1.2.3