diff options
author | Abseil Team <absl-team@google.com> | 2023-04-18 10:05:16 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-04-18 10:06:01 -0700 |
commit | 2d04ec1da212035cb2dd2576af60db4aa3f7bb72 (patch) | |
tree | dbff2ca6ebe18ddaeb6a6e0de6b8d4b5520604e8 /absl/log/globals_test.cc | |
parent | f36183604eb90bb7a921721e445e6dacff9e25bb (diff) |
Add configurability of the log Tag value on Android
PiperOrigin-RevId: 525178448
Change-Id: I0f35a38f23316b25621148b7fe59becf72bafeff
Diffstat (limited to 'absl/log/globals_test.cc')
-rw-r--r-- | absl/log/globals_test.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/absl/log/globals_test.cc b/absl/log/globals_test.cc index 6710c5aa..f7af47cd 100644 --- a/absl/log/globals_test.cc +++ b/absl/log/globals_test.cc @@ -15,8 +15,6 @@ #include "absl/log/globals.h" -#include <string> - #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/base/attributes.h" @@ -27,6 +25,8 @@ #include "absl/log/scoped_mock_log.h" namespace { +using ::testing::_; +using ::testing::StrEq; auto* test_env ABSL_ATTRIBUTE_UNUSED = ::testing::AddGlobalTestEnvironment( new absl::log_internal::LogTestEnvironment); @@ -88,4 +88,17 @@ TEST(TestGlobals, LogPrefix) { EXPECT_TRUE(absl::ShouldPrependLogPrefix()); } +TEST(TestGlobals, AndroidLogTag) { + // Verify invalid tags result in a check failure. + EXPECT_DEATH_IF_SUPPORTED(absl::SetAndroidNativeTag(nullptr), ".*"); + + // Verify valid tags applied. + EXPECT_THAT(absl::log_internal::GetAndroidNativeTag(), StrEq("native")); + absl::SetAndroidNativeTag("test_tag"); + EXPECT_THAT(absl::log_internal::GetAndroidNativeTag(), StrEq("test_tag")); + + // Verify that additional calls (more than 1) result in a check failure. + EXPECT_DEATH_IF_SUPPORTED(absl::SetAndroidNativeTag("test_tag_fail"), ".*"); +} + } // namespace |