Googletest export

This change updates testing::internal::IsAProtocolMessage to return true not
just for full proto messages but also for lite ones (i.e. those inheriting
directly from MessageLite).

PiperOrigin-RevId: 304286535
This commit is contained in:
Abseil Team 2020-04-01 19:33:24 -04:00 committed by Andy Getz
parent 61f010d703
commit c344cb5a8d
2 changed files with 7 additions and 5 deletions

View File

@ -90,7 +90,9 @@
#define GTEST_STRINGIFY_HELPER_(name, ...) #name #define GTEST_STRINGIFY_HELPER_(name, ...) #name
#define GTEST_STRINGIFY_(...) GTEST_STRINGIFY_HELPER_(__VA_ARGS__, ) #define GTEST_STRINGIFY_(...) GTEST_STRINGIFY_HELPER_(__VA_ARGS__, )
namespace proto2 { class Message; } namespace proto2 {
class MessageLite;
}
namespace testing { namespace testing {
@ -879,10 +881,10 @@ 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::Message or a subclass of it. // true if and only if T is type proto2::MessageLite or a subclass of it.
template <typename T> template <typename T>
struct IsAProtocolMessage struct IsAProtocolMessage
: public std::is_convertible<const T*, const ::proto2::Message*> {}; : public std::is_convertible<const T*, const ::proto2::MessageLite*> {};
// 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

View File

@ -7104,7 +7104,7 @@ class ConversionHelperDerived : public ConversionHelperBase {};
// Tests that IsAProtocolMessage<T>::value is a compile-time constant. // Tests that IsAProtocolMessage<T>::value is a compile-time constant.
TEST(IsAProtocolMessageTest, ValueIsCompileTimeConstant) { TEST(IsAProtocolMessageTest, ValueIsCompileTimeConstant) {
GTEST_COMPILE_ASSERT_(IsAProtocolMessage<::proto2::Message>::value, GTEST_COMPILE_ASSERT_(IsAProtocolMessage<::proto2::MessageLite>::value,
const_true); const_true);
GTEST_COMPILE_ASSERT_(!IsAProtocolMessage<int>::value, const_false); GTEST_COMPILE_ASSERT_(!IsAProtocolMessage<int>::value, const_false);
} }
@ -7112,7 +7112,7 @@ TEST(IsAProtocolMessageTest, ValueIsCompileTimeConstant) {
// Tests that IsAProtocolMessage<T>::value is true when T is // Tests that IsAProtocolMessage<T>::value is true when T is
// proto2::Message or a sub-class of it. // proto2::Message or a sub-class of it.
TEST(IsAProtocolMessageTest, ValueIsTrueWhenTypeIsAProtocolMessage) { TEST(IsAProtocolMessageTest, ValueIsTrueWhenTypeIsAProtocolMessage) {
EXPECT_TRUE(IsAProtocolMessage< ::proto2::Message>::value); EXPECT_TRUE(IsAProtocolMessage<::proto2::MessageLite>::value);
} }
// Tests that IsAProtocolMessage<T>::value is false when T is neither // Tests that IsAProtocolMessage<T>::value is false when T is neither