34#ifndef GOOGLEMOCK_TEST_GMOCK_MATCHERS_TEST_H_
35#define GOOGLEMOCK_TEST_GMOCK_MATCHERS_TEST_H_
43#include <forward_list>
55#include <unordered_map>
56#include <unordered_set>
60#include "gmock/gmock-matchers.h"
61#include "gmock/gmock-more-matchers.h"
62#include "gmock/gmock.h"
63#include "gtest/gtest-spi.h"
64#include "gtest/gtest.h"
67namespace gmock_matchers_test {
79using std::stringstream;
81using testing::internal::DummyMatchResultListener;
82using testing::internal::ElementMatcherPair;
83using testing::internal::ElementMatcherPairs;
84using testing::internal::ElementsAreArrayMatcher;
85using testing::internal::ExplainMatchFailureTupleTo;
86using testing::internal::FloatingEqMatcher;
87using testing::internal::FormatMatcherDescription;
88using testing::internal::IsReadableTypeName;
89using testing::internal::MatchMatrix;
90using testing::internal::PredicateFormatterFromMatcher;
92using testing::internal::StreamMatchResultListener;
93using testing::internal::Strings;
99 MOCK_METHOD1(Call,
void(std::vector<std::unique_ptr<int>>));
105 using is_gtest_matcher = void;
107 void DescribeTo(ostream* os)
const { *os <<
"is > " << rhs; }
108 void DescribeNegationTo(ostream* os)
const { *os <<
"is <= " << rhs; }
110 bool MatchAndExplain(T lhs, MatchResultListener* listener)
const {
112 *listener <<
"which is " << (lhs - rhs) <<
" more than " << rhs;
113 }
else if (lhs == rhs) {
114 *listener <<
"which is the same as " << rhs;
116 *listener <<
"which is " << (rhs - lhs) <<
" less than " << rhs;
137 void DescribeTo(ostream* os)
const override { impl_.DescribeTo(os); }
138 void DescribeNegationTo(ostream* os)
const override {
139 impl_.DescribeNegationTo(os);
142 bool MatchAndExplain(T lhs, MatchResultListener* listener)
const override {
143 return impl_.MatchAndExplain(lhs, listener);
151#define INSTANTIATE_GTEST_MATCHER_TEST_P(TestSuite) \
152 using TestSuite##P = GTestMatcherTestP; \
153 INSTANTIATE_TEST_SUITE_P(MatcherInterface, TestSuite##P, Values(false)); \
154 INSTANTIATE_TEST_SUITE_P(GtestMatcher, TestSuite##P, Values(true))
158 template <
typename T>
160 if (use_gtest_matcher_) {
161 return GtestGreaterThan(n);
166 const bool use_gtest_matcher_ = GetParam();
172 return DescribeMatcher<T>(m);
177std::string DescribeNegation(
const Matcher<T>& m) {
178 return DescribeMatcher<T>(m,
true);
182template <
typename MatcherType,
typename Value>
183std::string Explain(
const MatcherType& m,
const Value& x) {
184 StringMatchResultListener listener;
185 ExplainMatchResult(m, x, &listener);
186 return listener.str();
Definition gmock-internal-utils.h:55
Definition gmock-matchers_test.h:156
Definition gmock-matchers_test.h:133
Definition gtest-port.h:894
Definition gmock-matchers_test.h:98
Definition gmock-matchers_test.h:104