HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Android 10
|
10.0.0_r6
下载
查看原文件
收藏
根目录
external
google-breakpad
src
testing
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 "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 ::std::tr1::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 ::std::tr1::tuple
type; static type GetSelectedFields(const Tuple& t) { using ::std::tr1::get; 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 ::std::tr1::tuple<> type; static type GetSelectedFields(const Tuple& /* t */) { using ::std::tr1::get; return type(); } }; template
class TupleFields
{ public: typedef ::std::tr1::tuple
type; static type GetSelectedFields(const Tuple& t) { using ::std::tr1::get; return type(get
(t)); } }; template
class TupleFields
{ public: typedef ::std::tr1::tuple
type; static type GetSelectedFields(const Tuple& t) { using ::std::tr1::get; return type(get
(t), get
(t)); } }; template
class TupleFields
{ public: typedef ::std::tr1::tuple
type; static type GetSelectedFields(const Tuple& t) { using ::std::tr1::get; return type(get
(t), get
(t), get
(t)); } }; template
class TupleFields
{ public: typedef ::std::tr1::tuple
type; static type GetSelectedFields(const Tuple& t) { using ::std::tr1::get; return type(get
(t), get
(t), get
(t), get
(t)); } }; template
class TupleFields
{ public: typedef ::std::tr1::tuple
type; static type GetSelectedFields(const Tuple& t) { using ::std::tr1::get; return type(get
(t), get
(t), get
(t), get
(t), get
(t)); } }; template
class TupleFields
{ public: typedef ::std::tr1::tuple
type; static type GetSelectedFields(const Tuple& t) { using ::std::tr1::get; return type(get
(t), get
(t), get
(t), get
(t), get
(t), get
(t)); } }; template
class TupleFields
{ public: typedef ::std::tr1::tuple
type; static type GetSelectedFields(const Tuple& t) { using ::std::tr1::get; return type(get
(t), get
(t), get
(t), get
(t), get
(t), get
(t), get
(t)); } }; template
class TupleFields
{ public: typedef ::std::tr1::tuple
type; static type GetSelectedFields(const Tuple& t) { using ::std::tr1::get; return type(get
(t), get
(t), get
(t), get
(t), get
(t), get
(t), get
(t), get
(t)); } }; template
class TupleFields
{ public: typedef ::std::tr1::tuple
type; static type GetSelectedFields(const Tuple& t) { using ::std::tr1::get; 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); }; // Implements ElementsAre() of 1-10 arguments. template
class ElementsAreMatcher1 { public: explicit ElementsAreMatcher1(const T1& e1) : e1_(e1) {} template
operator Matcher
() const { typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer; typedef typename internal::StlContainerView
::type::value_type Element; // Nokia's Symbian Compiler has a nasty bug where the object put // in a one-element local array is not destructed when the array // goes out of scope. This leads to obvious badness as we've // added the linked_ptr in it to our other linked_ptrs list. // Hence we implement ElementsAreMatcher1 specially to avoid using // a local array. const Matcher
matcher = MatcherCast
(e1_); return MakeMatcher(new ElementsAreMatcherImpl
(&matcher, 1)); } private: const T1& e1_; GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher1); }; template
class ElementsAreMatcher2 { public: ElementsAreMatcher2(const T1& e1, const T2& e2) : e1_(e1), e2_(e2) {} template
operator Matcher
() const { typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer; typedef typename internal::StlContainerView
::type::value_type Element; const Matcher
matchers[] = { MatcherCast
(e1_), MatcherCast
(e2_), }; return MakeMatcher(new ElementsAreMatcherImpl
(matchers, 2)); } private: const T1& e1_; const T2& e2_; GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher2); }; template
class ElementsAreMatcher3 { public: ElementsAreMatcher3(const T1& e1, const T2& e2, const T3& e3) : e1_(e1), e2_(e2), e3_(e3) {} template
operator Matcher
() const { typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer; typedef typename internal::StlContainerView
::type::value_type Element; const Matcher
matchers[] = { MatcherCast
(e1_), MatcherCast
(e2_), MatcherCast
(e3_), }; return MakeMatcher(new ElementsAreMatcherImpl
(matchers, 3)); } private: const T1& e1_; const T2& e2_; const T3& e3_; GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher3); }; template
class ElementsAreMatcher4 { public: ElementsAreMatcher4(const T1& e1, const T2& e2, const T3& e3, const T4& e4) : e1_(e1), e2_(e2), e3_(e3), e4_(e4) {} template
operator Matcher
() const { typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer; typedef typename internal::StlContainerView
::type::value_type Element; const Matcher
matchers[] = { MatcherCast
(e1_), MatcherCast
(e2_), MatcherCast
(e3_), MatcherCast
(e4_), }; return MakeMatcher(new ElementsAreMatcherImpl
(matchers, 4)); } private: const T1& e1_; const T2& e2_; const T3& e3_; const T4& e4_; GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher4); }; template
class ElementsAreMatcher5 { public: ElementsAreMatcher5(const T1& e1, const T2& e2, const T3& e3, const T4& e4, const T5& e5) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5) {} template
operator Matcher
() const { typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer; typedef typename internal::StlContainerView
::type::value_type Element; const Matcher
matchers[] = { MatcherCast
(e1_), MatcherCast
(e2_), MatcherCast
(e3_), MatcherCast
(e4_), MatcherCast
(e5_), }; return MakeMatcher(new ElementsAreMatcherImpl
(matchers, 5)); } private: const T1& e1_; const T2& e2_; const T3& e3_; const T4& e4_; const T5& e5_; GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher5); }; template
class ElementsAreMatcher6 { public: ElementsAreMatcher6(const T1& e1, const T2& e2, const T3& e3, const T4& e4, const T5& e5, const T6& e6) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6) {} template
operator Matcher
() const { typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer; typedef typename internal::StlContainerView
::type::value_type Element; const Matcher
matchers[] = { MatcherCast
(e1_), MatcherCast
(e2_), MatcherCast
(e3_), MatcherCast
(e4_), MatcherCast
(e5_), MatcherCast
(e6_), }; return MakeMatcher(new ElementsAreMatcherImpl
(matchers, 6)); } private: const T1& e1_; const T2& e2_; const T3& e3_; const T4& e4_; const T5& e5_; const T6& e6_; GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher6); }; template
class ElementsAreMatcher7 { public: ElementsAreMatcher7(const T1& e1, const T2& e2, const T3& e3, const T4& e4, const T5& e5, const T6& e6, const T7& e7) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6), e7_(e7) {} template
operator Matcher
() const { typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer; typedef typename internal::StlContainerView
::type::value_type Element; const Matcher
matchers[] = { MatcherCast
(e1_), MatcherCast
(e2_), MatcherCast
(e3_), MatcherCast
(e4_), MatcherCast
(e5_), MatcherCast
(e6_), MatcherCast
(e7_), }; return MakeMatcher(new ElementsAreMatcherImpl
(matchers, 7)); } private: const T1& e1_; const T2& e2_; const T3& e3_; const T4& e4_; const T5& e5_; const T6& e6_; const T7& e7_; GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher7); }; template
class ElementsAreMatcher8 { public: ElementsAreMatcher8(const T1& e1, const T2& e2, const T3& e3, const T4& e4, const T5& e5, const T6& e6, const T7& e7, const T8& e8) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6), e7_(e7), e8_(e8) {} template
operator Matcher
() const { typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer; typedef typename internal::StlContainerView
::type::value_type Element; const Matcher
matchers[] = { MatcherCast
(e1_), MatcherCast
(e2_), MatcherCast
(e3_), MatcherCast
(e4_), MatcherCast
(e5_), MatcherCast
(e6_), MatcherCast
(e7_), MatcherCast
(e8_), }; return MakeMatcher(new ElementsAreMatcherImpl
(matchers, 8)); } private: const T1& e1_; const T2& e2_; const T3& e3_; const T4& e4_; const T5& e5_; const T6& e6_; const T7& e7_; const T8& e8_; GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher8); }; template
class ElementsAreMatcher9 { public: ElementsAreMatcher9(const T1& e1, const T2& e2, const T3& e3, const T4& e4, const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6), e7_(e7), e8_(e8), e9_(e9) {} template
operator Matcher
() const { typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer; typedef typename internal::StlContainerView
::type::value_type Element; const Matcher
matchers[] = { MatcherCast
(e1_), MatcherCast
(e2_), MatcherCast
(e3_), MatcherCast
(e4_), MatcherCast
(e5_), MatcherCast
(e6_), MatcherCast
(e7_), MatcherCast
(e8_), MatcherCast
(e9_), }; return MakeMatcher(new ElementsAreMatcherImpl
(matchers, 9)); } private: const T1& e1_; const T2& e2_; const T3& e3_; const T4& e4_; const T5& e5_; const T6& e6_; const T7& e7_; const T8& e8_; const T9& e9_; GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher9); }; template
class ElementsAreMatcher10 { public: ElementsAreMatcher10(const T1& e1, const T2& e2, const T3& e3, const T4& e4, const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9, const T10& e10) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6), e7_(e7), e8_(e8), e9_(e9), e10_(e10) {} template
operator Matcher
() const { typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer; typedef typename internal::StlContainerView
::type::value_type Element; const Matcher
matchers[] = { MatcherCast
(e1_), MatcherCast
(e2_), MatcherCast
(e3_), MatcherCast
(e4_), MatcherCast
(e5_), MatcherCast
(e6_), MatcherCast
(e7_), MatcherCast
(e8_), MatcherCast
(e9_), MatcherCast
(e10_), }; return MakeMatcher(new ElementsAreMatcherImpl
(matchers, 10)); } private: const T1& e1_; const T2& e2_; const T3& e3_; const T4& e4_; const T5& e5_; const T6& e6_; const T7& e7_; const T8& e8_; const T9& e9_; const T10& e10_; GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher10); }; // 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