diff options
author | Andy Getzendanner <durandal@google.com> | 2023-01-13 01:22:59 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-01-13 01:23:57 -0800 |
commit | bb63a76710554cebbeb20306739a7b832be38c4a (patch) | |
tree | 8ba428e9cb17d9e766c89bc97c625f5f5d075b67 /absl/log/log_format_test.cc | |
parent | 49081b8d71e4e60667110dd085f3cb8c3f554c8a (diff) | |
download | abseil-bb63a76710554cebbeb20306739a7b832be38c4a.tar.gz abseil-bb63a76710554cebbeb20306739a7b832be38c4a.tar.bz2 abseil-bb63a76710554cebbeb20306739a7b832be38c4a.zip |
Use NullGuard for signed and unsigned char pointer types, and extend volatile pointer type testcase to char pointers.
PiperOrigin-RevId: 501781539
Change-Id: I99012cecd960745de8a921b96671cde42e28a3af
Diffstat (limited to 'absl/log/log_format_test.cc')
-rw-r--r-- | absl/log/log_format_test.cc | 23 |
1 files changed, 14 insertions, 9 deletions
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 <typename T> -class VolatileVoidPtrLogFormatTest : public testing::Test {}; -using VolatileVoidPtrTypes = Types<volatile void *, const volatile void *>; -TYPED_TEST_SUITE(VolatileVoidPtrLogFormatTest, VolatileVoidPtrTypes); +class VolatilePtrLogFormatTest : public testing::Test {}; +using VolatilePtrTypes = + Types<volatile void*, const volatile void*, volatile char*, + const volatile char*, volatile signed char*, + const volatile signed char*, volatile unsigned char*, + const volatile unsigned char*>; +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<TypeParam>(0xdeadbeefLL); @@ -707,7 +711,8 @@ TYPED_TEST(VolatileVoidPtrLogFormatTest, NonNull) { template <typename T> class CharPtrLogFormatTest : public testing::Test {}; -using CharPtrTypes = Types<char *, const char *>; +using CharPtrTypes = Types<char, const char, signed char, const signed char, + unsigned char, const unsigned char>; 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; |