From bb63a76710554cebbeb20306739a7b832be38c4a Mon Sep 17 00:00:00 2001 From: Andy Getzendanner Date: Fri, 13 Jan 2023 01:22:59 -0800 Subject: Use NullGuard for signed and unsigned char pointer types, and extend volatile pointer type testcase to char pointers. PiperOrigin-RevId: 501781539 Change-Id: I99012cecd960745de8a921b96671cde42e28a3af --- absl/log/log_format_test.cc | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'absl/log/log_format_test.cc') diff --git a/absl/log/log_format_test.cc b/absl/log/log_format_test.cc index 69bdf8d8..dbad5d97 100644 --- a/absl/log/log_format_test.cc +++ b/absl/log/log_format_test.cc @@ -665,11 +665,15 @@ TYPED_TEST(VoidPtrLogFormatTest, NonNull) { } template -class VolatileVoidPtrLogFormatTest : public testing::Test {}; -using VolatileVoidPtrTypes = Types; -TYPED_TEST_SUITE(VolatileVoidPtrLogFormatTest, VolatileVoidPtrTypes); +class VolatilePtrLogFormatTest : public testing::Test {}; +using VolatilePtrTypes = + Types; +TYPED_TEST_SUITE(VolatilePtrLogFormatTest, VolatilePtrTypes); -TYPED_TEST(VolatileVoidPtrLogFormatTest, Null) { +TYPED_TEST(VolatilePtrLogFormatTest, Null) { absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected); const TypeParam value = nullptr; @@ -687,7 +691,7 @@ TYPED_TEST(VolatileVoidPtrLogFormatTest, Null) { LOG(INFO) << value; } -TYPED_TEST(VolatileVoidPtrLogFormatTest, NonNull) { +TYPED_TEST(VolatilePtrLogFormatTest, NonNull) { absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected); const TypeParam value = reinterpret_cast(0xdeadbeefLL); @@ -707,7 +711,8 @@ TYPED_TEST(VolatileVoidPtrLogFormatTest, NonNull) { template class CharPtrLogFormatTest : public testing::Test {}; -using CharPtrTypes = Types; +using CharPtrTypes = Types; TYPED_TEST_SUITE(CharPtrLogFormatTest, CharPtrTypes); TYPED_TEST(CharPtrLogFormatTest, Null) { @@ -717,7 +722,7 @@ TYPED_TEST(CharPtrLogFormatTest, Null) { // standard library implementations choose to crash. We take measures to log // something useful instead of crashing, even when that differs from the // standard library in use (and thus the behavior of `std::ostream`). - const TypeParam value = nullptr; + TypeParam* const value = nullptr; EXPECT_CALL( test_sink, @@ -733,8 +738,8 @@ TYPED_TEST(CharPtrLogFormatTest, Null) { TYPED_TEST(CharPtrLogFormatTest, NonNull) { absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected); - char data[] = "value"; - const TypeParam value = data; + TypeParam data[] = {'v', 'a', 'l', 'u', 'e', '\0'}; + TypeParam* const value = data; auto comparison_stream = ComparisonStream(); comparison_stream << value; -- cgit v1.2.3