summaryrefslogtreecommitdiff
path: root/absl/random
diff options
context:
space:
mode:
authorGravatar Andy Getzendanner <durandal@google.com>2023-05-23 15:46:35 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-05-23 15:47:23 -0700
commit52747821480e6cadd8b27a0947af5d7933f9dfb4 (patch)
treecc42f6dc30fa8eca19047efd799c769ead59b6c4 /absl/random
parent79ca5d7aad63973c83a4962a66ab07cd623131ea (diff)
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
Diffstat (limited to 'absl/random')
-rw-r--r--absl/random/BUILD.bazel18
-rw-r--r--absl/random/CMakeLists.txt23
-rw-r--r--absl/random/beta_distribution_test.cc39
-rw-r--r--absl/random/discrete_distribution_test.cc4
-rw-r--r--absl/random/exponential_distribution_test.cc44
-rw-r--r--absl/random/gaussian_distribution_test.cc44
-rw-r--r--absl/random/internal/BUILD.bazel8
-rw-r--r--absl/random/internal/nanobenchmark_test.cc20
-rw-r--r--absl/random/internal/randen_engine_test.cc7
-rw-r--r--absl/random/internal/randen_hwaes_test.cc26
-rw-r--r--absl/random/log_uniform_int_distribution_test.cc19
-rw-r--r--absl/random/poisson_distribution_test.cc45
-rw-r--r--absl/random/uniform_int_distribution_test.cc7
-rw-r--r--absl/random/uniform_real_distribution_test.cc9
-rw-r--r--absl/random/zipf_distribution_test.cc22
15 files changed, 160 insertions, 175 deletions
diff --git a/absl/random/BUILD.bazel b/absl/random/BUILD.bazel
index 133c0659..19130ff7 100644
--- a/absl/random/BUILD.bazel
+++ b/absl/random/BUILD.bazel
@@ -189,7 +189,7 @@ cc_test(
deps = [
":distributions",
":random",
- "//absl/base:raw_logging_internal",
+ "//absl/log",
"//absl/numeric:representation",
"//absl/random/internal:distribution_test_util",
"//absl/random/internal:pcg_engine",
@@ -244,7 +244,7 @@ cc_test(
deps = [
":distributions",
":random",
- "//absl/base:raw_logging_internal",
+ "//absl/log",
"//absl/random/internal:distribution_test_util",
"//absl/random/internal:pcg_engine",
"//absl/random/internal:sequence_urbg",
@@ -265,7 +265,7 @@ cc_test(
deps = [
":distributions",
":random",
- "//absl/base:raw_logging_internal",
+ "//absl/log",
"//absl/random/internal:distribution_test_util",
"//absl/random/internal:pcg_engine",
"//absl/random/internal:sequence_urbg",
@@ -292,8 +292,8 @@ cc_test(
":distributions",
":random",
"//absl/base:core_headers",
- "//absl/base:raw_logging_internal",
"//absl/container:flat_hash_map",
+ "//absl/log",
"//absl/random/internal:distribution_test_util",
"//absl/random/internal:pcg_engine",
"//absl/random/internal:sequence_urbg",
@@ -314,7 +314,7 @@ cc_test(
":distributions",
":random",
"//absl/base:core_headers",
- "//absl/base:raw_logging_internal",
+ "//absl/log",
"//absl/numeric:representation",
"//absl/random/internal:distribution_test_util",
"//absl/random/internal:pcg_engine",
@@ -338,7 +338,7 @@ cc_test(
":distributions",
":random",
"//absl/base:core_headers",
- "//absl/base:raw_logging_internal",
+ "//absl/log",
"//absl/numeric:representation",
"//absl/random/internal:distribution_test_util",
"//absl/random/internal:sequence_urbg",
@@ -360,7 +360,7 @@ cc_test(
deps = [
":distributions",
":random",
- "//absl/base:raw_logging_internal",
+ "//absl/log",
"//absl/random/internal:distribution_test_util",
"//absl/random/internal:pcg_engine",
"//absl/random/internal:sequence_urbg",
@@ -385,7 +385,7 @@ cc_test(
deps = [
":distributions",
":random",
- "//absl/base:raw_logging_internal",
+ "//absl/log",
"//absl/numeric:representation",
"//absl/random/internal:distribution_test_util",
"//absl/random/internal:pcg_engine",
@@ -406,7 +406,7 @@ cc_test(
deps = [
":distributions",
":random",
- "//absl/base:raw_logging_internal",
+ "//absl/log",
"//absl/random/internal:distribution_test_util",
"//absl/random/internal:pcg_engine",
"//absl/random/internal:sequence_urbg",
diff --git a/absl/random/CMakeLists.txt b/absl/random/CMakeLists.txt
index c74fd300..bd363d88 100644
--- a/absl/random/CMakeLists.txt
+++ b/absl/random/CMakeLists.txt
@@ -260,13 +260,13 @@ absl_cc_test(
LINKOPTS
${ABSL_DEFAULT_LINKOPTS}
DEPS
+ absl::log
absl::numeric_representation
absl::random_distributions
absl::random_random
absl::random_internal_distribution_test_util
absl::random_internal_sequence_urbg
absl::random_internal_pcg_engine
- absl::raw_logging_internal
absl::strings
absl::str_format
GTest::gmock
@@ -299,6 +299,7 @@ absl_cc_test(
${ABSL_TEST_COPTS}
LINKOPTS
${ABSL_DEFAULT_LINKOPTS}
+ DEPS
absl::random_distributions
absl::random_random
absl::raw_logging_internal
@@ -315,12 +316,13 @@ absl_cc_test(
${ABSL_TEST_COPTS}
LINKOPTS
${ABSL_DEFAULT_LINKOPTS}
+ DEPS
+ absl::log
absl::random_distributions
absl::random_internal_distribution_test_util
absl::random_internal_pcg_engine
absl::random_internal_sequence_urbg
absl::random_random
- absl::raw_logging_internal
absl::strings
absl::str_format
GTest::gmock
@@ -337,12 +339,12 @@ absl_cc_test(
LINKOPTS
${ABSL_DEFAULT_LINKOPTS}
DEPS
+ absl::log
absl::random_distributions
absl::random_internal_distribution_test_util
absl::random_internal_pcg_engine
absl::random_internal_sequence_urbg
absl::random_random
- absl::raw_logging_internal
absl::strings
GTest::gmock
GTest::gtest_main
@@ -362,10 +364,10 @@ absl_cc_test(
absl::random_random
absl::core_headers
absl::flat_hash_map
+ absl::log
absl::random_internal_distribution_test_util
absl::random_internal_pcg_engine
absl::random_internal_sequence_urbg
- absl::raw_logging_internal
absl::strings
absl::str_format
GTest::gmock
@@ -383,13 +385,13 @@ absl_cc_test(
${ABSL_DEFAULT_LINKOPTS}
DEPS
absl::core_headers
+ absl::log
absl::numeric_representation
absl::random_distributions
absl::random_internal_distribution_test_util
absl::random_internal_pcg_engine
absl::random_internal_sequence_urbg
absl::random_random
- absl::raw_logging_internal
absl::strings
absl::str_format
GTest::gmock
@@ -407,12 +409,12 @@ absl_cc_test(
${ABSL_DEFAULT_LINKOPTS}
DEPS
absl::core_headers
+ absl::log
absl::numeric_representation
absl::random_distributions
absl::random_internal_distribution_test_util
absl::random_internal_sequence_urbg
absl::random_random
- absl::raw_logging_internal
absl::strings
absl::str_format
GTest::gmock
@@ -429,12 +431,12 @@ absl_cc_test(
LINKOPTS
${ABSL_DEFAULT_LINKOPTS}
DEPS
+ absl::log
absl::random_distributions
absl::random_internal_distribution_test_util
absl::random_internal_pcg_engine
absl::random_internal_sequence_urbg
absl::random_random
- absl::raw_logging_internal
absl::strings
GTest::gmock
GTest::gtest_main
@@ -450,6 +452,7 @@ absl_cc_test(
LINKOPTS
${ABSL_DEFAULT_LINKOPTS}
DEPS
+ absl::log
absl::numeric_representation
absl::random_distributions
absl::random_internal_distribution_test_util
@@ -471,12 +474,12 @@ absl_cc_test(
LINKOPTS
${ABSL_DEFAULT_LINKOPTS}
DEPS
+ absl::log
absl::random_distributions
absl::random_internal_distribution_test_util
absl::random_internal_pcg_engine
absl::random_internal_sequence_urbg
absl::random_random
- absl::raw_logging_internal
absl::strings
GTest::gmock
GTest::gtest_main
@@ -1090,9 +1093,9 @@ absl_cc_test(
LINKOPTS
${ABSL_DEFAULT_LINKOPTS}
DEPS
+ absl::log
absl::random_internal_explicit_seed_seq
absl::random_internal_randen_engine
- absl::raw_logging_internal
absl::strings
absl::time
GTest::gmock
@@ -1142,10 +1145,10 @@ absl_cc_test(
LINKOPTS
${ABSL_DEFAULT_LINKOPTS}
DEPS
+ absl::log
absl::random_internal_platform
absl::random_internal_randen_hwaes
absl::random_internal_randen_hwaes_impl
- absl::raw_logging_internal
absl::str_format
GTest::gmock
GTest::gtest
diff --git a/absl/random/beta_distribution_test.cc b/absl/random/beta_distribution_test.cc
index c16fbb4f..c93b2a33 100644
--- a/absl/random/beta_distribution_test.cc
+++ b/absl/random/beta_distribution_test.cc
@@ -28,7 +28,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#include "absl/base/internal/raw_logging.h"
+#include "absl/log/log.h"
#include "absl/numeric/internal/representation.h"
#include "absl/random/internal/chi_square.h"
#include "absl/random/internal/distribution_test_util.h"
@@ -107,8 +107,8 @@ TYPED_TEST(BetaDistributionInterfaceTest, SerializeTest) {
};
for (TypeParam alpha : kValues) {
for (TypeParam beta : kValues) {
- ABSL_INTERNAL_LOG(
- INFO, absl::StrFormat("Smoke test for Beta(%a, %a)", alpha, beta));
+ LOG(INFO) << absl::StreamFormat("Smoke test for Beta(%a, %a)", alpha,
+ beta);
param_type param(alpha, beta);
absl::beta_distribution<TypeParam> before(alpha, beta);
@@ -327,15 +327,13 @@ bool BetaDistributionTest::SingleZTestOnMeanAndVariance(double p,
absl::random_internal::Near("z", z_mean, 0.0, max_err) &&
absl::random_internal::Near("z_variance", z_variance, 0.0, max_err);
if (!pass) {
- ABSL_INTERNAL_LOG(
- INFO,
- absl::StrFormat(
- "Beta(%f, %f), "
- "mean: sample %f, expect %f, which is %f stddevs away, "
- "variance: sample %f, expect %f, which is %f stddevs away.",
- alpha_, beta_, m.mean, Mean(),
- std::abs(m.mean - Mean()) / mean_stddev, m.variance, Variance(),
- std::abs(m.variance - Variance()) / variance_stddev));
+ LOG(INFO) << "Beta(" << alpha_ << ", " << beta_ << "), mean: sample "
+ << m.mean << ", expect " << Mean() << ", which is "
+ << std::abs(m.mean - Mean()) / mean_stddev
+ << " stddevs away, variance: sample " << m.variance << ", expect "
+ << Variance() << ", which is "
+ << std::abs(m.variance - Variance()) / variance_stddev
+ << " stddevs away.";
}
return pass;
}
@@ -396,18 +394,15 @@ bool BetaDistributionTest::SingleChiSquaredTest(double p, size_t samples,
const bool pass =
(absl::random_internal::ChiSquarePValue(chi_square, dof) >= p);
if (!pass) {
- for (int i = 0; i < cutoffs.size(); i++) {
- ABSL_INTERNAL_LOG(
- INFO, absl::StrFormat("cutoff[%d] = %f, actual count %d, expected %d",
- i, cutoffs[i], counts[i],
- static_cast<int>(expected[i])));
+ for (size_t i = 0; i < cutoffs.size(); i++) {
+ LOG(INFO) << "cutoff[" << i << "] = " << cutoffs[i] << ", actual count "
+ << counts[i] << ", expected " << static_cast<int>(expected[i]);
}
- ABSL_INTERNAL_LOG(
- INFO, absl::StrFormat(
- "Beta(%f, %f) %s %f, p = %f", alpha_, beta_,
- absl::random_internal::kChiSquared, chi_square,
- absl::random_internal::ChiSquarePValue(chi_square, dof)));
+ LOG(INFO) << "Beta(" << alpha_ << ", " << beta_ << ") "
+ << absl::random_internal::kChiSquared << " " << chi_square
+ << ", p = "
+ << absl::random_internal::ChiSquarePValue(chi_square, dof);
}
return pass;
}
diff --git a/absl/random/discrete_distribution_test.cc b/absl/random/discrete_distribution_test.cc
index e528a6a7..32405ea9 100644
--- a/absl/random/discrete_distribution_test.cc
+++ b/absl/random/discrete_distribution_test.cc
@@ -26,7 +26,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#include "absl/base/internal/raw_logging.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"
@@ -194,7 +194,7 @@ TEST(DiscreteDistributionTest, ChiSquaredTest50) {
absl::StrAppend(&msg, kChiSquared, " p-value ", p_value, "\n");
absl::StrAppend(&msg, "High ", kChiSquared, " value: ", chi_square, " > ",
kThreshold);
- ABSL_RAW_LOG(INFO, "%s", msg.c_str());
+ LOG(INFO) << msg;
FAIL() << msg;
}
}
diff --git a/absl/random/exponential_distribution_test.cc b/absl/random/exponential_distribution_test.cc
index 3c44d9ec..fb9a0d16 100644
--- a/absl/random/exponential_distribution_test.cc
+++ b/absl/random/exponential_distribution_test.cc
@@ -29,8 +29,8 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#include "absl/base/internal/raw_logging.h"
#include "absl/base/macros.h"
+#include "absl/log/log.h"
#include "absl/numeric/internal/representation.h"
#include "absl/random/internal/chi_square.h"
#include "absl/random/internal/distribution_test_util.h"
@@ -115,9 +115,8 @@ TYPED_TEST(ExponentialDistributionTypedTest, SerializeTest) {
if (sample < sample_min) sample_min = sample;
}
if (!std::is_same<TypeParam, long double>::value) {
- ABSL_INTERNAL_LOG(INFO,
- absl::StrFormat("Range {%f}: %f, %f, lambda=%f", lambda,
- sample_min, sample_max, lambda));
+ LOG(INFO) << "Range {" << lambda << "}: " << sample_min << ", "
+ << sample_max << ", lambda=" << lambda;
}
std::stringstream ss;
@@ -219,17 +218,16 @@ bool ExponentialDistributionTests::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"
- " lambda=%f\n"
- " mean=%f vs. %f\n"
- " stddev=%f vs. %f\n"
- " skewness=%f vs. %f\n"
- " kurtosis=%f vs. %f\n"
- " z=%f vs. 0",
- p, max_err, lambda(), 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"
+ " lambda=" << lambda() << "\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 << " vs. 0";
+ // clang-format on
}
return pass;
}
@@ -274,16 +272,16 @@ double ExponentialDistributionTests::SingleChiSquaredTest() {
double p = absl::random_internal::ChiSquarePValue(chi_square, dof);
if (chi_square > threshold) {
- for (int i = 0; i < cutoffs.size(); i++) {
- ABSL_INTERNAL_LOG(
- INFO, absl::StrFormat("%d : (%f) = %d", i, cutoffs[i], counts[i]));
+ for (size_t i = 0; i < cutoffs.size(); i++) {
+ LOG(INFO) << i << " : (" << cutoffs[i] << ") = " << counts[i];
}
- ABSL_INTERNAL_LOG(INFO,
- absl::StrCat("lambda ", lambda(), "\n", //
- " expected ", expected, "\n", //
- kChiSquared, " ", chi_square, " (", p, ")\n",
- kChiSquared, " @ 0.98 = ", threshold));
+ // clang-format off
+ LOG(INFO) << "lambda " << lambda() << "\n"
+ " expected " << expected << "\n"
+ << kChiSquared << " " << chi_square << " (" << p << ")\n"
+ << kChiSquared << " @ 0.98 = " << threshold;
+ // clang-format on
}
return p;
}
diff --git a/absl/random/gaussian_distribution_test.cc b/absl/random/gaussian_distribution_test.cc
index 4584ac92..bad3476f 100644
--- a/absl/random/gaussian_distribution_test.cc
+++ b/absl/random/gaussian_distribution_test.cc
@@ -26,8 +26,8 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#include "absl/base/internal/raw_logging.h"
#include "absl/base/macros.h"
+#include "absl/log/log.h"
#include "absl/numeric/internal/representation.h"
#include "absl/random/internal/chi_square.h"
#include "absl/random/internal/distribution_test_util.h"
@@ -116,9 +116,8 @@ TYPED_TEST(GaussianDistributionInterfaceTest, SerializeTest) {
EXPECT_LE(sample, before.max()) << before;
}
if (!std::is_same<TypeParam, long double>::value) {
- ABSL_INTERNAL_LOG(
- INFO, absl::StrFormat("Range{%f, %f}: %f, %f", mean, stddev,
- sample_min, sample_max));
+ LOG(INFO) << "Range{" << mean << ", " << stddev << "}: " << sample_min
+ << ", " << sample_max;
}
std::stringstream ss;
@@ -240,17 +239,16 @@ bool GaussianDistributionTests::SingleZTest(const double p,
(std::pow(m.skewness, 2.0) + std::pow(m.kurtosis - 3.0, 2.0) / 4.0);
if (!pass || jb > 9.21) {
- 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 vs. 0\n"
- " jb=%f vs. 9.21",
- p, max_err, m.mean, mean(), std::sqrt(m.variance),
- stddev(), m.skewness, skew(), m.kurtosis,
- kurtosis(), z, jb));
+ // 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 << " vs. 0\n"
+ " jb=" << jb << " vs. 9.21";
+ // clang-format on
}
return pass;
}
@@ -297,16 +295,16 @@ double GaussianDistributionTests::SingleChiSquaredTest() {
// Log if the chi_square value is above the threshold.
if (chi_square > threshold) {
- for (int i = 0; i < cutoffs.size(); i++) {
- ABSL_INTERNAL_LOG(
- INFO, absl::StrFormat("%d : (%f) = %d", i, cutoffs[i], counts[i]));
+ for (size_t i = 0; i < cutoffs.size(); i++) {
+ LOG(INFO) << i << " : (" << cutoffs[i] << ") = " << counts[i];
}
- ABSL_INTERNAL_LOG(
- INFO, absl::StrCat("mean=", mean(), " stddev=", stddev(), "\n", //
- " expected ", expected, "\n", //
- kChiSquared, " ", chi_square, " (", p, ")\n", //
- kChiSquared, " @ 0.98 = ", threshold));
+ // clang-format off
+ LOG(INFO) << "mean=" << mean() << " stddev=" << stddev() << "\n"
+ " expected " << expected << "\n"
+ << kChiSquared << " " << chi_square << " (" << p << ")\n"
+ << kChiSquared << " @ 0.98 = " << threshold;
+ // clang-format on
}
return p;
}
diff --git a/absl/random/internal/BUILD.bazel b/absl/random/internal/BUILD.bazel
index a51c9375..37f4d6e2 100644
--- a/absl/random/internal/BUILD.bazel
+++ b/absl/random/internal/BUILD.bazel
@@ -601,7 +601,7 @@ cc_test(
deps = [
":explicit_seed_seq",
":randen_engine",
- "//absl/base:raw_logging_internal",
+ "//absl/log",
"//absl/strings",
"//absl/time",
"@com_google_googletest//:gtest_main",
@@ -646,7 +646,7 @@ cc_test(
":platform",
":randen_hwaes",
":randen_hwaes_impl", # build_cleaner: keep
- "//absl/base:raw_logging_internal",
+ "//absl/log",
"//absl/strings:str_format",
"@com_google_googletest//:gtest",
],
@@ -707,8 +707,10 @@ cc_test(
],
deps = [
":nanobenchmark",
- "//absl/base:raw_logging_internal",
+ "//absl/log",
+ "//absl/log:check",
"//absl/strings",
+ "//absl/strings:str_format",
],
)
diff --git a/absl/random/internal/nanobenchmark_test.cc b/absl/random/internal/nanobenchmark_test.cc
index f1571e26..d4f1028d 100644
--- a/absl/random/internal/nanobenchmark_test.cc
+++ b/absl/random/internal/nanobenchmark_test.cc
@@ -14,8 +14,10 @@
#include "absl/random/internal/nanobenchmark.h"
-#include "absl/base/internal/raw_logging.h"
+#include "absl/log/check.h"
+#include "absl/log/log.h"
#include "absl/strings/numbers.h"
+#include "absl/strings/str_format.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
@@ -36,16 +38,16 @@ void MeasureDiv(const FuncInput (&inputs)[N]) {
params.max_evals = 6; // avoid test timeout
const size_t num_results = Measure(&Div, nullptr, inputs, N, results, params);
if (num_results == 0) {
- ABSL_RAW_LOG(
- WARNING,
- "WARNING: Measurement failed, should not happen when using "
- "PinThreadToCPU unless the region to measure takes > 1 second.\n");
+ LOG(WARNING)
+ << "WARNING: Measurement failed, should not happen when using "
+ "PinThreadToCPU unless the region to measure takes > 1 second.";
return;
}
for (size_t i = 0; i < num_results; ++i) {
- ABSL_RAW_LOG(INFO, "%5zu: %6.2f ticks; MAD=%4.2f%%\n", results[i].input,
- results[i].ticks, results[i].variability * 100.0);
- ABSL_RAW_CHECK(results[i].ticks != 0.0f, "Zero duration");
+ LOG(INFO) << absl::StreamFormat("%5u: %6.2f ticks; MAD=%4.2f%%\n",
+ results[i].input, results[i].ticks,
+ results[i].variability * 100.0);
+ CHECK_NE(results[i].ticks, 0.0f) << "Zero duration";
}
}
@@ -54,7 +56,7 @@ void RunAll(const int argc, char* argv[]) {
int cpu = -1;
if (argc == 2) {
if (!absl::SimpleAtoi(argv[1], &cpu)) {
- ABSL_RAW_LOG(FATAL, "The optional argument must be a CPU number >= 0.\n");
+ LOG(FATAL) << "The optional argument must be a CPU number >= 0.";
}
}
PinThreadToCPU(cpu);
diff --git a/absl/random/internal/randen_engine_test.cc b/absl/random/internal/randen_engine_test.cc
index c8e7685b..a94f4916 100644
--- a/absl/random/internal/randen_engine_test.cc
+++ b/absl/random/internal/randen_engine_test.cc
@@ -21,7 +21,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#include "absl/base/internal/raw_logging.h"
+#include "absl/log/log.h"
#include "absl/random/internal/explicit_seed_seq.h"
#include "absl/strings/str_cat.h"
#include "absl/time/clock.h"
@@ -645,9 +645,8 @@ TEST(RandenTest, IsFastOrSlow) {
}
auto duration = absl::GetCurrentTimeNanos() - start;
- ABSL_INTERNAL_LOG(INFO, absl::StrCat(static_cast<double>(duration) /
- static_cast<double>(kCount),
- "ns"));
+ LOG(INFO) << static_cast<double>(duration) / static_cast<double>(kCount)
+ << "ns";
EXPECT_GT(sum, 0);
EXPECT_GE(duration, kCount); // Should be slower than 1ns per call.
diff --git a/absl/random/internal/randen_hwaes_test.cc b/absl/random/internal/randen_hwaes_test.cc
index 2348b55c..00d96efd 100644
--- a/absl/random/internal/randen_hwaes_test.cc
+++ b/absl/random/internal/randen_hwaes_test.cc
@@ -16,7 +16,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#include "absl/base/internal/raw_logging.h"
+#include "absl/log/log.h"
#include "absl/random/internal/platform.h"
#include "absl/random/internal/randen_detect.h"
#include "absl/random/internal/randen_traits.h"
@@ -67,32 +67,32 @@ TEST(RandenHwAesTest, Default) {
int main(int argc, char* argv[]) {
testing::InitGoogleTest(&argc, argv);
- ABSL_RAW_LOG(INFO, "ABSL_HAVE_ACCELERATED_AES=%d", ABSL_HAVE_ACCELERATED_AES);
- ABSL_RAW_LOG(INFO, "ABSL_RANDOM_INTERNAL_AES_DISPATCH=%d",
- ABSL_RANDOM_INTERNAL_AES_DISPATCH);
+ LOG(INFO) << "ABSL_HAVE_ACCELERATED_AES=" << ABSL_HAVE_ACCELERATED_AES;
+ LOG(INFO) << "ABSL_RANDOM_INTERNAL_AES_DISPATCH="
+ << ABSL_RANDOM_INTERNAL_AES_DISPATCH;
#if defined(ABSL_ARCH_X86_64)
- ABSL_RAW_LOG(INFO, "ABSL_ARCH_X86_64");
+ LOG(INFO) << "ABSL_ARCH_X86_64";
#elif defined(ABSL_ARCH_X86_32)
- ABSL_RAW_LOG(INFO, "ABSL_ARCH_X86_32");
+ LOG(INFO) << "ABSL_ARCH_X86_32";
#elif defined(ABSL_ARCH_AARCH64)
- ABSL_RAW_LOG(INFO, "ABSL_ARCH_AARCH64");
+ LOG(INFO) << "ABSL_ARCH_AARCH64";
#elif defined(ABSL_ARCH_ARM)
- ABSL_RAW_LOG(INFO, "ABSL_ARCH_ARM");
+ LOG(INFO) << "ABSL_ARCH_ARM";
#elif defined(ABSL_ARCH_PPC)
- ABSL_RAW_LOG(INFO, "ABSL_ARCH_PPC");
+ LOG(INFO) << "ABSL_ARCH_PPC";
#else
- ABSL_RAW_LOG(INFO, "ARCH Unknown");
+ LOG(INFO) << "ARCH Unknown";
#endif
int x = absl::random_internal::HasRandenHwAesImplementation();
- ABSL_RAW_LOG(INFO, "HasRandenHwAesImplementation = %d", x);
+ LOG(INFO) << "HasRandenHwAesImplementation = " << x;
int y = absl::random_internal::CPUSupportsRandenHwAes();
- ABSL_RAW_LOG(INFO, "CPUSupportsRandenHwAes = %d", x);
+ LOG(INFO) << "CPUSupportsRandenHwAes = " << x;
if (!x || !y) {
- ABSL_RAW_LOG(INFO, "Skipping Randen HWAES tests.");
+ LOG(INFO) << "Skipping Randen HWAES tests.";
return 0;
}
return RUN_ALL_TESTS();
diff --git a/absl/random/log_uniform_int_distribution_test.cc b/absl/random/log_uniform_int_distribution_test.cc
index 0d0fcb95..5df3edac 100644
--- a/absl/random/log_uniform_int_distribution_test.cc
+++ b/absl/random/log_uniform_int_distribution_test.cc
@@ -24,7 +24,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#include "absl/base/internal/raw_logging.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"
@@ -108,8 +108,7 @@ TYPED_TEST(LogUniformIntDistributionTypeTest, SerializeTest) {
if (sample > sample_max) sample_max = sample;
if (sample < sample_min) sample_min = sample;
}
- ABSL_INTERNAL_LOG(INFO,
- absl::StrCat("Range: ", +sample_min, ", ", +sample_max));
+ LOG(INFO) << "Range: " << sample_min << ", " << sample_max;
}
}
@@ -182,16 +181,14 @@ double LogUniformIntChiSquaredTest::ChiSquaredTestImpl() {
const double p = absl::random_internal::ChiSquarePValue(chi_square, dof);
if (chi_square > threshold) {
- ABSL_INTERNAL_LOG(INFO, "values");
+ LOG(INFO) << "values";
for (size_t i = 0; i < buckets.size(); i++) {
- ABSL_INTERNAL_LOG(INFO, absl::StrCat(i, ": ", buckets[i]));
+ LOG(INFO) << i << ": " << buckets[i];
}
- ABSL_INTERNAL_LOG(INFO,
- absl::StrFormat("trials=%d\n"
- "%s(data, %d) = %f (%f)\n"
- "%s @ 0.98 = %f",
- trials, kChiSquared, dof, chi_square, p,
- kChiSquared, threshold));
+ LOG(INFO) << "trials=" << trials << "\n"
+ << kChiSquared << "(data, " << dof << ") = " << chi_square << " ("
+ << p << ")\n"
+ << kChiSquared << " @ 0.98 = " << threshold;
}
return p;
}
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;
}
diff --git a/absl/random/uniform_int_distribution_test.cc b/absl/random/uniform_int_distribution_test.cc
index a830117a..b40d6185 100644
--- a/absl/random/uniform_int_distribution_test.cc
+++ b/absl/random/uniform_int_distribution_test.cc
@@ -24,7 +24,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#include "absl/base/internal/raw_logging.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"
@@ -107,8 +107,7 @@ TYPED_TEST(UniformIntDistributionTest, ParamSerializeTest) {
sample_min = sample;
}
}
- std::string msg = absl::StrCat("Range: ", +sample_min, ", ", +sample_max);
- ABSL_RAW_LOG(INFO, "%s", msg.c_str());
+ LOG(INFO) << "Range: " << sample_min << ", " << sample_max;
}
}
@@ -210,7 +209,7 @@ TYPED_TEST(UniformIntDistributionTest, ChiSquaredTest50) {
absl::StrAppend(&msg, kChiSquared, " p-value ", p_value, "\n");
absl::StrAppend(&msg, "High ", kChiSquared, " value: ", chi_square, " > ",
kThreshold);
- ABSL_RAW_LOG(INFO, "%s", msg.c_str());
+ LOG(INFO) << msg;
FAIL() << msg;
}
}
diff --git a/absl/random/uniform_real_distribution_test.cc b/absl/random/uniform_real_distribution_test.cc
index 07f199d3..260aac96 100644
--- a/absl/random/uniform_real_distribution_test.cc
+++ b/absl/random/uniform_real_distribution_test.cc
@@ -26,7 +26,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#include "absl/base/internal/raw_logging.h"
+#include "absl/log/log.h"
#include "absl/numeric/internal/representation.h"
#include "absl/random/internal/chi_square.h"
#include "absl/random/internal/distribution_test_util.h"
@@ -182,9 +182,8 @@ TYPED_TEST(UniformRealDistributionTest, ParamSerializeTest) {
if (!std::is_same<real_type, long double>::value) {
// static_cast<double>(long double) can overflow.
- std::string msg = absl::StrCat("Range: ", static_cast<double>(sample_min),
- ", ", static_cast<double>(sample_max));
- ABSL_RAW_LOG(INFO, "%s", msg.c_str());
+ LOG(INFO) << "Range: " << static_cast<double>(sample_min) << ", "
+ << static_cast<double>(sample_max);
}
}
}
@@ -324,7 +323,7 @@ TYPED_TEST(UniformRealDistributionTest, ChiSquaredTest50) {
absl::StrAppend(&msg, kChiSquared, " p-value ", p_value, "\n");
absl::StrAppend(&msg, "High ", kChiSquared, " value: ", chi_square, " > ",
kThreshold);
- ABSL_RAW_LOG(INFO, "%s", msg.c_str());
+ LOG(INFO) << msg;
FAIL() << msg;
}
}
diff --git a/absl/random/zipf_distribution_test.cc b/absl/random/zipf_distribution_test.cc
index c8bb89db..801ec4f6 100644
--- a/absl/random/zipf_distribution_test.cc
+++ b/absl/random/zipf_distribution_test.cc
@@ -25,7 +25,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#include "absl/base/internal/raw_logging.h"
+#include "absl/log/log.h"
#include "absl/random/internal/chi_square.h"
#include "absl/random/internal/pcg_engine.h"
#include "absl/random/internal/sequence_urbg.h"
@@ -102,8 +102,7 @@ TYPED_TEST(ZipfDistributionTypedTest, SerializeTest) {
if (sample > sample_max) sample_max = sample;
if (sample < sample_min) sample_min = sample;
}
- ABSL_INTERNAL_LOG(INFO,
- absl::StrCat("Range: ", +sample_min, ", ", +sample_max));
+ LOG(INFO) << "Range: " << sample_min << ", " << sample_max;
}
}
@@ -303,18 +302,15 @@ TEST_P(ZipfTest, ChiSquaredTest) {
// Log if the chi_squared value is above the threshold.
if (chi_square > threshold) {
- ABSL_INTERNAL_LOG(INFO, "values");
+ LOG(INFO) << "values";
for (size_t i = 0; i < expected.size(); i++) {
- ABSL_INTERNAL_LOG(INFO, absl::StrCat(points[i], ": ", buckets[i],
- " vs. E=", expected[i]));
+ LOG(INFO) << points[i] << ": " << buckets[i] << " vs. E=" << expected[i];
}
- ABSL_INTERNAL_LOG(INFO, absl::StrCat("trials ", trials));
- ABSL_INTERNAL_LOG(INFO,
- absl::StrCat("mean ", avg, " vs. expected ", mean()));
- ABSL_INTERNAL_LOG(INFO, absl::StrCat(kChiSquared, "(data, ", dof, ") = ",
- chi_square, " (", p_actual, ")"));
- ABSL_INTERNAL_LOG(INFO,
- absl::StrCat(kChiSquared, " @ 0.9995 = ", threshold));
+ LOG(INFO) << "trials " << trials;
+ LOG(INFO) << "mean " << avg << " vs. expected " << mean();
+ LOG(INFO) << kChiSquared << "(data, " << dof << ") = " << chi_square << " ("
+ << p_actual << ")";
+ LOG(INFO) << kChiSquared << " @ 0.9995 = " << threshold;
FAIL() << kChiSquared << " value of " << chi_square
<< " is above the threshold.";
}