diff options
author | Igor Nazarenko <igor.n.nazarenko@gmail.com> | 2020-04-19 17:30:50 -0700 |
---|---|---|
committer | Igor Nazarenko <igor.n.nazarenko@gmail.com> | 2020-04-19 17:30:50 -0700 |
commit | 9d580ea80592189e6d44fa35bcf9cdea8bf620d6 (patch) | |
tree | f39ac4ef9a4f6195851231ea52185f8d5f63c37b | |
parent | dcc92d0ab6c4ce022162a23566d44f673251eee4 (diff) | |
download | googletest-9d580ea80592189e6d44fa35bcf9cdea8bf620d6.tar.gz googletest-9d580ea80592189e6d44fa35bcf9cdea8bf620d6.tar.bz2 googletest-9d580ea80592189e6d44fa35bcf9cdea8bf620d6.zip |
Enable protobuf printing for open-source proto messages.
-rw-r--r-- | googletest/include/gtest/internal/gtest-internal.h | 15 | ||||
-rw-r--r-- | googletest/test/gtest_unittest.cc | 4 |
2 files changed, 17 insertions, 2 deletions
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index 7f1a5b00..c36029ee 100644 --- a/googletest/include/gtest/internal/gtest-internal.h +++ b/googletest/include/gtest/internal/gtest-internal.h @@ -94,6 +94,12 @@ namespace proto2 { class MessageLite; } +namespace google { +namespace protobuf { +class MessageLite; +} +} + namespace testing { // Forward declarations. @@ -881,10 +887,15 @@ class GTEST_API_ Random { typename std::remove_const<typename std::remove_reference<T>::type>::type // 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> 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 // STL-style container class, the first overload of IsContainerTest diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 005a2d40..631180e3 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -7115,6 +7115,10 @@ TEST(IsAProtocolMessageTest, ValueIsTrueWhenTypeIsAProtocolMessage) { 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 // ::proto2::Message nor a sub-class of it. TEST(IsAProtocolMessageTest, ValueIsFalseWhenTypeIsNotAProtocolMessage) { |