From d4fd79a434186f04781da7c168fff848d9a4102d Mon Sep 17 00:00:00 2001 From: bmeurer Date: Mon, 26 Jan 2015 22:58:39 -0800 Subject: [PATCH] Don't use internal gmock helper classes. BUG=v8:3835 LOG=n Review URL: https://codereview.chromium.org/881653003 Cr-Commit-Position: refs/heads/master@{#26282} --- testing/gmock-support.h | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/testing/gmock-support.h b/testing/gmock-support.h index 012775b..d00468e 100644 --- a/testing/gmock-support.h +++ b/testing/gmock-support.h @@ -7,6 +7,7 @@ #include #include +#include #include "testing/gmock/include/gmock/gmock.h" @@ -34,25 +35,6 @@ class Capture { namespace internal { -struct AnyBitEq { - template - bool operator()(A const& a, B const& b) const { - if (sizeof(A) != sizeof(B)) return false; - return std::memcmp(&a, &b, sizeof(A)) == 0; - } -}; - - -template -class BitEqMatcher : public ComparisonBase, Rhs, AnyBitEq> { - public: - explicit BitEqMatcher(Rhs const& rhs) - : ComparisonBase, Rhs, AnyBitEq>(rhs) {} - static const char* Desc() { return "is bitwise equal to"; } - static const char* NegatedDesc() { return "isn't bitwise equal to"; } -}; - - template class CaptureEqMatcher : public MatcherInterface { public: @@ -83,10 +65,11 @@ class CaptureEqMatcher : public MatcherInterface { // Creates a polymorphic matcher that matches anything whose bit representation -// is equal to that of x. -template -inline internal::BitEqMatcher BitEq(T const& x) { - return internal::BitEqMatcher(x); +// is equal to that of {x}. +MATCHER_P(BitEq, x, std::string(negation ? "isn't" : "is") + + " bitwise equal to " + PrintToString(x)) { + static_assert(sizeof(x) == sizeof(arg), "Size mismatch"); + return std::memcmp(&arg, &x, sizeof(x)) == 0; } -- 2.7.4