HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Oreo
|
8.0.0_r4
下载
查看原文件
收藏
根目录
external
googletest
googlemock
include
gmock
gmock-generated-matchers.h
// This file was GENERATED by command: // pump.py gmock-generated-matchers.h.pump // DO NOT EDIT BY HAND!!! // Copyright 2008, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Google Mock - a framework for writing C++ mock classes. // // This file implements some commonly used variadic matchers. #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_ #include
#include
#include
#include
#include "gmock/gmock-matchers.h" namespace testing { namespace internal { // The type of the i-th (0-based) field of Tuple. #define GMOCK_FIELD_TYPE_(Tuple, i) \ typename ::testing::tuple_element
::type // TupleFields
is for selecting fields from a // tuple of type Tuple. It has two members: // // type: a tuple type whose i-th field is the ki-th field of Tuple. // GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple. // // For example, in class TupleFields
, 2, 0>, we have: // // type is tuple
, and // GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true). template
class TupleFields; // This generic version is used when there are 10 selectors. template
class TupleFields { public: typedef ::testing::tuple
type; static type GetSelectedFields(const Tuple& t) { return type(get
(t), get
(t), get
(t), get
(t), get
(t), get
(t), get
(t), get
(t), get
(t), get
(t)); } }; // The following specialization is used for 0 ~ 9 selectors. template
class TupleFields
{ public: typedef ::testing::tuple<> type; static type GetSelectedFields(const Tuple& /* t */) { return type(); } }; template
class TupleFields
{ public: typedef ::testing::tuple
type; static type GetSelectedFields(const Tuple& t) { return type(get
(t)); } }; template
class TupleFields
{ public: typedef ::testing::tuple
type; static type GetSelectedFields(const Tuple& t) { return type(get
(t), get
(t)); } }; template
class TupleFields
{ public: typedef ::testing::tuple
type; static type GetSelectedFields(const Tuple& t) { return type(get
(t), get
(t), get
(t)); } }; template
class TupleFields
{ public: typedef ::testing::tuple
type; static type GetSelectedFields(const Tuple& t) { return type(get
(t), get
(t), get
(t), get
(t)); } }; template
class TupleFields
{ public: typedef ::testing::tuple
type; static type GetSelectedFields(const Tuple& t) { return type(get
(t), get
(t), get
(t), get
(t), get
(t)); } }; template
class TupleFields
{ public: typedef ::testing::tuple
type; static type GetSelectedFields(const Tuple& t) { return type(get
(t), get
(t), get
(t), get
(t), get
(t), get
(t)); } }; template
class TupleFields
{ public: typedef ::testing::tuple
type; static type GetSelectedFields(const Tuple& t) { return type(get
(t), get
(t), get
(t), get
(t), get
(t), get
(t), get
(t)); } }; template
class TupleFields
{ public: typedef ::testing::tuple
type; static type GetSelectedFields(const Tuple& t) { return type(get
(t), get
(t), get
(t), get
(t), get
(t), get
(t), get
(t), get
(t)); } }; template
class TupleFields
{ public: typedef ::testing::tuple
type; static type GetSelectedFields(const Tuple& t) { return type(get
(t), get
(t), get
(t), get
(t), get
(t), get
(t), get
(t), get
(t), get
(t)); } }; #undef GMOCK_FIELD_TYPE_ // Implements the Args() matcher. template
class ArgsMatcherImpl : public MatcherInterface
{ public: // ArgsTuple may have top-level const or reference modifiers. typedef GTEST_REMOVE_REFERENCE_AND_CONST_(ArgsTuple) RawArgsTuple; typedef typename internal::TupleFields
::type SelectedArgs; typedef Matcher
MonomorphicInnerMatcher; template
explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher) : inner_matcher_(SafeMatcherCast
(inner_matcher)) {} virtual bool MatchAndExplain(ArgsTuple args, MatchResultListener* listener) const { const SelectedArgs& selected_args = GetSelectedArgs(args); if (!listener->IsInterested()) return inner_matcher_.Matches(selected_args); PrintIndices(listener->stream()); *listener << "are " << PrintToString(selected_args); StringMatchResultListener inner_listener; const bool match = inner_matcher_.MatchAndExplain(selected_args, &inner_listener); PrintIfNotEmpty(inner_listener.str(), listener->stream()); return match; } virtual void DescribeTo(::std::ostream* os) const { *os << "are a tuple "; PrintIndices(os); inner_matcher_.DescribeTo(os); } virtual void DescribeNegationTo(::std::ostream* os) const { *os << "are a tuple "; PrintIndices(os); inner_matcher_.DescribeNegationTo(os); } private: static SelectedArgs GetSelectedArgs(ArgsTuple args) { return TupleFields
::GetSelectedFields(args); } // Prints the indices of the selected fields. static void PrintIndices(::std::ostream* os) { *os << "whose fields ("; const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 }; for (int i = 0; i < 10; i++) { if (indices[i] < 0) break; if (i >= 1) *os << ", "; *os << "#" << indices[i]; } *os << ") "; } const MonomorphicInnerMatcher inner_matcher_; GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl); }; template
class ArgsMatcher { public: explicit ArgsMatcher(const InnerMatcher& inner_matcher) : inner_matcher_(inner_matcher) {} template
operator Matcher
() const { return MakeMatcher(new ArgsMatcherImpl
(inner_matcher_)); } private: const InnerMatcher inner_matcher_; GTEST_DISALLOW_ASSIGN_(ArgsMatcher); }; // A set of metafunctions for computing the result type of AllOf. // AllOf(m1, ..., mN) returns // AllOfResultN
::type. // Although AllOf isn't defined for one argument, AllOfResult1 is defined // to simplify the implementation. template
struct AllOfResult1 { typedef M1 type; }; template
struct AllOfResult2 { typedef BothOfMatcher< typename AllOfResult1
::type, typename AllOfResult1
::type > type; }; template
struct AllOfResult3 { typedef BothOfMatcher< typename AllOfResult1
::type, typename AllOfResult2
::type > type; }; template
struct AllOfResult4 { typedef BothOfMatcher< typename AllOfResult2
::type, typename AllOfResult2
::type > type; }; template
struct AllOfResult5 { typedef BothOfMatcher< typename AllOfResult2
::type, typename AllOfResult3
::type > type; }; template
struct AllOfResult6 { typedef BothOfMatcher< typename AllOfResult3
::type, typename AllOfResult3
::type > type; }; template
struct AllOfResult7 { typedef BothOfMatcher< typename AllOfResult3
::type, typename AllOfResult4
::type > type; }; template
struct AllOfResult8 { typedef BothOfMatcher< typename AllOfResult4
::type, typename AllOfResult4
::type > type; }; template
struct AllOfResult9 { typedef BothOfMatcher< typename AllOfResult4
::type, typename AllOfResult5
::type > type; }; template
struct AllOfResult10 { typedef BothOfMatcher< typename AllOfResult5
::type, typename AllOfResult5
::type > type; }; // A set of metafunctions for computing the result type of AnyOf. // AnyOf(m1, ..., mN) returns // AnyOfResultN
::type. // Although AnyOf isn't defined for one argument, AnyOfResult1 is defined // to simplify the implementation. template
struct AnyOfResult1 { typedef M1 type; }; template
struct AnyOfResult2 { typedef EitherOfMatcher< typename AnyOfResult1
::type, typename AnyOfResult1
::type > type; }; template
struct AnyOfResult3 { typedef EitherOfMatcher< typename AnyOfResult1
::type, typename AnyOfResult2
::type > type; }; template
struct AnyOfResult4 { typedef EitherOfMatcher< typename AnyOfResult2
::type, typename AnyOfResult2
::type > type; }; template
struct AnyOfResult5 { typedef EitherOfMatcher< typename AnyOfResult2
::type, typename AnyOfResult3
::type > type; }; template
struct AnyOfResult6 { typedef EitherOfMatcher< typename AnyOfResult3
::type, typename AnyOfResult3
::type > type; }; template
struct AnyOfResult7 { typedef EitherOfMatcher< typename AnyOfResult3
::type, typename AnyOfResult4
::type > type; }; template
struct AnyOfResult8 { typedef EitherOfMatcher< typename AnyOfResult4
::type, typename AnyOfResult4
::type > type; }; template
struct AnyOfResult9 { typedef EitherOfMatcher< typename AnyOfResult4
::type, typename AnyOfResult5
::type > type; }; template
struct AnyOfResult10 { typedef EitherOfMatcher< typename AnyOfResult5
::type, typename AnyOfResult5
::type > type; }; } // namespace internal // Args
(a_matcher) matches a tuple if the selected // fields of it matches a_matcher. C++ doesn't support default // arguments for function templates, so we have to overload it. template
inline internal::ArgsMatcher
Args(const InnerMatcher& matcher) { return internal::ArgsMatcher
(matcher); } template
inline internal::ArgsMatcher
Args(const InnerMatcher& matcher) { return internal::ArgsMatcher
(matcher); } template
inline internal::ArgsMatcher
Args(const InnerMatcher& matcher) { return internal::ArgsMatcher
(matcher); } template
inline internal::ArgsMatcher
Args(const InnerMatcher& matcher) { return internal::ArgsMatcher
(matcher); } template
inline internal::ArgsMatcher
Args(const InnerMatcher& matcher) { return internal::ArgsMatcher
(matcher); } template
inline internal::ArgsMatcher
Args(const InnerMatcher& matcher) { return internal::ArgsMatcher
(matcher); } template
inline internal::ArgsMatcher
Args(const InnerMatcher& matcher) { return internal::ArgsMatcher
(matcher); } template
inline internal::ArgsMatcher
Args(const InnerMatcher& matcher) { return internal::ArgsMatcher
(matcher); } template
inline internal::ArgsMatcher
Args(const InnerMatcher& matcher) { return internal::ArgsMatcher
(matcher); } template
inline internal::ArgsMatcher
Args(const InnerMatcher& matcher) { return internal::ArgsMatcher
(matcher); } template
inline internal::ArgsMatcher
Args(const InnerMatcher& matcher) { return internal::ArgsMatcher
(matcher); } // ElementsAre(e_1, e_2, ... e_n) matches an STL-style container with // n elements, where the i-th element in the container must // match the i-th argument in the list. Each argument of // ElementsAre() can be either a value or a matcher. We support up to // 10 arguments. // // The use of DecayArray in the implementation allows ElementsAre() // to accept string literals, whose type is const char[N], but we // want to treat them as const char*. // // NOTE: Since ElementsAre() cares about the order of the elements, it // must not be used with containers whose elements's order is // undefined (e.g. hash_map). inline internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre() { typedef ::testing::tuple<> Args; return internal::ElementsAreMatcher
(Args()); } template
inline internal::ElementsAreMatcher< ::testing::tuple< typename internal::DecayArray
::type> > ElementsAre(const T1& e1) { typedef ::testing::tuple< typename internal::DecayArray
::type> Args; return internal::ElementsAreMatcher
(Args(e1)); } template
inline internal::ElementsAreMatcher< ::testing::tuple< typename internal::DecayArray
::type, typename internal::DecayArray
::type> > ElementsAre(const T1& e1, const T2& e2) { typedef ::testing::tuple< typename internal::DecayArray
::type, typename internal::DecayArray
::type> Args; return internal::ElementsAreMatcher
(Args(e1, e2)); } template
inline internal::ElementsAreMatcher< ::testing::tuple< typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type> > ElementsAre(const T1& e1, const T2& e2, const T3& e3) { typedef ::testing::tuple< typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type> Args; return internal::ElementsAreMatcher
(Args(e1, e2, e3)); } template
inline internal::ElementsAreMatcher< ::testing::tuple< typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type> > ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4) { typedef ::testing::tuple< typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type> Args; return internal::ElementsAreMatcher
(Args(e1, e2, e3, e4)); } template
inline internal::ElementsAreMatcher< ::testing::tuple< typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type> > ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4, const T5& e5) { typedef ::testing::tuple< typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type> Args; return internal::ElementsAreMatcher
(Args(e1, e2, e3, e4, e5)); } template
inline internal::ElementsAreMatcher< ::testing::tuple< typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type> > ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4, const T5& e5, const T6& e6) { typedef ::testing::tuple< typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type, typename internal::DecayArray
::type> Args; return internal::ElementsAreMatcher
(Args(e1, e2, e3, e4, e5, e6)); } template