Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
8567b092
Commit
8567b092
authored
Jun 12, 2020
by
dmauro
Committed by
vslashg
Jun 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Googletest export
Adds support for printing pointers of types char8_t, char16_t, and char32_t. PiperOrigin-RevId: 316112767
parent
13a433a9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
0 deletions
+70
-0
gtest-printers.h
googletest/include/gtest/gtest-printers.h
+20
-0
googletest-printers-test.cc
googletest/test/googletest-printers-test.cc
+50
-0
No files found.
googletest/include/gtest/gtest-printers.h
View file @
8567b092
...
...
@@ -499,6 +499,26 @@ inline void PrintTo(const unsigned char* s, ::std::ostream* os) {
inline
void
PrintTo
(
unsigned
char
*
s
,
::
std
::
ostream
*
os
)
{
PrintTo
(
ImplicitCast_
<
const
void
*>
(
s
),
os
);
}
#ifdef __cpp_char8_t
inline
void
PrintTo
(
const
char8_t
*
s
,
::
std
::
ostream
*
os
)
{
PrintTo
(
ImplicitCast_
<
const
void
*>
(
s
),
os
);
}
inline
void
PrintTo
(
char8_t
*
s
,
::
std
::
ostream
*
os
)
{
PrintTo
(
ImplicitCast_
<
const
void
*>
(
s
),
os
);
}
#endif
inline
void
PrintTo
(
const
char16_t
*
s
,
::
std
::
ostream
*
os
)
{
PrintTo
(
ImplicitCast_
<
const
void
*>
(
s
),
os
);
}
inline
void
PrintTo
(
char16_t
*
s
,
::
std
::
ostream
*
os
)
{
PrintTo
(
ImplicitCast_
<
const
void
*>
(
s
),
os
);
}
inline
void
PrintTo
(
const
char32_t
*
s
,
::
std
::
ostream
*
os
)
{
PrintTo
(
ImplicitCast_
<
const
void
*>
(
s
),
os
);
}
inline
void
PrintTo
(
char32_t
*
s
,
::
std
::
ostream
*
os
)
{
PrintTo
(
ImplicitCast_
<
const
void
*>
(
s
),
os
);
}
// MSVC can be configured to define wchar_t as a typedef of unsigned
// short. It defines _NATIVE_WCHAR_T_DEFINED when wchar_t is a native
...
...
googletest/test/googletest-printers-test.cc
View file @
8567b092
...
...
@@ -513,6 +513,56 @@ TEST(PrintCharPointerTest, ConstUnsignedChar) {
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
#ifdef __cpp_char8_t
// char8_t*
TEST
(
PrintCharPointerTest
,
Char8
)
{
char8_t
*
p
=
reinterpret_cast
<
char8_t
*>
(
0x1234
);
EXPECT_EQ
(
PrintPointer
(
p
),
Print
(
p
));
p
=
nullptr
;
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
// const char8_t*
TEST
(
PrintCharPointerTest
,
ConstChar8
)
{
const
char8_t
*
p
=
reinterpret_cast
<
const
char8_t
*>
(
0x1234
);
EXPECT_EQ
(
PrintPointer
(
p
),
Print
(
p
));
p
=
nullptr
;
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
#endif
// char16_t*
TEST
(
PrintCharPointerTest
,
Char16
)
{
char16_t
*
p
=
reinterpret_cast
<
char16_t
*>
(
0x1234
);
EXPECT_EQ
(
PrintPointer
(
p
),
Print
(
p
));
p
=
nullptr
;
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
// const char16_t*
TEST
(
PrintCharPointerTest
,
ConstChar16
)
{
const
char16_t
*
p
=
reinterpret_cast
<
const
char16_t
*>
(
0x1234
);
EXPECT_EQ
(
PrintPointer
(
p
),
Print
(
p
));
p
=
nullptr
;
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
// char32_t*
TEST
(
PrintCharPointerTest
,
Char32
)
{
char32_t
*
p
=
reinterpret_cast
<
char32_t
*>
(
0x1234
);
EXPECT_EQ
(
PrintPointer
(
p
),
Print
(
p
));
p
=
nullptr
;
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
// const char32_t*
TEST
(
PrintCharPointerTest
,
ConstChar32
)
{
const
char32_t
*
p
=
reinterpret_cast
<
const
char32_t
*>
(
0x1234
);
EXPECT_EQ
(
PrintPointer
(
p
),
Print
(
p
));
p
=
nullptr
;
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
// Tests printing pointers to simple, built-in types.
// bool*.
...
...
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