19 #ifndef PAGESPEED_KERNEL_BASE_PROTO_MATCHER_IMPL_H_
20 #define PAGESPEED_KERNEL_BASE_PROTO_MATCHER_IMPL_H_
24 #include "base/logging.h"
30 #include "google/protobuf/util/message_differencer.h"
31 #include "gmock/gmock-matchers.h"
33 using google::protobuf::util::MessageDifferencer;
36 namespace net_instaweb {
41 : expected_proto_str_(str) {}
43 template <
typename Proto>
44 bool MatchAndExplain(
const Proto& actual_proto,
45 testing::MatchResultListener* )
const {
46 std::unique_ptr<Proto> expected_proto(actual_proto.New());
47 CHECK(ParseTextFormatProtoFromString(expected_proto_str_,
48 expected_proto.get()));
49 return MessageDifferencer::Equals(*expected_proto, actual_proto);
52 void DescribeTo(::std::ostream* os)
const {
53 *os <<
"matches proto: " << expected_proto_str_;
56 void DescribeNegationTo(::std::ostream* os)
const {
57 *os <<
"does not match proto: " << expected_proto_str_;
64 inline testing::PolymorphicMatcher<EqualsProtoMatcher>
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Definition: proto_matcher_impl.h:38