Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
c3792825
Commit
c3792825
authored
Nov 08, 2021
by
Abseil Team
Committed by
dinord
Nov 09, 2021
Browse files
Googletest export
Add printer for std::type_info. PiperOrigin-RevId: 408375407
parent
d4e084a1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
googletest/include/gtest/gtest-printers.h
googletest/include/gtest/gtest-printers.h
+6
-0
googletest/test/googletest-printers-test.cc
googletest/test/googletest-printers-test.cc
+10
-0
No files found.
googletest/include/gtest/gtest-printers.h
View file @
c3792825
...
...
@@ -591,6 +591,12 @@ inline void PrintTo(internal::StringView sp, ::std::ostream* os) {
inline
void
PrintTo
(
std
::
nullptr_t
,
::
std
::
ostream
*
os
)
{
*
os
<<
"(nullptr)"
;
}
#if GTEST_HAS_RTTI
inline
void
PrintTo
(
const
std
::
type_info
&
info
,
std
::
ostream
*
os
)
{
*
os
<<
internal
::
GetTypeName
(
info
);
}
#endif // GTEST_HAS_RTTI
template
<
typename
T
>
void
PrintTo
(
std
::
reference_wrapper
<
T
>
ref
,
::
std
::
ostream
*
os
)
{
UniversalPrinter
<
T
&>::
Print
(
ref
.
get
(),
os
);
...
...
googletest/test/googletest-printers-test.cc
View file @
c3792825
...
...
@@ -473,6 +473,16 @@ TEST(PrintBuiltInTypeTest, FloatingPoints) {
EXPECT_EQ
(
"-2.5"
,
Print
(
-
2.5
));
// double
}
#if GTEST_HAS_RTTI
TEST
(
PrintBuiltInTypeTest
,
TypeInfo
)
{
struct
MyStruct
{};
auto
res
=
Print
(
typeid
(
MyStruct
{}));
// We can't guarantee that we can demangle the name, but either name should
// contain the substring "MyStruct".
EXPECT_NE
(
res
.
find
(
"MyStruct"
),
res
.
npos
)
<<
res
;
}
#endif // GTEST_HAS_RTTI
// Since ::std::stringstream::operator<<(const void *) formats the pointer
// output differently with different compilers, we have to create the expected
// output first and use it as our expectation.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment