diff options
author | Andy Getzendanner <durandal@google.com> | 2023-05-23 15:46:35 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-05-23 15:47:23 -0700 |
commit | 52747821480e6cadd8b27a0947af5d7933f9dfb4 (patch) | |
tree | cc42f6dc30fa8eca19047efd799c769ead59b6c4 /absl/container | |
parent | 79ca5d7aad63973c83a4962a66ab07cd623131ea (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/container')
-rw-r--r-- | absl/container/BUILD.bazel | 9 | ||||
-rw-r--r-- | absl/container/CMakeLists.txt | 21 | ||||
-rw-r--r-- | absl/container/flat_hash_map_test.cc | 8 | ||||
-rw-r--r-- | absl/container/flat_hash_set_test.cc | 6 | ||||
-rw-r--r-- | absl/container/inlined_vector_test.cc | 6 | ||||
-rw-r--r-- | absl/container/internal/layout_test.cc | 36 | ||||
-rw-r--r-- | absl/container/internal/raw_hash_set_test.cc | 5 |
7 files changed, 44 insertions, 47 deletions
diff --git a/absl/container/BUILD.bazel b/absl/container/BUILD.bazel index 902f6ed3..f22da59a 100644 --- a/absl/container/BUILD.bazel +++ b/absl/container/BUILD.bazel @@ -160,8 +160,8 @@ cc_test( "//absl/base:config", "//absl/base:core_headers", "//absl/base:exception_testing", - "//absl/base:raw_logging_internal", "//absl/hash:hash_testing", + "//absl/log:check", "//absl/memory", "//absl/strings", "@com_google_googletest//:gtest_main", @@ -255,7 +255,7 @@ cc_test( ":unordered_map_lookup_test", ":unordered_map_members_test", ":unordered_map_modifiers_test", - "//absl/base:raw_logging_internal", + "//absl/log:check", "//absl/types:any", "@com_google_googletest//:gtest_main", ], @@ -289,7 +289,7 @@ cc_test( ":unordered_set_lookup_test", ":unordered_set_members_test", ":unordered_set_modifiers_test", - "//absl/base:raw_logging_internal", + "//absl/log:check", "//absl/memory", "//absl/strings", "@com_google_googletest//:gtest_main", @@ -656,7 +656,6 @@ cc_test( "//absl/base:config", "//absl/base:core_headers", "//absl/base:prefetch", - "//absl/base:raw_logging_internal", "//absl/log", "//absl/strings", "@com_google_googletest//:gtest_main", @@ -743,7 +742,7 @@ cc_test( ":layout", "//absl/base:config", "//absl/base:core_headers", - "//absl/base:raw_logging_internal", + "//absl/log:check", "//absl/types:span", "@com_google_googletest//:gtest_main", ], diff --git a/absl/container/CMakeLists.txt b/absl/container/CMakeLists.txt index 3c48270b..39d95e02 100644 --- a/absl/container/CMakeLists.txt +++ b/absl/container/CMakeLists.txt @@ -221,16 +221,16 @@ absl_cc_test( COPTS ${ABSL_TEST_COPTS} DEPS - absl::counting_allocator - absl::inlined_vector - absl::test_instance_tracker + absl::check absl::config absl::core_headers + absl::counting_allocator absl::exception_testing absl::hash_testing + absl::inlined_vector absl::memory - absl::raw_logging_internal absl::strings + absl::test_instance_tracker GTest::gmock_main ) @@ -300,14 +300,14 @@ absl_cc_test( COPTS ${ABSL_TEST_COPTS} DEPS + absl::any + absl::check absl::flat_hash_map absl::hash_generator_testing absl::unordered_map_constructor_test absl::unordered_map_lookup_test absl::unordered_map_members_test absl::unordered_map_modifiers_test - absl::any - absl::raw_logging_internal GTest::gmock_main ) @@ -337,15 +337,15 @@ absl_cc_test( ${ABSL_TEST_COPTS} "-DUNORDERED_SET_CXX17" DEPS + absl::check absl::flat_hash_set absl::hash_generator_testing + absl::memory + absl::strings absl::unordered_set_constructor_test absl::unordered_set_lookup_test absl::unordered_set_members_test absl::unordered_set_modifiers_test - absl::memory - absl::raw_logging_internal - absl::strings GTest::gmock_main ) @@ -742,7 +742,6 @@ absl_cc_test( absl::log absl::prefetch absl::raw_hash_set - absl::raw_logging_internal absl::strings GTest::gmock_main ) @@ -788,9 +787,9 @@ absl_cc_test( ${ABSL_TEST_COPTS} DEPS absl::layout + absl::check absl::config absl::core_headers - absl::raw_logging_internal absl::span GTest::gmock_main ) diff --git a/absl/container/flat_hash_map_test.cc b/absl/container/flat_hash_map_test.cc index 03171f6d..e6acbea2 100644 --- a/absl/container/flat_hash_map_test.cc +++ b/absl/container/flat_hash_map_test.cc @@ -16,12 +16,12 @@ #include <memory> -#include "absl/base/internal/raw_logging.h" #include "absl/container/internal/hash_generator_testing.h" #include "absl/container/internal/unordered_map_constructor_test.h" #include "absl/container/internal/unordered_map_lookup_test.h" #include "absl/container/internal/unordered_map_members_test.h" #include "absl/container/internal/unordered_map_modifiers_test.h" +#include "absl/log/check.h" #include "absl/types/any.h" namespace absl { @@ -40,10 +40,10 @@ struct BeforeMain { BeforeMain() { absl::flat_hash_map<int, int> x; x.insert({1, 1}); - ABSL_RAW_CHECK(x.find(0) == x.end(), "x should not contain 0"); + CHECK(x.find(0) == x.end()) << "x should not contain 0"; auto it = x.find(1); - ABSL_RAW_CHECK(it != x.end(), "x should contain 1"); - ABSL_RAW_CHECK(it->second, "1 should map to 1"); + CHECK(it != x.end()) << "x should contain 1"; + CHECK(it->second) << "1 should map to 1"; } }; const BeforeMain before_main; diff --git a/absl/container/flat_hash_set_test.cc b/absl/container/flat_hash_set_test.cc index b6a72a20..20130f91 100644 --- a/absl/container/flat_hash_set_test.cc +++ b/absl/container/flat_hash_set_test.cc @@ -16,12 +16,12 @@ #include <vector> -#include "absl/base/internal/raw_logging.h" #include "absl/container/internal/hash_generator_testing.h" #include "absl/container/internal/unordered_set_constructor_test.h" #include "absl/container/internal/unordered_set_lookup_test.h" #include "absl/container/internal/unordered_set_members_test.h" #include "absl/container/internal/unordered_set_modifiers_test.h" +#include "absl/log/check.h" #include "absl/memory/memory.h" #include "absl/strings/string_view.h" @@ -42,8 +42,8 @@ struct BeforeMain { BeforeMain() { absl::flat_hash_set<int> x; x.insert(1); - ABSL_RAW_CHECK(!x.contains(0), "x should not contain 0"); - ABSL_RAW_CHECK(x.contains(1), "x should contain 1"); + CHECK(!x.contains(0)) << "x should not contain 0"; + CHECK(x.contains(1)) << "x should contain 1"; } }; const BeforeMain before_main; diff --git a/absl/container/inlined_vector_test.cc b/absl/container/inlined_vector_test.cc index 808f97cc..6f4625dc 100644 --- a/absl/container/inlined_vector_test.cc +++ b/absl/container/inlined_vector_test.cc @@ -31,12 +31,12 @@ #include "gtest/gtest.h" #include "absl/base/attributes.h" #include "absl/base/internal/exception_testing.h" -#include "absl/base/internal/raw_logging.h" #include "absl/base/macros.h" #include "absl/base/options.h" #include "absl/container/internal/counting_allocator.h" #include "absl/container/internal/test_instance_tracker.h" #include "absl/hash/hash_testing.h" +#include "absl/log/check.h" #include "absl/memory/memory.h" #include "absl/strings/str_cat.h" @@ -103,13 +103,13 @@ class RefCounted { } void Ref() const { - ABSL_RAW_CHECK(count_ != nullptr, ""); + CHECK_NE(count_, nullptr); ++(*count_); } void Unref() const { --(*count_); - ABSL_RAW_CHECK(*count_ >= 0, ""); + CHECK_GE(*count_, 0); } int value_; diff --git a/absl/container/internal/layout_test.cc b/absl/container/internal/layout_test.cc index 54e5d5bb..ce599ce7 100644 --- a/absl/container/internal/layout_test.cc +++ b/absl/container/internal/layout_test.cc @@ -26,7 +26,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/base/config.h" -#include "absl/base/internal/raw_logging.h" +#include "absl/log/check.h" #include "absl/types/span.h" namespace absl { @@ -38,7 +38,7 @@ using ::absl::Span; using ::testing::ElementsAre; size_t Distance(const void* from, const void* to) { - ABSL_RAW_CHECK(from <= to, "Distance must be non-negative"); + CHECK_LE(from, to) << "Distance must be non-negative"; return static_cast<const char*>(to) - static_cast<const char*>(from); } @@ -366,7 +366,7 @@ TEST(Layout, Sizes) { } TEST(Layout, PointerByIndex) { - alignas(max_align_t) const unsigned char p[100] = {}; + alignas(max_align_t) const unsigned char p[100] = {0}; { using L = Layout<int32_t>; EXPECT_EQ(0, Distance(p, Type<const int32_t*>(L::Partial().Pointer<0>(p)))); @@ -447,7 +447,7 @@ TEST(Layout, PointerByIndex) { } TEST(Layout, PointerByType) { - alignas(max_align_t) const unsigned char p[100] = {}; + alignas(max_align_t) const unsigned char p[100] = {0}; { using L = Layout<int32_t>; EXPECT_EQ( @@ -526,7 +526,7 @@ TEST(Layout, PointerByType) { } TEST(Layout, MutablePointerByIndex) { - alignas(max_align_t) unsigned char p[100]; + alignas(max_align_t) unsigned char p[100] = {0}; { using L = Layout<int32_t>; EXPECT_EQ(0, Distance(p, Type<int32_t*>(L::Partial().Pointer<0>(p)))); @@ -581,7 +581,7 @@ TEST(Layout, MutablePointerByIndex) { } TEST(Layout, MutablePointerByType) { - alignas(max_align_t) unsigned char p[100]; + alignas(max_align_t) unsigned char p[100] = {0}; { using L = Layout<int32_t>; EXPECT_EQ(0, Distance(p, Type<int32_t*>(L::Partial().Pointer<int32_t>(p)))); @@ -647,7 +647,7 @@ TEST(Layout, MutablePointerByType) { } TEST(Layout, Pointers) { - alignas(max_align_t) const unsigned char p[100] = {}; + alignas(max_align_t) const unsigned char p[100] = {0}; using L = Layout<int8_t, int8_t, Int128>; { const auto x = L::Partial(); @@ -683,7 +683,7 @@ TEST(Layout, Pointers) { } TEST(Layout, MutablePointers) { - alignas(max_align_t) unsigned char p[100]; + alignas(max_align_t) unsigned char p[100] = {0}; using L = Layout<int8_t, int8_t, Int128>; { const auto x = L::Partial(); @@ -716,7 +716,7 @@ TEST(Layout, MutablePointers) { } TEST(Layout, SliceByIndexSize) { - alignas(max_align_t) const unsigned char p[100] = {}; + alignas(max_align_t) const unsigned char p[100] = {0}; { using L = Layout<int32_t>; EXPECT_EQ(0, L::Partial(0).Slice<0>(p).size()); @@ -744,7 +744,7 @@ TEST(Layout, SliceByIndexSize) { } TEST(Layout, SliceByTypeSize) { - alignas(max_align_t) const unsigned char p[100] = {}; + alignas(max_align_t) const unsigned char p[100] = {0}; { using L = Layout<int32_t>; EXPECT_EQ(0, L::Partial(0).Slice<int32_t>(p).size()); @@ -766,7 +766,7 @@ TEST(Layout, SliceByTypeSize) { } TEST(Layout, MutableSliceByIndexSize) { - alignas(max_align_t) unsigned char p[100]; + alignas(max_align_t) unsigned char p[100] = {0}; { using L = Layout<int32_t>; EXPECT_EQ(0, L::Partial(0).Slice<0>(p).size()); @@ -794,7 +794,7 @@ TEST(Layout, MutableSliceByIndexSize) { } TEST(Layout, MutableSliceByTypeSize) { - alignas(max_align_t) unsigned char p[100]; + alignas(max_align_t) unsigned char p[100] = {0}; { using L = Layout<int32_t>; EXPECT_EQ(0, L::Partial(0).Slice<int32_t>(p).size()); @@ -816,7 +816,7 @@ TEST(Layout, MutableSliceByTypeSize) { } TEST(Layout, SliceByIndexData) { - alignas(max_align_t) const unsigned char p[100] = {}; + alignas(max_align_t) const unsigned char p[100] = {0}; { using L = Layout<int32_t>; EXPECT_EQ( @@ -939,7 +939,7 @@ TEST(Layout, SliceByIndexData) { } TEST(Layout, SliceByTypeData) { - alignas(max_align_t) const unsigned char p[100] = {}; + alignas(max_align_t) const unsigned char p[100] = {0}; { using L = Layout<int32_t>; EXPECT_EQ( @@ -1037,7 +1037,7 @@ TEST(Layout, SliceByTypeData) { } TEST(Layout, MutableSliceByIndexData) { - alignas(max_align_t) unsigned char p[100]; + alignas(max_align_t) unsigned char p[100] = {0}; { using L = Layout<int32_t>; EXPECT_EQ( @@ -1122,7 +1122,7 @@ TEST(Layout, MutableSliceByIndexData) { } TEST(Layout, MutableSliceByTypeData) { - alignas(max_align_t) unsigned char p[100]; + alignas(max_align_t) unsigned char p[100] = {0}; { using L = Layout<int32_t>; EXPECT_EQ( @@ -1268,7 +1268,7 @@ testing::PolymorphicMatcher<TupleMatcher<M...>> Tuple(M... matchers) { } TEST(Layout, Slices) { - alignas(max_align_t) const unsigned char p[100] = {}; + alignas(max_align_t) const unsigned char p[100] = {0}; using L = Layout<int8_t, int8_t, Int128>; { const auto x = L::Partial(); @@ -1302,7 +1302,7 @@ TEST(Layout, Slices) { } TEST(Layout, MutableSlices) { - alignas(max_align_t) unsigned char p[100] = {}; + alignas(max_align_t) unsigned char p[100] = {0}; using L = Layout<int8_t, int8_t, Int128>; { const auto x = L::Partial(); diff --git a/absl/container/internal/raw_hash_set_test.cc b/absl/container/internal/raw_hash_set_test.cc index c46a5939..ce1070ba 100644 --- a/absl/container/internal/raw_hash_set_test.cc +++ b/absl/container/internal/raw_hash_set_test.cc @@ -40,7 +40,6 @@ #include "absl/base/attributes.h" #include "absl/base/config.h" #include "absl/base/internal/cycleclock.h" -#include "absl/base/internal/raw_logging.h" #include "absl/base/prefetch.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" @@ -1280,7 +1279,7 @@ ExpectedStats XorSeedExpectedStats() { {{0.95, 0}, {0.99, 1}, {0.999, 4}, {0.9999, 10}}}; } } - ABSL_RAW_LOG(FATAL, "%s", "Unknown Group width"); + LOG(FATAL) << "Unknown Group width"; return {}; } @@ -1376,7 +1375,7 @@ ExpectedStats LinearTransformExpectedStats() { {{0.95, 0}, {0.99, 1}, {0.999, 6}, {0.9999, 10}}}; } } - ABSL_RAW_LOG(FATAL, "%s", "Unknown Group width"); + LOG(FATAL) << "Unknown Group width"; return {}; } |