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
9d580ea8
Commit
9d580ea8
authored
Apr 19, 2020
by
Igor Nazarenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable protobuf printing for open-source proto messages.
parent
dcc92d0a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
gtest-internal.h
googletest/include/gtest/internal/gtest-internal.h
+13
-2
gtest_unittest.cc
googletest/test/gtest_unittest.cc
+4
-0
No files found.
googletest/include/gtest/internal/gtest-internal.h
View file @
9d580ea8
...
@@ -94,6 +94,12 @@ namespace proto2 {
...
@@ -94,6 +94,12 @@ namespace proto2 {
class
MessageLite
;
class
MessageLite
;
}
}
namespace
google
{
namespace
protobuf
{
class
MessageLite
;
}
}
namespace
testing
{
namespace
testing
{
// Forward declarations.
// Forward declarations.
...
@@ -881,10 +887,15 @@ class GTEST_API_ Random {
...
@@ -881,10 +887,15 @@ class GTEST_API_ Random {
typename std::remove_const<typename std::remove_reference<T>::type>::type
typename std::remove_const<typename std::remove_reference<T>::type>::type
// IsAProtocolMessage<T>::value is a compile-time bool constant that's
// IsAProtocolMessage<T>::value is a compile-time bool constant that's
// true if and only if T is type proto2::MessageLite or a subclass of it.
// true if and only if T is type proto2::MessageLite or
// google::protobuf::MessageLite or a subclass of one of them.
template
<
typename
T
>
template
<
typename
T
>
struct
IsAProtocolMessage
struct
IsAProtocolMessage
:
public
std
::
is_convertible
<
const
T
*
,
const
::
proto2
::
MessageLite
*>
{};
:
public
std
::
integral_constant
<
bool
,
std
::
is_convertible
<
const
T
*
,
const
::
proto2
::
MessageLite
*>::
value
||
std
::
is_convertible
<
const
T
*
,
const
::
google
::
protobuf
::
MessageLite
*>::
value
>
{};
// When the compiler sees expression IsContainerTest<C>(0), if C is an
// When the compiler sees expression IsContainerTest<C>(0), if C is an
// STL-style container class, the first overload of IsContainerTest
// STL-style container class, the first overload of IsContainerTest
...
...
googletest/test/gtest_unittest.cc
View file @
9d580ea8
...
@@ -7115,6 +7115,10 @@ TEST(IsAProtocolMessageTest, ValueIsTrueWhenTypeIsAProtocolMessage) {
...
@@ -7115,6 +7115,10 @@ TEST(IsAProtocolMessageTest, ValueIsTrueWhenTypeIsAProtocolMessage) {
EXPECT_TRUE
(
IsAProtocolMessage
<::
proto2
::
MessageLite
>::
value
);
EXPECT_TRUE
(
IsAProtocolMessage
<::
proto2
::
MessageLite
>::
value
);
}
}
TEST
(
IsAProtocolMessageTest
,
ValueIsTrueWhenTypeIsAnOpenSourceProtocolMessage
)
{
EXPECT_TRUE
(
IsAProtocolMessage
<::
google
::
protobuf
::
MessageLite
>::
value
);
}
// Tests that IsAProtocolMessage<T>::value is false when T is neither
// Tests that IsAProtocolMessage<T>::value is false when T is neither
// ::proto2::Message nor a sub-class of it.
// ::proto2::Message nor a sub-class of it.
TEST
(
IsAProtocolMessageTest
,
ValueIsFalseWhenTypeIsNotAProtocolMessage
)
{
TEST
(
IsAProtocolMessageTest
,
ValueIsFalseWhenTypeIsNotAProtocolMessage
)
{
...
...
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