gmock-generated-matchers.h.pump 4.91 KB
Newer Older
1
$$ -*- mode: c++; -*-
Gennadiy Civil's avatar
 
Gennadiy Civil committed
2
3
$$ This is a Pump source file. Please use Pump to convert
$$ it to gmock-generated-matchers.h.
4
5
$$
$var n = 10  $$ The maximum arity we support.
6
$$ }} This line fixes auto-indentation of the following code in Emacs.
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// 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.

Gennadiy Civil's avatar
 
Gennadiy Civil committed
40
41
// GOOGLETEST_CM0002 DO NOT DELETE

42
43
44
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_

45
#include <iterator>
46
47
#include <sstream>
#include <string>
Abseil Team's avatar
Abseil Team committed
48
#include <utility>
49
#include <vector>
50
#include "gmock/gmock-matchers.h"
51

zhanyong.wan's avatar
zhanyong.wan committed
52
53
54
55
$range i 0..n
$for i

[[
Abseil Team's avatar
Abseil Team committed
56
57
$var macro_name = [[$if i==0 [[GMOCK_INTERNAL_MATCHER]] $elif i==1 [[GMOCK_INTERNAL_MATCHER_P]]
                                         $else [[GMOCK_INTERNAL_MATCHER_P$i]]]]
zhanyong.wan's avatar
zhanyong.wan committed
58
59
60
61
62
63
64
$var class_name = [[name##Matcher[[$if i==0 [[]] $elif i==1 [[P]]
                                                 $else [[P$i]]]]]]
$range j 0..i-1
$var template = [[$if i==0 [[]] $else [[

  template <$for j, [[typename p$j##_type]]>\
]]]]
65
$var impl_ctor_param_list = [[$for j, [[p$j##_type gmock_p$j]]]]
Abseil Team's avatar
Abseil Team committed
66
$var impl_inits = [[$if i==0 [[]] $else [[ : $for j, [[p$j(::std::move(gmock_p$j))]]]]]]
zhanyong.wan's avatar
zhanyong.wan committed
67
68
69
70
71
72
$var params = [[$for j, [[p$j]]]]
$var param_types = [[$if i==0 [[]] $else [[<$for j, [[p$j##_type]]>]]]]
$var param_types_and_names = [[$for j, [[p$j##_type p$j]]]]
$var param_field_decls = [[$for j
[[

73
      p$j##_type const p$j;\
zhanyong.wan's avatar
zhanyong.wan committed
74
75
76
77
]]]]
$var param_field_decls2 = [[$for j
[[

78
    p$j##_type const p$j;\
zhanyong.wan's avatar
zhanyong.wan committed
79
80
]]]]

Abseil Team's avatar
Abseil Team committed
81
#define $macro_name(name, description$for j [[, p$j]])\$template
Abseil Team's avatar
Abseil Team committed
82
83
  class $class_name : public ::testing::internal::MatcherBaseImpl<$class_name$param_types> {\
    using __internal_base_type = ::testing::internal::MatcherBaseImpl<$class_name>;\
zhanyong.wan's avatar
zhanyong.wan committed
84
   public:\
Abseil Team's avatar
Abseil Team committed
85
    using __internal_base_type::__internal_base_type;\
zhanyong.wan's avatar
zhanyong.wan committed
86
    template <typename arg_type>\
87
88
    class gmock_Impl : public ::testing::MatcherInterface<\
        GTEST_REFERENCE_TO_CONST_(arg_type)> {\
zhanyong.wan's avatar
zhanyong.wan committed
89
     public:\
90
91
      [[$if i==1 [[explicit ]]]]gmock_Impl($impl_ctor_param_list)\
          $impl_inits {}\
Robert Luberda's avatar
Robert Luberda committed
92
      bool MatchAndExplain(\
93
          GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
Robert Luberda's avatar
Robert Luberda committed
94
95
          ::testing::MatchResultListener* result_listener) const override;\
      void DescribeTo(::std::ostream* gmock_os) const override {\
96
97
        *gmock_os << FormatDescription(false);\
      }\
Robert Luberda's avatar
Robert Luberda committed
98
      void DescribeNegationTo(::std::ostream* gmock_os) const override {\
99
        *gmock_os << FormatDescription(true);\
zhanyong.wan's avatar
zhanyong.wan committed
100
      }\$param_field_decls
101
     private:\
102
103
      ::std::string FormatDescription(bool negation) const {\
        ::std::string gmock_description = (description);\
104
        if (!gmock_description.empty()) {\
105
          return gmock_description;\
106
        }\
107
        return ::testing::internal::FormatMatcherDescription(\
108
            negation, #name, \
109
            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
Abseil Team's avatar
Abseil Team committed
110
                ::std::tuple<$for j, [[p$j##_type]]>($for j, [[p$j]])));\
111
      }\
zhanyong.wan's avatar
zhanyong.wan committed
112
113
114
115
116
117
    };\
  };\$template
  inline $class_name$param_types name($param_types_and_names) {\
    return $class_name$param_types($params);\
  }\$template
  template <typename arg_type>\
zhanyong.wan's avatar
zhanyong.wan committed
118
  bool $class_name$param_types::gmock_Impl<arg_type>::MatchAndExplain(\
119
      GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
zhanyong.wan's avatar
zhanyong.wan committed
120
121
      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
          const
zhanyong.wan's avatar
zhanyong.wan committed
122
123
124
]]


125
#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_