Merge pull request #2818 from inazarenko:master
PiperOrigin-RevId: 308650221
This commit is contained in:
commit
b99b421d8d
@ -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 {
|
|||||||
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
|
||||||
|
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user