diff options
author | Abseil Team <absl-team@google.com> | 2023-10-02 10:09:34 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-10-02 10:10:25 -0700 |
commit | 302d851a06072a581961970c1e120c2af7b70482 (patch) | |
tree | b100bf8dffd45e44b3d406741f599cbfbaff7c7f /absl/debugging/internal/demangle_test.cc | |
parent | 44e8609e7ee6ba85ca7bca43fdef51618a806405 (diff) |
Re-submit with a fix for platforms without RTTI.
We test for `ABSL_INTERNAL_HAS_RTTI` in `absl::container_internal::TypeName` before calling `typeid`.
PiperOrigin-RevId: 570101013
Change-Id: I1f2f9b2f475a6beae50d0b88718b17b296311155
Diffstat (limited to 'absl/debugging/internal/demangle_test.cc')
-rw-r--r-- | absl/debugging/internal/demangle_test.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc index 71bc237a..a16ab75e 100644 --- a/absl/debugging/internal/demangle_test.cc +++ b/absl/debugging/internal/demangle_test.cc @@ -17,6 +17,7 @@ #include <cstdlib> #include <string> +#include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/base/config.h" #include "absl/debugging/internal/stack_consumption.h" @@ -28,6 +29,8 @@ ABSL_NAMESPACE_BEGIN namespace debugging_internal { namespace { +using ::testing::ContainsRegex; + // Test corner cases of boundary conditions. TEST(Demangle, CornerCases) { char tmp[10]; @@ -227,6 +230,25 @@ TEST(DemangleRegression, DeeplyNestedArrayType) { TestOnInput(data.c_str()); } +struct Base { + virtual ~Base() = default; +}; + +struct Derived : public Base {}; + +TEST(DemangleStringTest, SupportsSymbolNameReturnedByTypeId) { + EXPECT_EQ(DemangleString(typeid(int).name()), "int"); + // We want to test that `DemangleString` can demangle the symbol names + // returned by `typeid`, but without hard-coding the actual demangled values + // (because they are platform-specific). + EXPECT_THAT( + DemangleString(typeid(Base).name()), + ContainsRegex("absl.*debugging_internal.*anonymous namespace.*::Base")); + EXPECT_THAT(DemangleString(typeid(Derived).name()), + ContainsRegex( + "absl.*debugging_internal.*anonymous namespace.*::Derived")); +} + } // namespace } // namespace debugging_internal ABSL_NAMESPACE_END |