Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1 | // This file was GENERATED by command: |
| 2 | // pump.py gmock-generated-actions.h.pump |
| 3 | // DO NOT EDIT BY HAND!!! |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 4 | |
| 5 | // Copyright 2007, Google Inc. |
| 6 | // All rights reserved. |
| 7 | // |
| 8 | // Redistribution and use in source and binary forms, with or without |
| 9 | // modification, are permitted provided that the following conditions are |
| 10 | // met: |
| 11 | // |
| 12 | // * Redistributions of source code must retain the above copyright |
| 13 | // notice, this list of conditions and the following disclaimer. |
| 14 | // * Redistributions in binary form must reproduce the above |
| 15 | // copyright notice, this list of conditions and the following disclaimer |
| 16 | // in the documentation and/or other materials provided with the |
| 17 | // distribution. |
| 18 | // * Neither the name of Google Inc. nor the names of its |
| 19 | // contributors may be used to endorse or promote products derived from |
| 20 | // this software without specific prior written permission. |
| 21 | // |
| 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 | // |
| 34 | // Author: wan@google.com (Zhanyong Wan) |
| 35 | |
| 36 | // Google Mock - a framework for writing C++ mock classes. |
| 37 | // |
| 38 | // This file implements some commonly used variadic actions. |
| 39 | |
| 40 | #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ |
| 41 | #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ |
| 42 | |
zhanyong.wan | 53e08c4 | 2010-09-14 05:38:21 +0000 | [diff] [blame] | 43 | #include "gmock/gmock-actions.h" |
| 44 | #include "gmock/internal/gmock-port.h" |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 45 | |
| 46 | namespace testing { |
| 47 | namespace internal { |
| 48 | |
| 49 | // InvokeHelper<F> knows how to unpack an N-tuple and invoke an N-ary |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 50 | // function, method, or callback with the unpacked values, where F is |
| 51 | // a function type that takes N arguments. |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 52 | template <typename Result, typename ArgumentTuple> |
| 53 | class InvokeHelper; |
| 54 | |
| 55 | template <typename R> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 56 | class InvokeHelper<R, ::testing::tuple<> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 57 | public: |
| 58 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 59 | static R Invoke(Function function, const ::testing::tuple<>&) { |
| 60 | return function(); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | template <class Class, typename MethodPtr> |
| 64 | static R InvokeMethod(Class* obj_ptr, |
| 65 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 66 | const ::testing::tuple<>&) { |
| 67 | return (obj_ptr->*method_ptr)(); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 68 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 69 | |
| 70 | template <typename CallbackType> |
| 71 | static R InvokeCallback(CallbackType* callback, |
| 72 | const ::testing::tuple<>&) { |
| 73 | return callback->Run(); |
| 74 | } |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | template <typename R, typename A1> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 78 | class InvokeHelper<R, ::testing::tuple<A1> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 79 | public: |
| 80 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 81 | static R Invoke(Function function, const ::testing::tuple<A1>& args) { |
| 82 | return function(get<0>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | template <class Class, typename MethodPtr> |
| 86 | static R InvokeMethod(Class* obj_ptr, |
| 87 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 88 | const ::testing::tuple<A1>& args) { |
| 89 | return (obj_ptr->*method_ptr)(get<0>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 90 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 91 | |
| 92 | template <typename CallbackType> |
| 93 | static R InvokeCallback(CallbackType* callback, |
| 94 | const ::testing::tuple<A1>& args) { |
| 95 | return callback->Run(get<0>(args)); |
| 96 | } |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | template <typename R, typename A1, typename A2> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 100 | class InvokeHelper<R, ::testing::tuple<A1, A2> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 101 | public: |
| 102 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 103 | static R Invoke(Function function, const ::testing::tuple<A1, A2>& args) { |
| 104 | return function(get<0>(args), get<1>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | template <class Class, typename MethodPtr> |
| 108 | static R InvokeMethod(Class* obj_ptr, |
| 109 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 110 | const ::testing::tuple<A1, A2>& args) { |
| 111 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 112 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 113 | |
| 114 | template <typename CallbackType> |
| 115 | static R InvokeCallback(CallbackType* callback, |
| 116 | const ::testing::tuple<A1, A2>& args) { |
| 117 | return callback->Run(get<0>(args), get<1>(args)); |
| 118 | } |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | template <typename R, typename A1, typename A2, typename A3> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 122 | class InvokeHelper<R, ::testing::tuple<A1, A2, A3> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 123 | public: |
| 124 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 125 | static R Invoke(Function function, const ::testing::tuple<A1, A2, A3>& args) { |
| 126 | return function(get<0>(args), get<1>(args), get<2>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | template <class Class, typename MethodPtr> |
| 130 | static R InvokeMethod(Class* obj_ptr, |
| 131 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 132 | const ::testing::tuple<A1, A2, A3>& args) { |
| 133 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), |
| 134 | get<2>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 135 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 136 | |
| 137 | template <typename CallbackType> |
| 138 | static R InvokeCallback(CallbackType* callback, |
| 139 | const ::testing::tuple<A1, A2, A3>& args) { |
| 140 | return callback->Run(get<0>(args), get<1>(args), get<2>(args)); |
| 141 | } |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 142 | }; |
| 143 | |
| 144 | template <typename R, typename A1, typename A2, typename A3, typename A4> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 145 | class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 146 | public: |
| 147 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 148 | static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 149 | A4>& args) { |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 150 | return function(get<0>(args), get<1>(args), get<2>(args), |
| 151 | get<3>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | template <class Class, typename MethodPtr> |
| 155 | static R InvokeMethod(Class* obj_ptr, |
| 156 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 157 | const ::testing::tuple<A1, A2, A3, A4>& args) { |
| 158 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), |
| 159 | get<2>(args), get<3>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 160 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 161 | |
| 162 | template <typename CallbackType> |
| 163 | static R InvokeCallback(CallbackType* callback, |
| 164 | const ::testing::tuple<A1, A2, A3, A4>& args) { |
| 165 | return callback->Run(get<0>(args), get<1>(args), get<2>(args), |
| 166 | get<3>(args)); |
| 167 | } |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 168 | }; |
| 169 | |
| 170 | template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 171 | typename A5> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 172 | class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 173 | public: |
| 174 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 175 | static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 176 | A5>& args) { |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 177 | return function(get<0>(args), get<1>(args), get<2>(args), |
| 178 | get<3>(args), get<4>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | template <class Class, typename MethodPtr> |
| 182 | static R InvokeMethod(Class* obj_ptr, |
| 183 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 184 | const ::testing::tuple<A1, A2, A3, A4, A5>& args) { |
| 185 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), |
| 186 | get<2>(args), get<3>(args), get<4>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 187 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 188 | |
| 189 | template <typename CallbackType> |
| 190 | static R InvokeCallback(CallbackType* callback, |
| 191 | const ::testing::tuple<A1, A2, A3, A4, A5>& args) { |
| 192 | return callback->Run(get<0>(args), get<1>(args), get<2>(args), |
| 193 | get<3>(args), get<4>(args)); |
| 194 | } |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 195 | }; |
| 196 | |
| 197 | template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 198 | typename A5, typename A6> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 199 | class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 200 | public: |
| 201 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 202 | static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5, |
| 203 | A6>& args) { |
| 204 | return function(get<0>(args), get<1>(args), get<2>(args), |
| 205 | get<3>(args), get<4>(args), get<5>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | template <class Class, typename MethodPtr> |
| 209 | static R InvokeMethod(Class* obj_ptr, |
| 210 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 211 | const ::testing::tuple<A1, A2, A3, A4, A5, A6>& args) { |
| 212 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), |
| 213 | get<2>(args), get<3>(args), get<4>(args), get<5>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 214 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 215 | |
| 216 | // There is no InvokeCallback() for 6-tuples, as google3 callbacks |
| 217 | // support 5 arguments at most. |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 218 | }; |
| 219 | |
| 220 | template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 221 | typename A5, typename A6, typename A7> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 222 | class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 223 | public: |
| 224 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 225 | static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5, |
| 226 | A6, A7>& args) { |
| 227 | return function(get<0>(args), get<1>(args), get<2>(args), |
| 228 | get<3>(args), get<4>(args), get<5>(args), get<6>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | template <class Class, typename MethodPtr> |
| 232 | static R InvokeMethod(Class* obj_ptr, |
| 233 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 234 | const ::testing::tuple<A1, A2, A3, A4, A5, A6, |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 235 | A7>& args) { |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 236 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), |
| 237 | get<2>(args), get<3>(args), get<4>(args), get<5>(args), |
| 238 | get<6>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 239 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 240 | |
| 241 | // There is no InvokeCallback() for 7-tuples, as google3 callbacks |
| 242 | // support 5 arguments at most. |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 243 | }; |
| 244 | |
| 245 | template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 246 | typename A5, typename A6, typename A7, typename A8> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 247 | class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 248 | public: |
| 249 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 250 | static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5, |
| 251 | A6, A7, A8>& args) { |
| 252 | return function(get<0>(args), get<1>(args), get<2>(args), |
| 253 | get<3>(args), get<4>(args), get<5>(args), get<6>(args), |
| 254 | get<7>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | template <class Class, typename MethodPtr> |
| 258 | static R InvokeMethod(Class* obj_ptr, |
| 259 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 260 | const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 261 | A8>& args) { |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 262 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), |
| 263 | get<2>(args), get<3>(args), get<4>(args), get<5>(args), |
| 264 | get<6>(args), get<7>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 265 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 266 | |
| 267 | // There is no InvokeCallback() for 8-tuples, as google3 callbacks |
| 268 | // support 5 arguments at most. |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 269 | }; |
| 270 | |
| 271 | template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 272 | typename A5, typename A6, typename A7, typename A8, typename A9> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 273 | class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 274 | public: |
| 275 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 276 | static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5, |
| 277 | A6, A7, A8, A9>& args) { |
| 278 | return function(get<0>(args), get<1>(args), get<2>(args), |
| 279 | get<3>(args), get<4>(args), get<5>(args), get<6>(args), |
| 280 | get<7>(args), get<8>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | template <class Class, typename MethodPtr> |
| 284 | static R InvokeMethod(Class* obj_ptr, |
| 285 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 286 | const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 287 | A9>& args) { |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 288 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), |
| 289 | get<2>(args), get<3>(args), get<4>(args), get<5>(args), |
| 290 | get<6>(args), get<7>(args), get<8>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 291 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 292 | |
| 293 | // There is no InvokeCallback() for 9-tuples, as google3 callbacks |
| 294 | // support 5 arguments at most. |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 295 | }; |
| 296 | |
| 297 | template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 298 | typename A5, typename A6, typename A7, typename A8, typename A9, |
| 299 | typename A10> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 300 | class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9, |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 301 | A10> > { |
| 302 | public: |
| 303 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 304 | static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5, |
| 305 | A6, A7, A8, A9, A10>& args) { |
| 306 | return function(get<0>(args), get<1>(args), get<2>(args), |
| 307 | get<3>(args), get<4>(args), get<5>(args), get<6>(args), |
| 308 | get<7>(args), get<8>(args), get<9>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | template <class Class, typename MethodPtr> |
| 312 | static R InvokeMethod(Class* obj_ptr, |
| 313 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 314 | const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 315 | A9, A10>& args) { |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 316 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), |
| 317 | get<2>(args), get<3>(args), get<4>(args), get<5>(args), |
| 318 | get<6>(args), get<7>(args), get<8>(args), get<9>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 319 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 320 | |
| 321 | // There is no InvokeCallback() for 10-tuples, as google3 callbacks |
| 322 | // support 5 arguments at most. |
| 323 | }; |
| 324 | |
| 325 | // Implements the Invoke(callback) action. |
| 326 | template <typename CallbackType> |
| 327 | class InvokeCallbackAction { |
| 328 | public: |
| 329 | // The c'tor takes ownership of the callback. |
| 330 | explicit InvokeCallbackAction(CallbackType* callback) |
| 331 | : callback_(callback) { |
| 332 | callback->CheckIsRepeatable(); // Makes sure the callback is permanent. |
| 333 | } |
| 334 | |
| 335 | // This type conversion operator template allows Invoke(callback) to |
| 336 | // be used wherever the callback's type is compatible with that of |
| 337 | // the mock function, i.e. if the mock function's arguments can be |
| 338 | // implicitly converted to the callback's arguments and the |
| 339 | // callback's result can be implicitly converted to the mock |
| 340 | // function's result. |
| 341 | template <typename Result, typename ArgumentTuple> |
| 342 | Result Perform(const ArgumentTuple& args) const { |
| 343 | return InvokeHelper<Result, ArgumentTuple>::InvokeCallback( |
| 344 | callback_.get(), args); |
| 345 | } |
| 346 | private: |
| 347 | const linked_ptr<CallbackType> callback_; |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 348 | }; |
| 349 | |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 350 | // An INTERNAL macro for extracting the type of a tuple field. It's |
| 351 | // subject to change without notice - DO NOT USE IN USER CODE! |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 352 | #define GMOCK_FIELD_(Tuple, N) \ |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 353 | typename ::testing::tuple_element<N, Tuple>::type |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 354 | |
| 355 | // SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::type is the |
| 356 | // type of an n-ary function whose i-th (1-based) argument type is the |
| 357 | // k{i}-th (0-based) field of ArgumentTuple, which must be a tuple |
| 358 | // type, and whose return type is Result. For example, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 359 | // SelectArgs<int, ::testing::tuple<bool, char, double, long>, 0, 3>::type |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 360 | // is int(bool, long). |
| 361 | // |
| 362 | // SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args) |
| 363 | // returns the selected fields (k1, k2, ..., k_n) of args as a tuple. |
| 364 | // For example, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 365 | // SelectArgs<int, tuple<bool, char, double>, 2, 0>::Select( |
| 366 | // ::testing::make_tuple(true, 'a', 2.5)) |
| 367 | // returns tuple (2.5, true). |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 368 | // |
| 369 | // The numbers in list k1, k2, ..., k_n must be >= 0, where n can be |
| 370 | // in the range [0, 10]. Duplicates are allowed and they don't have |
| 371 | // to be in an ascending or descending order. |
| 372 | |
| 373 | template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, |
| 374 | int k4, int k5, int k6, int k7, int k8, int k9, int k10> |
| 375 | class SelectArgs { |
| 376 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 377 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 378 | GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), |
| 379 | GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), |
| 380 | GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7), |
| 381 | GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9), |
| 382 | GMOCK_FIELD_(ArgumentTuple, k10)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 383 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 384 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 385 | return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), |
| 386 | get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args), |
| 387 | get<k8>(args), get<k9>(args), get<k10>(args)); |
| 388 | } |
| 389 | }; |
| 390 | |
| 391 | template <typename Result, typename ArgumentTuple> |
| 392 | class SelectArgs<Result, ArgumentTuple, |
| 393 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> { |
| 394 | public: |
| 395 | typedef Result type(); |
| 396 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
zhanyong.wan | 3fbd2dd | 2009-03-26 19:06:45 +0000 | [diff] [blame] | 397 | static SelectedArgs Select(const ArgumentTuple& /* args */) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 398 | return SelectedArgs(); |
| 399 | } |
| 400 | }; |
| 401 | |
| 402 | template <typename Result, typename ArgumentTuple, int k1> |
| 403 | class SelectArgs<Result, ArgumentTuple, |
| 404 | k1, -1, -1, -1, -1, -1, -1, -1, -1, -1> { |
| 405 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 406 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 407 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 408 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 409 | return SelectedArgs(get<k1>(args)); |
| 410 | } |
| 411 | }; |
| 412 | |
| 413 | template <typename Result, typename ArgumentTuple, int k1, int k2> |
| 414 | class SelectArgs<Result, ArgumentTuple, |
| 415 | k1, k2, -1, -1, -1, -1, -1, -1, -1, -1> { |
| 416 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 417 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 418 | GMOCK_FIELD_(ArgumentTuple, k2)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 419 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 420 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 421 | return SelectedArgs(get<k1>(args), get<k2>(args)); |
| 422 | } |
| 423 | }; |
| 424 | |
| 425 | template <typename Result, typename ArgumentTuple, int k1, int k2, int k3> |
| 426 | class SelectArgs<Result, ArgumentTuple, |
| 427 | k1, k2, k3, -1, -1, -1, -1, -1, -1, -1> { |
| 428 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 429 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 430 | GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 431 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 432 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 433 | return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args)); |
| 434 | } |
| 435 | }; |
| 436 | |
| 437 | template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, |
| 438 | int k4> |
| 439 | class SelectArgs<Result, ArgumentTuple, |
| 440 | k1, k2, k3, k4, -1, -1, -1, -1, -1, -1> { |
| 441 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 442 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 443 | GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), |
| 444 | GMOCK_FIELD_(ArgumentTuple, k4)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 445 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 446 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 447 | return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), |
| 448 | get<k4>(args)); |
| 449 | } |
| 450 | }; |
| 451 | |
| 452 | template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, |
| 453 | int k4, int k5> |
| 454 | class SelectArgs<Result, ArgumentTuple, |
| 455 | k1, k2, k3, k4, k5, -1, -1, -1, -1, -1> { |
| 456 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 457 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 458 | GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), |
| 459 | GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 460 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 461 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 462 | return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), |
| 463 | get<k4>(args), get<k5>(args)); |
| 464 | } |
| 465 | }; |
| 466 | |
| 467 | template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, |
| 468 | int k4, int k5, int k6> |
| 469 | class SelectArgs<Result, ArgumentTuple, |
| 470 | k1, k2, k3, k4, k5, k6, -1, -1, -1, -1> { |
| 471 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 472 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 473 | GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), |
| 474 | GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), |
| 475 | GMOCK_FIELD_(ArgumentTuple, k6)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 476 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 477 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 478 | return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), |
| 479 | get<k4>(args), get<k5>(args), get<k6>(args)); |
| 480 | } |
| 481 | }; |
| 482 | |
| 483 | template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, |
| 484 | int k4, int k5, int k6, int k7> |
| 485 | class SelectArgs<Result, ArgumentTuple, |
| 486 | k1, k2, k3, k4, k5, k6, k7, -1, -1, -1> { |
| 487 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 488 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 489 | GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), |
| 490 | GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), |
| 491 | GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 492 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 493 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 494 | return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), |
| 495 | get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args)); |
| 496 | } |
| 497 | }; |
| 498 | |
| 499 | template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, |
| 500 | int k4, int k5, int k6, int k7, int k8> |
| 501 | class SelectArgs<Result, ArgumentTuple, |
| 502 | k1, k2, k3, k4, k5, k6, k7, k8, -1, -1> { |
| 503 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 504 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 505 | GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), |
| 506 | GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), |
| 507 | GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7), |
| 508 | GMOCK_FIELD_(ArgumentTuple, k8)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 509 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 510 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 511 | return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), |
| 512 | get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args), |
| 513 | get<k8>(args)); |
| 514 | } |
| 515 | }; |
| 516 | |
| 517 | template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, |
| 518 | int k4, int k5, int k6, int k7, int k8, int k9> |
| 519 | class SelectArgs<Result, ArgumentTuple, |
| 520 | k1, k2, k3, k4, k5, k6, k7, k8, k9, -1> { |
| 521 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 522 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 523 | GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), |
| 524 | GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), |
| 525 | GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7), |
| 526 | GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 527 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 528 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 529 | return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), |
| 530 | get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args), |
| 531 | get<k8>(args), get<k9>(args)); |
| 532 | } |
| 533 | }; |
| 534 | |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 535 | #undef GMOCK_FIELD_ |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 536 | |
| 537 | // Implements the WithArgs action. |
| 538 | template <typename InnerAction, int k1 = -1, int k2 = -1, int k3 = -1, |
| 539 | int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1, |
| 540 | int k9 = -1, int k10 = -1> |
| 541 | class WithArgsAction { |
| 542 | public: |
| 543 | explicit WithArgsAction(const InnerAction& action) : action_(action) {} |
| 544 | |
| 545 | template <typename F> |
zhanyong.wan | 38ca64d | 2009-02-19 22:30:22 +0000 | [diff] [blame] | 546 | operator Action<F>() const { return MakeAction(new Impl<F>(action_)); } |
| 547 | |
| 548 | private: |
| 549 | template <typename F> |
| 550 | class Impl : public ActionInterface<F> { |
| 551 | public: |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 552 | typedef typename Function<F>::Result Result; |
| 553 | typedef typename Function<F>::ArgumentTuple ArgumentTuple; |
zhanyong.wan | 38ca64d | 2009-02-19 22:30:22 +0000 | [diff] [blame] | 554 | |
| 555 | explicit Impl(const InnerAction& action) : action_(action) {} |
| 556 | |
| 557 | virtual Result Perform(const ArgumentTuple& args) { |
| 558 | return action_.Perform(SelectArgs<Result, ArgumentTuple, k1, k2, k3, k4, |
| 559 | k5, k6, k7, k8, k9, k10>::Select(args)); |
| 560 | } |
| 561 | |
| 562 | private: |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 563 | typedef typename SelectArgs<Result, ArgumentTuple, |
zhanyong.wan | 38ca64d | 2009-02-19 22:30:22 +0000 | [diff] [blame] | 564 | k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type InnerFunctionType; |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 565 | |
zhanyong.wan | 38ca64d | 2009-02-19 22:30:22 +0000 | [diff] [blame] | 566 | Action<InnerFunctionType> action_; |
| 567 | }; |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 568 | |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 569 | const InnerAction action_; |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 570 | |
| 571 | GTEST_DISALLOW_ASSIGN_(WithArgsAction); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 572 | }; |
| 573 | |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 574 | // A macro from the ACTION* family (defined later in this file) |
| 575 | // defines an action that can be used in a mock function. Typically, |
| 576 | // these actions only care about a subset of the arguments of the mock |
| 577 | // function. For example, if such an action only uses the second |
| 578 | // argument, it can be used in any mock function that takes >= 2 |
| 579 | // arguments where the type of the second argument is compatible. |
| 580 | // |
| 581 | // Therefore, the action implementation must be prepared to take more |
| 582 | // arguments than it needs. The ExcessiveArg type is used to |
| 583 | // represent those excessive arguments. In order to keep the compiler |
| 584 | // error messages tractable, we define it in the testing namespace |
| 585 | // instead of testing::internal. However, this is an INTERNAL TYPE |
| 586 | // and subject to change without notice, so a user MUST NOT USE THIS |
| 587 | // TYPE DIRECTLY. |
| 588 | struct ExcessiveArg {}; |
| 589 | |
| 590 | // A helper class needed for implementing the ACTION* macros. |
| 591 | template <typename Result, class Impl> |
| 592 | class ActionHelper { |
| 593 | public: |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 594 | static Result Perform(Impl* impl, const ::testing::tuple<>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 595 | return impl->template gmock_PerformImpl<>(args, ExcessiveArg(), |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 596 | ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 597 | ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
| 598 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | template <typename A0> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 602 | static Result Perform(Impl* impl, const ::testing::tuple<A0>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 603 | return impl->template gmock_PerformImpl<A0>(args, get<0>(args), |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 604 | ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 605 | ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
| 606 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | template <typename A0, typename A1> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 610 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 611 | return impl->template gmock_PerformImpl<A0, A1>(args, get<0>(args), |
| 612 | get<1>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 613 | ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 614 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 615 | } |
| 616 | |
| 617 | template <typename A0, typename A1, typename A2> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 618 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 619 | return impl->template gmock_PerformImpl<A0, A1, A2>(args, get<0>(args), |
| 620 | get<1>(args), get<2>(args), ExcessiveArg(), ExcessiveArg(), |
| 621 | ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
| 622 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | template <typename A0, typename A1, typename A2, typename A3> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 626 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 627 | A3>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 628 | return impl->template gmock_PerformImpl<A0, A1, A2, A3>(args, get<0>(args), |
| 629 | get<1>(args), get<2>(args), get<3>(args), ExcessiveArg(), |
| 630 | ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
| 631 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 632 | } |
| 633 | |
| 634 | template <typename A0, typename A1, typename A2, typename A3, typename A4> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 635 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 636 | A4>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 637 | return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4>(args, |
| 638 | get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args), |
| 639 | ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
| 640 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 641 | } |
| 642 | |
| 643 | template <typename A0, typename A1, typename A2, typename A3, typename A4, |
| 644 | typename A5> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 645 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4, |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 646 | A5>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 647 | return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5>(args, |
| 648 | get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args), |
| 649 | get<5>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
| 650 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | template <typename A0, typename A1, typename A2, typename A3, typename A4, |
| 654 | typename A5, typename A6> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 655 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4, |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 656 | A5, A6>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 657 | return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6>(args, |
| 658 | get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args), |
| 659 | get<5>(args), get<6>(args), ExcessiveArg(), ExcessiveArg(), |
| 660 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 661 | } |
| 662 | |
| 663 | template <typename A0, typename A1, typename A2, typename A3, typename A4, |
| 664 | typename A5, typename A6, typename A7> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 665 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4, |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 666 | A5, A6, A7>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 667 | return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, |
| 668 | A7>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args), |
| 669 | get<4>(args), get<5>(args), get<6>(args), get<7>(args), ExcessiveArg(), |
| 670 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 671 | } |
| 672 | |
| 673 | template <typename A0, typename A1, typename A2, typename A3, typename A4, |
| 674 | typename A5, typename A6, typename A7, typename A8> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 675 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4, |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 676 | A5, A6, A7, A8>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 677 | return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7, |
| 678 | A8>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args), |
| 679 | get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args), |
| 680 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 681 | } |
| 682 | |
| 683 | template <typename A0, typename A1, typename A2, typename A3, typename A4, |
| 684 | typename A5, typename A6, typename A7, typename A8, typename A9> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 685 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4, |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 686 | A5, A6, A7, A8, A9>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 687 | return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7, A8, |
| 688 | A9>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args), |
| 689 | get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args), |
| 690 | get<9>(args)); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 691 | } |
| 692 | }; |
| 693 | |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 694 | } // namespace internal |
| 695 | |
| 696 | // Various overloads for Invoke(). |
| 697 | |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 698 | // WithArgs<N1, N2, ..., Nk>(an_action) creates an action that passes |
| 699 | // the selected arguments of the mock function to an_action and |
| 700 | // performs it. It serves as an adaptor between actions with |
| 701 | // different argument lists. C++ doesn't support default arguments for |
| 702 | // function templates, so we have to overload it. |
| 703 | template <int k1, typename InnerAction> |
| 704 | inline internal::WithArgsAction<InnerAction, k1> |
| 705 | WithArgs(const InnerAction& action) { |
| 706 | return internal::WithArgsAction<InnerAction, k1>(action); |
| 707 | } |
| 708 | |
| 709 | template <int k1, int k2, typename InnerAction> |
| 710 | inline internal::WithArgsAction<InnerAction, k1, k2> |
| 711 | WithArgs(const InnerAction& action) { |
| 712 | return internal::WithArgsAction<InnerAction, k1, k2>(action); |
| 713 | } |
| 714 | |
| 715 | template <int k1, int k2, int k3, typename InnerAction> |
| 716 | inline internal::WithArgsAction<InnerAction, k1, k2, k3> |
| 717 | WithArgs(const InnerAction& action) { |
| 718 | return internal::WithArgsAction<InnerAction, k1, k2, k3>(action); |
| 719 | } |
| 720 | |
| 721 | template <int k1, int k2, int k3, int k4, typename InnerAction> |
| 722 | inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4> |
| 723 | WithArgs(const InnerAction& action) { |
| 724 | return internal::WithArgsAction<InnerAction, k1, k2, k3, k4>(action); |
| 725 | } |
| 726 | |
| 727 | template <int k1, int k2, int k3, int k4, int k5, typename InnerAction> |
| 728 | inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5> |
| 729 | WithArgs(const InnerAction& action) { |
| 730 | return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5>(action); |
| 731 | } |
| 732 | |
| 733 | template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerAction> |
| 734 | inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6> |
| 735 | WithArgs(const InnerAction& action) { |
| 736 | return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6>(action); |
| 737 | } |
| 738 | |
| 739 | template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, |
| 740 | typename InnerAction> |
| 741 | inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7> |
| 742 | WithArgs(const InnerAction& action) { |
| 743 | return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, |
| 744 | k7>(action); |
| 745 | } |
| 746 | |
| 747 | template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8, |
| 748 | typename InnerAction> |
| 749 | inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8> |
| 750 | WithArgs(const InnerAction& action) { |
| 751 | return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, |
| 752 | k8>(action); |
| 753 | } |
| 754 | |
| 755 | template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8, |
| 756 | int k9, typename InnerAction> |
| 757 | inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8, k9> |
| 758 | WithArgs(const InnerAction& action) { |
| 759 | return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8, |
| 760 | k9>(action); |
| 761 | } |
| 762 | |
| 763 | template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8, |
| 764 | int k9, int k10, typename InnerAction> |
| 765 | inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8, |
| 766 | k9, k10> |
| 767 | WithArgs(const InnerAction& action) { |
| 768 | return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8, |
| 769 | k9, k10>(action); |
| 770 | } |
| 771 | |
| 772 | // Creates an action that does actions a1, a2, ..., sequentially in |
| 773 | // each invocation. |
| 774 | template <typename Action1, typename Action2> |
| 775 | inline internal::DoBothAction<Action1, Action2> |
| 776 | DoAll(Action1 a1, Action2 a2) { |
| 777 | return internal::DoBothAction<Action1, Action2>(a1, a2); |
| 778 | } |
| 779 | |
| 780 | template <typename Action1, typename Action2, typename Action3> |
| 781 | inline internal::DoBothAction<Action1, internal::DoBothAction<Action2, |
| 782 | Action3> > |
| 783 | DoAll(Action1 a1, Action2 a2, Action3 a3) { |
| 784 | return DoAll(a1, DoAll(a2, a3)); |
| 785 | } |
| 786 | |
| 787 | template <typename Action1, typename Action2, typename Action3, |
| 788 | typename Action4> |
| 789 | inline internal::DoBothAction<Action1, internal::DoBothAction<Action2, |
| 790 | internal::DoBothAction<Action3, Action4> > > |
| 791 | DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4) { |
| 792 | return DoAll(a1, DoAll(a2, a3, a4)); |
| 793 | } |
| 794 | |
| 795 | template <typename Action1, typename Action2, typename Action3, |
| 796 | typename Action4, typename Action5> |
| 797 | inline internal::DoBothAction<Action1, internal::DoBothAction<Action2, |
| 798 | internal::DoBothAction<Action3, internal::DoBothAction<Action4, |
| 799 | Action5> > > > |
| 800 | DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5) { |
| 801 | return DoAll(a1, DoAll(a2, a3, a4, a5)); |
| 802 | } |
| 803 | |
| 804 | template <typename Action1, typename Action2, typename Action3, |
| 805 | typename Action4, typename Action5, typename Action6> |
| 806 | inline internal::DoBothAction<Action1, internal::DoBothAction<Action2, |
| 807 | internal::DoBothAction<Action3, internal::DoBothAction<Action4, |
| 808 | internal::DoBothAction<Action5, Action6> > > > > |
| 809 | DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6) { |
| 810 | return DoAll(a1, DoAll(a2, a3, a4, a5, a6)); |
| 811 | } |
| 812 | |
| 813 | template <typename Action1, typename Action2, typename Action3, |
| 814 | typename Action4, typename Action5, typename Action6, typename Action7> |
| 815 | inline internal::DoBothAction<Action1, internal::DoBothAction<Action2, |
| 816 | internal::DoBothAction<Action3, internal::DoBothAction<Action4, |
| 817 | internal::DoBothAction<Action5, internal::DoBothAction<Action6, |
| 818 | Action7> > > > > > |
| 819 | DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6, |
| 820 | Action7 a7) { |
| 821 | return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7)); |
| 822 | } |
| 823 | |
| 824 | template <typename Action1, typename Action2, typename Action3, |
| 825 | typename Action4, typename Action5, typename Action6, typename Action7, |
| 826 | typename Action8> |
| 827 | inline internal::DoBothAction<Action1, internal::DoBothAction<Action2, |
| 828 | internal::DoBothAction<Action3, internal::DoBothAction<Action4, |
| 829 | internal::DoBothAction<Action5, internal::DoBothAction<Action6, |
| 830 | internal::DoBothAction<Action7, Action8> > > > > > > |
| 831 | DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6, |
| 832 | Action7 a7, Action8 a8) { |
| 833 | return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8)); |
| 834 | } |
| 835 | |
| 836 | template <typename Action1, typename Action2, typename Action3, |
| 837 | typename Action4, typename Action5, typename Action6, typename Action7, |
| 838 | typename Action8, typename Action9> |
| 839 | inline internal::DoBothAction<Action1, internal::DoBothAction<Action2, |
| 840 | internal::DoBothAction<Action3, internal::DoBothAction<Action4, |
| 841 | internal::DoBothAction<Action5, internal::DoBothAction<Action6, |
| 842 | internal::DoBothAction<Action7, internal::DoBothAction<Action8, |
| 843 | Action9> > > > > > > > |
| 844 | DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6, |
| 845 | Action7 a7, Action8 a8, Action9 a9) { |
| 846 | return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9)); |
| 847 | } |
| 848 | |
| 849 | template <typename Action1, typename Action2, typename Action3, |
| 850 | typename Action4, typename Action5, typename Action6, typename Action7, |
| 851 | typename Action8, typename Action9, typename Action10> |
| 852 | inline internal::DoBothAction<Action1, internal::DoBothAction<Action2, |
| 853 | internal::DoBothAction<Action3, internal::DoBothAction<Action4, |
| 854 | internal::DoBothAction<Action5, internal::DoBothAction<Action6, |
| 855 | internal::DoBothAction<Action7, internal::DoBothAction<Action8, |
| 856 | internal::DoBothAction<Action9, Action10> > > > > > > > > |
| 857 | DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6, |
| 858 | Action7 a7, Action8 a8, Action9 a9, Action10 a10) { |
| 859 | return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9, a10)); |
| 860 | } |
| 861 | |
| 862 | } // namespace testing |
| 863 | |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 864 | // The ACTION* family of macros can be used in a namespace scope to |
| 865 | // define custom actions easily. The syntax: |
| 866 | // |
| 867 | // ACTION(name) { statements; } |
| 868 | // |
| 869 | // will define an action with the given name that executes the |
| 870 | // statements. The value returned by the statements will be used as |
| 871 | // the return value of the action. Inside the statements, you can |
| 872 | // refer to the K-th (0-based) argument of the mock function by |
| 873 | // 'argK', and refer to its type by 'argK_type'. For example: |
| 874 | // |
| 875 | // ACTION(IncrementArg1) { |
| 876 | // arg1_type temp = arg1; |
| 877 | // return ++(*temp); |
| 878 | // } |
| 879 | // |
| 880 | // allows you to write |
| 881 | // |
| 882 | // ...WillOnce(IncrementArg1()); |
| 883 | // |
| 884 | // You can also refer to the entire argument tuple and its type by |
| 885 | // 'args' and 'args_type', and refer to the mock function type and its |
| 886 | // return type by 'function_type' and 'return_type'. |
| 887 | // |
| 888 | // Note that you don't need to specify the types of the mock function |
| 889 | // arguments. However rest assured that your code is still type-safe: |
| 890 | // you'll get a compiler error if *arg1 doesn't support the ++ |
| 891 | // operator, or if the type of ++(*arg1) isn't compatible with the |
| 892 | // mock function's return type, for example. |
| 893 | // |
| 894 | // Sometimes you'll want to parameterize the action. For that you can use |
| 895 | // another macro: |
| 896 | // |
| 897 | // ACTION_P(name, param_name) { statements; } |
| 898 | // |
| 899 | // For example: |
| 900 | // |
| 901 | // ACTION_P(Add, n) { return arg0 + n; } |
| 902 | // |
| 903 | // will allow you to write: |
| 904 | // |
| 905 | // ...WillOnce(Add(5)); |
| 906 | // |
| 907 | // Note that you don't need to provide the type of the parameter |
| 908 | // either. If you need to reference the type of a parameter named |
| 909 | // 'foo', you can write 'foo_type'. For example, in the body of |
| 910 | // ACTION_P(Add, n) above, you can write 'n_type' to refer to the type |
| 911 | // of 'n'. |
| 912 | // |
| 913 | // We also provide ACTION_P2, ACTION_P3, ..., up to ACTION_P10 to support |
| 914 | // multi-parameter actions. |
| 915 | // |
| 916 | // For the purpose of typing, you can view |
| 917 | // |
| 918 | // ACTION_Pk(Foo, p1, ..., pk) { ... } |
| 919 | // |
| 920 | // as shorthand for |
| 921 | // |
| 922 | // template <typename p1_type, ..., typename pk_type> |
| 923 | // FooActionPk<p1_type, ..., pk_type> Foo(p1_type p1, ..., pk_type pk) { ... } |
| 924 | // |
| 925 | // In particular, you can provide the template type arguments |
| 926 | // explicitly when invoking Foo(), as in Foo<long, bool>(5, false); |
| 927 | // although usually you can rely on the compiler to infer the types |
| 928 | // for you automatically. You can assign the result of expression |
| 929 | // Foo(p1, ..., pk) to a variable of type FooActionPk<p1_type, ..., |
| 930 | // pk_type>. This can be useful when composing actions. |
| 931 | // |
| 932 | // You can also overload actions with different numbers of parameters: |
| 933 | // |
| 934 | // ACTION_P(Plus, a) { ... } |
| 935 | // ACTION_P2(Plus, a, b) { ... } |
| 936 | // |
| 937 | // While it's tempting to always use the ACTION* macros when defining |
| 938 | // a new action, you should also consider implementing ActionInterface |
| 939 | // or using MakePolymorphicAction() instead, especially if you need to |
| 940 | // use the action a lot. While these approaches require more work, |
| 941 | // they give you more control on the types of the mock function |
| 942 | // arguments and the action parameters, which in general leads to |
| 943 | // better compiler error messages that pay off in the long run. They |
| 944 | // also allow overloading actions based on parameter types (as opposed |
| 945 | // to just based on the number of parameters). |
| 946 | // |
| 947 | // CAVEAT: |
| 948 | // |
| 949 | // ACTION*() can only be used in a namespace scope. The reason is |
| 950 | // that C++ doesn't yet allow function-local types to be used to |
| 951 | // instantiate templates. The up-coming C++0x standard will fix this. |
| 952 | // Once that's done, we'll consider supporting using ACTION*() inside |
| 953 | // a function. |
| 954 | // |
| 955 | // MORE INFORMATION: |
| 956 | // |
| 957 | // To learn more about using these macros, please search for 'ACTION' |
Herbert Thielen | e033d8c | 2017-08-31 18:12:17 +0200 | [diff] [blame] | 958 | // on https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 959 | |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 960 | // An internal macro needed for implementing ACTION*(). |
| 961 | #define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\ |
jgm | 79a367e | 2012-04-10 16:02:11 +0000 | [diff] [blame] | 962 | const args_type& args GTEST_ATTRIBUTE_UNUSED_, \ |
| 963 | arg0_type arg0 GTEST_ATTRIBUTE_UNUSED_, \ |
| 964 | arg1_type arg1 GTEST_ATTRIBUTE_UNUSED_, \ |
| 965 | arg2_type arg2 GTEST_ATTRIBUTE_UNUSED_, \ |
| 966 | arg3_type arg3 GTEST_ATTRIBUTE_UNUSED_, \ |
| 967 | arg4_type arg4 GTEST_ATTRIBUTE_UNUSED_, \ |
| 968 | arg5_type arg5 GTEST_ATTRIBUTE_UNUSED_, \ |
| 969 | arg6_type arg6 GTEST_ATTRIBUTE_UNUSED_, \ |
| 970 | arg7_type arg7 GTEST_ATTRIBUTE_UNUSED_, \ |
| 971 | arg8_type arg8 GTEST_ATTRIBUTE_UNUSED_, \ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 972 | arg9_type arg9 GTEST_ATTRIBUTE_UNUSED_ |
| 973 | |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 974 | // Sometimes you want to give an action explicit template parameters |
| 975 | // that cannot be inferred from its value parameters. ACTION() and |
| 976 | // ACTION_P*() don't support that. ACTION_TEMPLATE() remedies that |
| 977 | // and can be viewed as an extension to ACTION() and ACTION_P*(). |
| 978 | // |
| 979 | // The syntax: |
| 980 | // |
| 981 | // ACTION_TEMPLATE(ActionName, |
| 982 | // HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m), |
| 983 | // AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; } |
| 984 | // |
| 985 | // defines an action template that takes m explicit template |
| 986 | // parameters and n value parameters. name_i is the name of the i-th |
| 987 | // template parameter, and kind_i specifies whether it's a typename, |
| 988 | // an integral constant, or a template. p_i is the name of the i-th |
| 989 | // value parameter. |
| 990 | // |
| 991 | // Example: |
| 992 | // |
| 993 | // // DuplicateArg<k, T>(output) converts the k-th argument of the mock |
| 994 | // // function to type T and copies it to *output. |
| 995 | // ACTION_TEMPLATE(DuplicateArg, |
| 996 | // HAS_2_TEMPLATE_PARAMS(int, k, typename, T), |
| 997 | // AND_1_VALUE_PARAMS(output)) { |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 998 | // *output = T(::testing::get<k>(args)); |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 999 | // } |
| 1000 | // ... |
| 1001 | // int n; |
| 1002 | // EXPECT_CALL(mock, Foo(_, _)) |
| 1003 | // .WillOnce(DuplicateArg<1, unsigned char>(&n)); |
| 1004 | // |
| 1005 | // To create an instance of an action template, write: |
| 1006 | // |
| 1007 | // ActionName<t1, ..., t_m>(v1, ..., v_n) |
| 1008 | // |
| 1009 | // where the ts are the template arguments and the vs are the value |
| 1010 | // arguments. The value argument types are inferred by the compiler. |
| 1011 | // If you want to explicitly specify the value argument types, you can |
| 1012 | // provide additional template arguments: |
| 1013 | // |
| 1014 | // ActionName<t1, ..., t_m, u1, ..., u_k>(v1, ..., v_n) |
| 1015 | // |
| 1016 | // where u_i is the desired type of v_i. |
| 1017 | // |
| 1018 | // ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the |
| 1019 | // number of value parameters, but not on the number of template |
| 1020 | // parameters. Without the restriction, the meaning of the following |
| 1021 | // is unclear: |
| 1022 | // |
| 1023 | // OverloadedAction<int, bool>(x); |
| 1024 | // |
| 1025 | // Are we using a single-template-parameter action where 'bool' refers |
| 1026 | // to the type of x, or are we using a two-template-parameter action |
| 1027 | // where the compiler is asked to infer the type of x? |
| 1028 | // |
| 1029 | // Implementation notes: |
| 1030 | // |
| 1031 | // GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and |
| 1032 | // GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for |
| 1033 | // implementing ACTION_TEMPLATE. The main trick we use is to create |
| 1034 | // new macro invocations when expanding a macro. For example, we have |
| 1035 | // |
| 1036 | // #define ACTION_TEMPLATE(name, template_params, value_params) |
| 1037 | // ... GMOCK_INTERNAL_DECL_##template_params ... |
| 1038 | // |
| 1039 | // which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...) |
| 1040 | // to expand to |
| 1041 | // |
| 1042 | // ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ... |
| 1043 | // |
| 1044 | // Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the |
| 1045 | // preprocessor will continue to expand it to |
| 1046 | // |
| 1047 | // ... typename T ... |
| 1048 | // |
| 1049 | // This technique conforms to the C++ standard and is portable. It |
| 1050 | // allows us to implement action templates using O(N) code, where N is |
| 1051 | // the maximum number of template/value parameters supported. Without |
| 1052 | // using it, we'd have to devote O(N^2) amount of code to implement all |
| 1053 | // combinations of m and n. |
| 1054 | |
| 1055 | // Declares the template parameters. |
| 1056 | #define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0 |
| 1057 | #define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \ |
| 1058 | name1) kind0 name0, kind1 name1 |
| 1059 | #define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1060 | kind2, name2) kind0 name0, kind1 name1, kind2 name2 |
| 1061 | #define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1062 | kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2, \ |
| 1063 | kind3 name3 |
| 1064 | #define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1065 | kind2, name2, kind3, name3, kind4, name4) kind0 name0, kind1 name1, \ |
| 1066 | kind2 name2, kind3 name3, kind4 name4 |
| 1067 | #define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1068 | kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \ |
| 1069 | kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5 |
| 1070 | #define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1071 | kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ |
| 1072 | name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \ |
| 1073 | kind5 name5, kind6 name6 |
| 1074 | #define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1075 | kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ |
| 1076 | kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \ |
| 1077 | kind4 name4, kind5 name5, kind6 name6, kind7 name7 |
| 1078 | #define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1079 | kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ |
| 1080 | kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \ |
| 1081 | kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \ |
| 1082 | kind8 name8 |
| 1083 | #define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \ |
| 1084 | name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ |
| 1085 | name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \ |
| 1086 | kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \ |
| 1087 | kind6 name6, kind7 name7, kind8 name8, kind9 name9 |
| 1088 | |
| 1089 | // Lists the template parameters. |
| 1090 | #define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0 |
| 1091 | #define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \ |
| 1092 | name1) name0, name1 |
| 1093 | #define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1094 | kind2, name2) name0, name1, name2 |
| 1095 | #define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1096 | kind2, name2, kind3, name3) name0, name1, name2, name3 |
| 1097 | #define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1098 | kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \ |
| 1099 | name4 |
| 1100 | #define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1101 | kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \ |
| 1102 | name2, name3, name4, name5 |
| 1103 | #define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1104 | kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ |
| 1105 | name6) name0, name1, name2, name3, name4, name5, name6 |
| 1106 | #define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1107 | kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ |
| 1108 | kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7 |
| 1109 | #define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1110 | kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ |
| 1111 | kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \ |
| 1112 | name6, name7, name8 |
| 1113 | #define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \ |
| 1114 | name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ |
| 1115 | name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \ |
| 1116 | name3, name4, name5, name6, name7, name8, name9 |
| 1117 | |
| 1118 | // Declares the types of value parameters. |
| 1119 | #define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS() |
| 1120 | #define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type |
| 1121 | #define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) , \ |
| 1122 | typename p0##_type, typename p1##_type |
| 1123 | #define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , \ |
| 1124 | typename p0##_type, typename p1##_type, typename p2##_type |
| 1125 | #define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \ |
| 1126 | typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1127 | typename p3##_type |
| 1128 | #define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \ |
| 1129 | typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1130 | typename p3##_type, typename p4##_type |
| 1131 | #define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \ |
| 1132 | typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1133 | typename p3##_type, typename p4##_type, typename p5##_type |
| 1134 | #define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1135 | p6) , typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1136 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 1137 | typename p6##_type |
| 1138 | #define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1139 | p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1140 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 1141 | typename p6##_type, typename p7##_type |
| 1142 | #define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1143 | p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1144 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 1145 | typename p6##_type, typename p7##_type, typename p8##_type |
| 1146 | #define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1147 | p6, p7, p8, p9) , typename p0##_type, typename p1##_type, \ |
| 1148 | typename p2##_type, typename p3##_type, typename p4##_type, \ |
| 1149 | typename p5##_type, typename p6##_type, typename p7##_type, \ |
| 1150 | typename p8##_type, typename p9##_type |
| 1151 | |
| 1152 | // Initializes the value parameters. |
| 1153 | #define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\ |
| 1154 | () |
| 1155 | #define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1156 | (p0##_type gmock_p0) : p0(::testing::internal::move(gmock_p0)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1157 | #define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1158 | (p0##_type gmock_p0, \ |
| 1159 | p1##_type gmock_p1) : p0(::testing::internal::move(gmock_p0)), \ |
| 1160 | p1(::testing::internal::move(gmock_p1)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1161 | #define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\ |
| 1162 | (p0##_type gmock_p0, p1##_type gmock_p1, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1163 | p2##_type gmock_p2) : p0(::testing::internal::move(gmock_p0)), \ |
| 1164 | p1(::testing::internal::move(gmock_p1)), \ |
| 1165 | p2(::testing::internal::move(gmock_p2)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1166 | #define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\ |
| 1167 | (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1168 | p3##_type gmock_p3) : p0(::testing::internal::move(gmock_p0)), \ |
| 1169 | p1(::testing::internal::move(gmock_p1)), \ |
| 1170 | p2(::testing::internal::move(gmock_p2)), \ |
| 1171 | p3(::testing::internal::move(gmock_p3)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1172 | #define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\ |
| 1173 | (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1174 | p3##_type gmock_p3, \ |
| 1175 | p4##_type gmock_p4) : p0(::testing::internal::move(gmock_p0)), \ |
| 1176 | p1(::testing::internal::move(gmock_p1)), \ |
| 1177 | p2(::testing::internal::move(gmock_p2)), \ |
| 1178 | p3(::testing::internal::move(gmock_p3)), \ |
| 1179 | p4(::testing::internal::move(gmock_p4)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1180 | #define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\ |
| 1181 | (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 1182 | p3##_type gmock_p3, p4##_type gmock_p4, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1183 | p5##_type gmock_p5) : p0(::testing::internal::move(gmock_p0)), \ |
| 1184 | p1(::testing::internal::move(gmock_p1)), \ |
| 1185 | p2(::testing::internal::move(gmock_p2)), \ |
| 1186 | p3(::testing::internal::move(gmock_p3)), \ |
| 1187 | p4(::testing::internal::move(gmock_p4)), \ |
| 1188 | p5(::testing::internal::move(gmock_p5)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1189 | #define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\ |
| 1190 | (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 1191 | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1192 | p6##_type gmock_p6) : p0(::testing::internal::move(gmock_p0)), \ |
| 1193 | p1(::testing::internal::move(gmock_p1)), \ |
| 1194 | p2(::testing::internal::move(gmock_p2)), \ |
| 1195 | p3(::testing::internal::move(gmock_p3)), \ |
| 1196 | p4(::testing::internal::move(gmock_p4)), \ |
| 1197 | p5(::testing::internal::move(gmock_p5)), \ |
| 1198 | p6(::testing::internal::move(gmock_p6)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1199 | #define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)\ |
| 1200 | (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 1201 | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1202 | p6##_type gmock_p6, \ |
| 1203 | p7##_type gmock_p7) : p0(::testing::internal::move(gmock_p0)), \ |
| 1204 | p1(::testing::internal::move(gmock_p1)), \ |
| 1205 | p2(::testing::internal::move(gmock_p2)), \ |
| 1206 | p3(::testing::internal::move(gmock_p3)), \ |
| 1207 | p4(::testing::internal::move(gmock_p4)), \ |
| 1208 | p5(::testing::internal::move(gmock_p5)), \ |
| 1209 | p6(::testing::internal::move(gmock_p6)), \ |
| 1210 | p7(::testing::internal::move(gmock_p7)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1211 | #define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1212 | p7, p8)\ |
| 1213 | (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 1214 | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ |
| 1215 | p6##_type gmock_p6, p7##_type gmock_p7, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1216 | p8##_type gmock_p8) : p0(::testing::internal::move(gmock_p0)), \ |
| 1217 | p1(::testing::internal::move(gmock_p1)), \ |
| 1218 | p2(::testing::internal::move(gmock_p2)), \ |
| 1219 | p3(::testing::internal::move(gmock_p3)), \ |
| 1220 | p4(::testing::internal::move(gmock_p4)), \ |
| 1221 | p5(::testing::internal::move(gmock_p5)), \ |
| 1222 | p6(::testing::internal::move(gmock_p6)), \ |
| 1223 | p7(::testing::internal::move(gmock_p7)), \ |
| 1224 | p8(::testing::internal::move(gmock_p8)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1225 | #define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1226 | p7, p8, p9)\ |
| 1227 | (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 1228 | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ |
| 1229 | p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1230 | p9##_type gmock_p9) : p0(::testing::internal::move(gmock_p0)), \ |
| 1231 | p1(::testing::internal::move(gmock_p1)), \ |
| 1232 | p2(::testing::internal::move(gmock_p2)), \ |
| 1233 | p3(::testing::internal::move(gmock_p3)), \ |
| 1234 | p4(::testing::internal::move(gmock_p4)), \ |
| 1235 | p5(::testing::internal::move(gmock_p5)), \ |
| 1236 | p6(::testing::internal::move(gmock_p6)), \ |
| 1237 | p7(::testing::internal::move(gmock_p7)), \ |
| 1238 | p8(::testing::internal::move(gmock_p8)), \ |
| 1239 | p9(::testing::internal::move(gmock_p9)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1240 | |
| 1241 | // Declares the fields for storing the value parameters. |
| 1242 | #define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS() |
| 1243 | #define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0; |
| 1244 | #define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \ |
| 1245 | p1##_type p1; |
| 1246 | #define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \ |
| 1247 | p1##_type p1; p2##_type p2; |
| 1248 | #define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0; \ |
| 1249 | p1##_type p1; p2##_type p2; p3##_type p3; |
| 1250 | #define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \ |
| 1251 | p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; |
| 1252 | #define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \ |
| 1253 | p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \ |
| 1254 | p5##_type p5; |
| 1255 | #define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1256 | p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \ |
| 1257 | p5##_type p5; p6##_type p6; |
| 1258 | #define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1259 | p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \ |
| 1260 | p5##_type p5; p6##_type p6; p7##_type p7; |
| 1261 | #define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1262 | p7, p8) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \ |
| 1263 | p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; |
| 1264 | #define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1265 | p7, p8, p9) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \ |
| 1266 | p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; \ |
| 1267 | p9##_type p9; |
| 1268 | |
| 1269 | // Lists the value parameters. |
| 1270 | #define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS() |
| 1271 | #define GMOCK_INTERNAL_LIST_AND_1_VALUE_PARAMS(p0) p0 |
| 1272 | #define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1 |
| 1273 | #define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2 |
| 1274 | #define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3 |
| 1275 | #define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1, \ |
| 1276 | p2, p3, p4 |
| 1277 | #define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \ |
| 1278 | p1, p2, p3, p4, p5 |
| 1279 | #define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1280 | p6) p0, p1, p2, p3, p4, p5, p6 |
| 1281 | #define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1282 | p7) p0, p1, p2, p3, p4, p5, p6, p7 |
| 1283 | #define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1284 | p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8 |
| 1285 | #define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1286 | p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9 |
| 1287 | |
| 1288 | // Lists the value parameter types. |
| 1289 | #define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS() |
| 1290 | #define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type |
| 1291 | #define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) , p0##_type, \ |
| 1292 | p1##_type |
| 1293 | #define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , p0##_type, \ |
| 1294 | p1##_type, p2##_type |
| 1295 | #define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \ |
| 1296 | p0##_type, p1##_type, p2##_type, p3##_type |
| 1297 | #define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \ |
| 1298 | p0##_type, p1##_type, p2##_type, p3##_type, p4##_type |
| 1299 | #define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \ |
| 1300 | p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type |
| 1301 | #define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1302 | p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \ |
| 1303 | p6##_type |
| 1304 | #define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1305 | p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ |
| 1306 | p5##_type, p6##_type, p7##_type |
| 1307 | #define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1308 | p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ |
| 1309 | p5##_type, p6##_type, p7##_type, p8##_type |
| 1310 | #define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1311 | p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ |
| 1312 | p5##_type, p6##_type, p7##_type, p8##_type, p9##_type |
| 1313 | |
| 1314 | // Declares the value parameters. |
| 1315 | #define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS() |
| 1316 | #define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0 |
| 1317 | #define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \ |
| 1318 | p1##_type p1 |
| 1319 | #define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \ |
| 1320 | p1##_type p1, p2##_type p2 |
| 1321 | #define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0, \ |
| 1322 | p1##_type p1, p2##_type p2, p3##_type p3 |
| 1323 | #define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \ |
| 1324 | p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4 |
| 1325 | #define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \ |
| 1326 | p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ |
| 1327 | p5##_type p5 |
| 1328 | #define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1329 | p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ |
| 1330 | p5##_type p5, p6##_type p6 |
| 1331 | #define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1332 | p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ |
| 1333 | p5##_type p5, p6##_type p6, p7##_type p7 |
| 1334 | #define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1335 | p7, p8) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ |
| 1336 | p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8 |
| 1337 | #define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1338 | p7, p8, p9) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ |
| 1339 | p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \ |
| 1340 | p9##_type p9 |
| 1341 | |
| 1342 | // The suffix of the class template implementing the action template. |
| 1343 | #define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS() |
| 1344 | #define GMOCK_INTERNAL_COUNT_AND_1_VALUE_PARAMS(p0) P |
| 1345 | #define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2 |
| 1346 | #define GMOCK_INTERNAL_COUNT_AND_3_VALUE_PARAMS(p0, p1, p2) P3 |
| 1347 | #define GMOCK_INTERNAL_COUNT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) P4 |
| 1348 | #define GMOCK_INTERNAL_COUNT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) P5 |
| 1349 | #define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6 |
| 1350 | #define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7 |
| 1351 | #define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1352 | p7) P8 |
| 1353 | #define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1354 | p7, p8) P9 |
| 1355 | #define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1356 | p7, p8, p9) P10 |
| 1357 | |
| 1358 | // The name of the class template implementing the action template. |
| 1359 | #define GMOCK_ACTION_CLASS_(name, value_params)\ |
zhanyong.wan | ccedc1c | 2010-08-09 22:46:12 +0000 | [diff] [blame] | 1360 | GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1361 | |
| 1362 | #define ACTION_TEMPLATE(name, template_params, value_params)\ |
| 1363 | template <GMOCK_INTERNAL_DECL_##template_params\ |
| 1364 | GMOCK_INTERNAL_DECL_TYPE_##value_params>\ |
| 1365 | class GMOCK_ACTION_CLASS_(name, value_params) {\ |
| 1366 | public:\ |
billydonahue | 1f5fdea | 2014-05-19 17:54:51 +0000 | [diff] [blame] | 1367 | explicit GMOCK_ACTION_CLASS_(name, value_params)\ |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1368 | GMOCK_INTERNAL_INIT_##value_params {}\ |
| 1369 | template <typename F>\ |
| 1370 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1371 | public:\ |
| 1372 | typedef F function_type;\ |
| 1373 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1374 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1375 | args_type;\ |
| 1376 | explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\ |
| 1377 | virtual return_type Perform(const args_type& args) {\ |
| 1378 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1379 | Perform(this, args);\ |
| 1380 | }\ |
| 1381 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1382 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1383 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1384 | typename arg9_type>\ |
| 1385 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1386 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1387 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1388 | arg9_type arg9) const;\ |
| 1389 | GMOCK_INTERNAL_DEFN_##value_params\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1390 | private:\ |
| 1391 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1392 | };\ |
| 1393 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1394 | return ::testing::Action<F>(\ |
| 1395 | new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\ |
| 1396 | }\ |
| 1397 | GMOCK_INTERNAL_DEFN_##value_params\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1398 | private:\ |
| 1399 | GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\ |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1400 | };\ |
| 1401 | template <GMOCK_INTERNAL_DECL_##template_params\ |
| 1402 | GMOCK_INTERNAL_DECL_TYPE_##value_params>\ |
| 1403 | inline GMOCK_ACTION_CLASS_(name, value_params)<\ |
| 1404 | GMOCK_INTERNAL_LIST_##template_params\ |
| 1405 | GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\ |
| 1406 | GMOCK_INTERNAL_DECL_##value_params) {\ |
| 1407 | return GMOCK_ACTION_CLASS_(name, value_params)<\ |
| 1408 | GMOCK_INTERNAL_LIST_##template_params\ |
| 1409 | GMOCK_INTERNAL_LIST_TYPE_##value_params>(\ |
| 1410 | GMOCK_INTERNAL_LIST_##value_params);\ |
| 1411 | }\ |
| 1412 | template <GMOCK_INTERNAL_DECL_##template_params\ |
| 1413 | GMOCK_INTERNAL_DECL_TYPE_##value_params>\ |
| 1414 | template <typename F>\ |
jgm | 79a367e | 2012-04-10 16:02:11 +0000 | [diff] [blame] | 1415 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1416 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1417 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1418 | typename arg9_type>\ |
| 1419 | typename ::testing::internal::Function<F>::Result\ |
| 1420 | GMOCK_ACTION_CLASS_(name, value_params)<\ |
| 1421 | GMOCK_INTERNAL_LIST_##template_params\ |
| 1422 | GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl<F>::\ |
| 1423 | gmock_PerformImpl(\ |
| 1424 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
| 1425 | |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1426 | #define ACTION(name)\ |
| 1427 | class name##Action {\ |
| 1428 | public:\ |
| 1429 | name##Action() {}\ |
| 1430 | template <typename F>\ |
| 1431 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1432 | public:\ |
| 1433 | typedef F function_type;\ |
| 1434 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1435 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1436 | args_type;\ |
| 1437 | gmock_Impl() {}\ |
| 1438 | virtual return_type Perform(const args_type& args) {\ |
| 1439 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1440 | Perform(this, args);\ |
| 1441 | }\ |
| 1442 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1443 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1444 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1445 | typename arg9_type>\ |
| 1446 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1447 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1448 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1449 | arg9_type arg9) const;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1450 | private:\ |
| 1451 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1452 | };\ |
| 1453 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1454 | return ::testing::Action<F>(new gmock_Impl<F>());\ |
| 1455 | }\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1456 | private:\ |
| 1457 | GTEST_DISALLOW_ASSIGN_(name##Action);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1458 | };\ |
| 1459 | inline name##Action name() {\ |
| 1460 | return name##Action();\ |
| 1461 | }\ |
| 1462 | template <typename F>\ |
| 1463 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1464 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1465 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1466 | typename arg9_type>\ |
| 1467 | typename ::testing::internal::Function<F>::Result\ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 1468 | name##Action::gmock_Impl<F>::gmock_PerformImpl(\ |
| 1469 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1470 | |
| 1471 | #define ACTION_P(name, p0)\ |
| 1472 | template <typename p0##_type>\ |
| 1473 | class name##ActionP {\ |
| 1474 | public:\ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1475 | explicit name##ActionP(p0##_type gmock_p0) : \ |
| 1476 | p0(::testing::internal::forward<p0##_type>(gmock_p0)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1477 | template <typename F>\ |
| 1478 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1479 | public:\ |
| 1480 | typedef F function_type;\ |
| 1481 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1482 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1483 | args_type;\ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1484 | explicit gmock_Impl(p0##_type gmock_p0) : \ |
| 1485 | p0(::testing::internal::forward<p0##_type>(gmock_p0)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1486 | virtual return_type Perform(const args_type& args) {\ |
| 1487 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1488 | Perform(this, args);\ |
| 1489 | }\ |
| 1490 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1491 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1492 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1493 | typename arg9_type>\ |
| 1494 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1495 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1496 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1497 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1498 | p0##_type p0;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1499 | private:\ |
| 1500 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1501 | };\ |
| 1502 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1503 | return ::testing::Action<F>(new gmock_Impl<F>(p0));\ |
| 1504 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1505 | p0##_type p0;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1506 | private:\ |
| 1507 | GTEST_DISALLOW_ASSIGN_(name##ActionP);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1508 | };\ |
| 1509 | template <typename p0##_type>\ |
| 1510 | inline name##ActionP<p0##_type> name(p0##_type p0) {\ |
| 1511 | return name##ActionP<p0##_type>(p0);\ |
| 1512 | }\ |
| 1513 | template <typename p0##_type>\ |
| 1514 | template <typename F>\ |
| 1515 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1516 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1517 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1518 | typename arg9_type>\ |
| 1519 | typename ::testing::internal::Function<F>::Result\ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 1520 | name##ActionP<p0##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 1521 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1522 | |
| 1523 | #define ACTION_P2(name, p0, p1)\ |
| 1524 | template <typename p0##_type, typename p1##_type>\ |
| 1525 | class name##ActionP2 {\ |
| 1526 | public:\ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1527 | name##ActionP2(p0##_type gmock_p0, \ |
| 1528 | p1##_type gmock_p1) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1529 | p1(::testing::internal::forward<p1##_type>(gmock_p1)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1530 | template <typename F>\ |
| 1531 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1532 | public:\ |
| 1533 | typedef F function_type;\ |
| 1534 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1535 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1536 | args_type;\ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1537 | gmock_Impl(p0##_type gmock_p0, \ |
| 1538 | p1##_type gmock_p1) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1539 | p1(::testing::internal::forward<p1##_type>(gmock_p1)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1540 | virtual return_type Perform(const args_type& args) {\ |
| 1541 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1542 | Perform(this, args);\ |
| 1543 | }\ |
| 1544 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1545 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1546 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1547 | typename arg9_type>\ |
| 1548 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1549 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1550 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1551 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1552 | p0##_type p0;\ |
| 1553 | p1##_type p1;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1554 | private:\ |
| 1555 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1556 | };\ |
| 1557 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1558 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1));\ |
| 1559 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1560 | p0##_type p0;\ |
| 1561 | p1##_type p1;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1562 | private:\ |
| 1563 | GTEST_DISALLOW_ASSIGN_(name##ActionP2);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1564 | };\ |
| 1565 | template <typename p0##_type, typename p1##_type>\ |
| 1566 | inline name##ActionP2<p0##_type, p1##_type> name(p0##_type p0, \ |
| 1567 | p1##_type p1) {\ |
| 1568 | return name##ActionP2<p0##_type, p1##_type>(p0, p1);\ |
| 1569 | }\ |
| 1570 | template <typename p0##_type, typename p1##_type>\ |
| 1571 | template <typename F>\ |
| 1572 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1573 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1574 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1575 | typename arg9_type>\ |
| 1576 | typename ::testing::internal::Function<F>::Result\ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 1577 | name##ActionP2<p0##_type, p1##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 1578 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1579 | |
| 1580 | #define ACTION_P3(name, p0, p1, p2)\ |
| 1581 | template <typename p0##_type, typename p1##_type, typename p2##_type>\ |
| 1582 | class name##ActionP3 {\ |
| 1583 | public:\ |
| 1584 | name##ActionP3(p0##_type gmock_p0, p1##_type gmock_p1, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1585 | p2##_type gmock_p2) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1586 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1587 | p2(::testing::internal::forward<p2##_type>(gmock_p2)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1588 | template <typename F>\ |
| 1589 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1590 | public:\ |
| 1591 | typedef F function_type;\ |
| 1592 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1593 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1594 | args_type;\ |
| 1595 | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1596 | p2##_type gmock_p2) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1597 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1598 | p2(::testing::internal::forward<p2##_type>(gmock_p2)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1599 | virtual return_type Perform(const args_type& args) {\ |
| 1600 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1601 | Perform(this, args);\ |
| 1602 | }\ |
| 1603 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1604 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1605 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1606 | typename arg9_type>\ |
| 1607 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1608 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1609 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1610 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1611 | p0##_type p0;\ |
| 1612 | p1##_type p1;\ |
| 1613 | p2##_type p2;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1614 | private:\ |
| 1615 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1616 | };\ |
| 1617 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1618 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2));\ |
| 1619 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1620 | p0##_type p0;\ |
| 1621 | p1##_type p1;\ |
| 1622 | p2##_type p2;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1623 | private:\ |
| 1624 | GTEST_DISALLOW_ASSIGN_(name##ActionP3);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1625 | };\ |
| 1626 | template <typename p0##_type, typename p1##_type, typename p2##_type>\ |
| 1627 | inline name##ActionP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \ |
| 1628 | p1##_type p1, p2##_type p2) {\ |
| 1629 | return name##ActionP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\ |
| 1630 | }\ |
| 1631 | template <typename p0##_type, typename p1##_type, typename p2##_type>\ |
| 1632 | template <typename F>\ |
| 1633 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1634 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1635 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1636 | typename arg9_type>\ |
| 1637 | typename ::testing::internal::Function<F>::Result\ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 1638 | name##ActionP3<p0##_type, p1##_type, \ |
| 1639 | p2##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 1640 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1641 | |
| 1642 | #define ACTION_P4(name, p0, p1, p2, p3)\ |
| 1643 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1644 | typename p3##_type>\ |
| 1645 | class name##ActionP4 {\ |
| 1646 | public:\ |
| 1647 | name##ActionP4(p0##_type gmock_p0, p1##_type gmock_p1, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1648 | p2##_type gmock_p2, \ |
| 1649 | p3##_type gmock_p3) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1650 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1651 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1652 | p3(::testing::internal::forward<p3##_type>(gmock_p3)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1653 | template <typename F>\ |
| 1654 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1655 | public:\ |
| 1656 | typedef F function_type;\ |
| 1657 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1658 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1659 | args_type;\ |
| 1660 | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1661 | p3##_type gmock_p3) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1662 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1663 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1664 | p3(::testing::internal::forward<p3##_type>(gmock_p3)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1665 | virtual return_type Perform(const args_type& args) {\ |
| 1666 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1667 | Perform(this, args);\ |
| 1668 | }\ |
| 1669 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1670 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1671 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1672 | typename arg9_type>\ |
| 1673 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1674 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1675 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1676 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1677 | p0##_type p0;\ |
| 1678 | p1##_type p1;\ |
| 1679 | p2##_type p2;\ |
| 1680 | p3##_type p3;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1681 | private:\ |
| 1682 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1683 | };\ |
| 1684 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1685 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3));\ |
| 1686 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1687 | p0##_type p0;\ |
| 1688 | p1##_type p1;\ |
| 1689 | p2##_type p2;\ |
| 1690 | p3##_type p3;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1691 | private:\ |
| 1692 | GTEST_DISALLOW_ASSIGN_(name##ActionP4);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1693 | };\ |
| 1694 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1695 | typename p3##_type>\ |
| 1696 | inline name##ActionP4<p0##_type, p1##_type, p2##_type, \ |
| 1697 | p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \ |
| 1698 | p3##_type p3) {\ |
| 1699 | return name##ActionP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, p1, \ |
| 1700 | p2, p3);\ |
| 1701 | }\ |
| 1702 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1703 | typename p3##_type>\ |
| 1704 | template <typename F>\ |
| 1705 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1706 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1707 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1708 | typename arg9_type>\ |
| 1709 | typename ::testing::internal::Function<F>::Result\ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 1710 | name##ActionP4<p0##_type, p1##_type, p2##_type, \ |
| 1711 | p3##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 1712 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1713 | |
| 1714 | #define ACTION_P5(name, p0, p1, p2, p3, p4)\ |
| 1715 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1716 | typename p3##_type, typename p4##_type>\ |
| 1717 | class name##ActionP5 {\ |
| 1718 | public:\ |
| 1719 | name##ActionP5(p0##_type gmock_p0, p1##_type gmock_p1, \ |
| 1720 | p2##_type gmock_p2, p3##_type gmock_p3, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1721 | p4##_type gmock_p4) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1722 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1723 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1724 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 1725 | p4(::testing::internal::forward<p4##_type>(gmock_p4)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1726 | template <typename F>\ |
| 1727 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1728 | public:\ |
| 1729 | typedef F function_type;\ |
| 1730 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1731 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1732 | args_type;\ |
| 1733 | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1734 | p3##_type gmock_p3, \ |
| 1735 | p4##_type gmock_p4) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1736 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1737 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1738 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 1739 | p4(::testing::internal::forward<p4##_type>(gmock_p4)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1740 | virtual return_type Perform(const args_type& args) {\ |
| 1741 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1742 | Perform(this, args);\ |
| 1743 | }\ |
| 1744 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1745 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1746 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1747 | typename arg9_type>\ |
| 1748 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1749 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1750 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1751 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1752 | p0##_type p0;\ |
| 1753 | p1##_type p1;\ |
| 1754 | p2##_type p2;\ |
| 1755 | p3##_type p3;\ |
| 1756 | p4##_type p4;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1757 | private:\ |
| 1758 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1759 | };\ |
| 1760 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1761 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4));\ |
| 1762 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1763 | p0##_type p0;\ |
| 1764 | p1##_type p1;\ |
| 1765 | p2##_type p2;\ |
| 1766 | p3##_type p3;\ |
| 1767 | p4##_type p4;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1768 | private:\ |
| 1769 | GTEST_DISALLOW_ASSIGN_(name##ActionP5);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1770 | };\ |
| 1771 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1772 | typename p3##_type, typename p4##_type>\ |
| 1773 | inline name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 1774 | p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ |
| 1775 | p4##_type p4) {\ |
| 1776 | return name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 1777 | p4##_type>(p0, p1, p2, p3, p4);\ |
| 1778 | }\ |
| 1779 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1780 | typename p3##_type, typename p4##_type>\ |
| 1781 | template <typename F>\ |
| 1782 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1783 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1784 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1785 | typename arg9_type>\ |
| 1786 | typename ::testing::internal::Function<F>::Result\ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 1787 | name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 1788 | p4##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 1789 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1790 | |
| 1791 | #define ACTION_P6(name, p0, p1, p2, p3, p4, p5)\ |
| 1792 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1793 | typename p3##_type, typename p4##_type, typename p5##_type>\ |
| 1794 | class name##ActionP6 {\ |
| 1795 | public:\ |
| 1796 | name##ActionP6(p0##_type gmock_p0, p1##_type gmock_p1, \ |
| 1797 | p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1798 | p5##_type gmock_p5) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1799 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1800 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1801 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 1802 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 1803 | p5(::testing::internal::forward<p5##_type>(gmock_p5)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1804 | template <typename F>\ |
| 1805 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1806 | public:\ |
| 1807 | typedef F function_type;\ |
| 1808 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1809 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1810 | args_type;\ |
| 1811 | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 1812 | p3##_type gmock_p3, p4##_type gmock_p4, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1813 | p5##_type gmock_p5) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1814 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1815 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1816 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 1817 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 1818 | p5(::testing::internal::forward<p5##_type>(gmock_p5)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1819 | virtual return_type Perform(const args_type& args) {\ |
| 1820 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1821 | Perform(this, args);\ |
| 1822 | }\ |
| 1823 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1824 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1825 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1826 | typename arg9_type>\ |
| 1827 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1828 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1829 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1830 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1831 | p0##_type p0;\ |
| 1832 | p1##_type p1;\ |
| 1833 | p2##_type p2;\ |
| 1834 | p3##_type p3;\ |
| 1835 | p4##_type p4;\ |
| 1836 | p5##_type p5;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1837 | private:\ |
| 1838 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1839 | };\ |
| 1840 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1841 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5));\ |
| 1842 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1843 | p0##_type p0;\ |
| 1844 | p1##_type p1;\ |
| 1845 | p2##_type p2;\ |
| 1846 | p3##_type p3;\ |
| 1847 | p4##_type p4;\ |
| 1848 | p5##_type p5;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1849 | private:\ |
| 1850 | GTEST_DISALLOW_ASSIGN_(name##ActionP6);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1851 | };\ |
| 1852 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1853 | typename p3##_type, typename p4##_type, typename p5##_type>\ |
| 1854 | inline name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 1855 | p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \ |
| 1856 | p3##_type p3, p4##_type p4, p5##_type p5) {\ |
| 1857 | return name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 1858 | p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\ |
| 1859 | }\ |
| 1860 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1861 | typename p3##_type, typename p4##_type, typename p5##_type>\ |
| 1862 | template <typename F>\ |
| 1863 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1864 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1865 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1866 | typename arg9_type>\ |
| 1867 | typename ::testing::internal::Function<F>::Result\ |
| 1868 | name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 1869 | p5##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 1870 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1871 | |
| 1872 | #define ACTION_P7(name, p0, p1, p2, p3, p4, p5, p6)\ |
| 1873 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1874 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 1875 | typename p6##_type>\ |
| 1876 | class name##ActionP7 {\ |
| 1877 | public:\ |
| 1878 | name##ActionP7(p0##_type gmock_p0, p1##_type gmock_p1, \ |
| 1879 | p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1880 | p5##_type gmock_p5, \ |
| 1881 | p6##_type gmock_p6) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1882 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1883 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1884 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 1885 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 1886 | p5(::testing::internal::forward<p5##_type>(gmock_p5)), \ |
| 1887 | p6(::testing::internal::forward<p6##_type>(gmock_p6)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1888 | template <typename F>\ |
| 1889 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1890 | public:\ |
| 1891 | typedef F function_type;\ |
| 1892 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1893 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1894 | args_type;\ |
| 1895 | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 1896 | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1897 | p6##_type gmock_p6) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1898 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1899 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1900 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 1901 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 1902 | p5(::testing::internal::forward<p5##_type>(gmock_p5)), \ |
| 1903 | p6(::testing::internal::forward<p6##_type>(gmock_p6)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1904 | virtual return_type Perform(const args_type& args) {\ |
| 1905 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1906 | Perform(this, args);\ |
| 1907 | }\ |
| 1908 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1909 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1910 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1911 | typename arg9_type>\ |
| 1912 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1913 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1914 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1915 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1916 | p0##_type p0;\ |
| 1917 | p1##_type p1;\ |
| 1918 | p2##_type p2;\ |
| 1919 | p3##_type p3;\ |
| 1920 | p4##_type p4;\ |
| 1921 | p5##_type p5;\ |
| 1922 | p6##_type p6;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1923 | private:\ |
| 1924 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1925 | };\ |
| 1926 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1927 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \ |
| 1928 | p6));\ |
| 1929 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1930 | p0##_type p0;\ |
| 1931 | p1##_type p1;\ |
| 1932 | p2##_type p2;\ |
| 1933 | p3##_type p3;\ |
| 1934 | p4##_type p4;\ |
| 1935 | p5##_type p5;\ |
| 1936 | p6##_type p6;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1937 | private:\ |
| 1938 | GTEST_DISALLOW_ASSIGN_(name##ActionP7);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1939 | };\ |
| 1940 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1941 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 1942 | typename p6##_type>\ |
| 1943 | inline name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 1944 | p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \ |
| 1945 | p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \ |
| 1946 | p6##_type p6) {\ |
| 1947 | return name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 1948 | p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\ |
| 1949 | }\ |
| 1950 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1951 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 1952 | typename p6##_type>\ |
| 1953 | template <typename F>\ |
| 1954 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1955 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1956 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1957 | typename arg9_type>\ |
| 1958 | typename ::testing::internal::Function<F>::Result\ |
| 1959 | name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 1960 | p5##_type, p6##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 1961 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1962 | |
| 1963 | #define ACTION_P8(name, p0, p1, p2, p3, p4, p5, p6, p7)\ |
| 1964 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1965 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 1966 | typename p6##_type, typename p7##_type>\ |
| 1967 | class name##ActionP8 {\ |
| 1968 | public:\ |
| 1969 | name##ActionP8(p0##_type gmock_p0, p1##_type gmock_p1, \ |
| 1970 | p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ |
| 1971 | p5##_type gmock_p5, p6##_type gmock_p6, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1972 | p7##_type gmock_p7) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1973 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1974 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1975 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 1976 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 1977 | p5(::testing::internal::forward<p5##_type>(gmock_p5)), \ |
| 1978 | p6(::testing::internal::forward<p6##_type>(gmock_p6)), \ |
| 1979 | p7(::testing::internal::forward<p7##_type>(gmock_p7)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1980 | template <typename F>\ |
| 1981 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1982 | public:\ |
| 1983 | typedef F function_type;\ |
| 1984 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1985 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1986 | args_type;\ |
| 1987 | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 1988 | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 1989 | p6##_type gmock_p6, \ |
| 1990 | p7##_type gmock_p7) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1991 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1992 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1993 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 1994 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 1995 | p5(::testing::internal::forward<p5##_type>(gmock_p5)), \ |
| 1996 | p6(::testing::internal::forward<p6##_type>(gmock_p6)), \ |
| 1997 | p7(::testing::internal::forward<p7##_type>(gmock_p7)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1998 | virtual return_type Perform(const args_type& args) {\ |
| 1999 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 2000 | Perform(this, args);\ |
| 2001 | }\ |
| 2002 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 2003 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 2004 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 2005 | typename arg9_type>\ |
| 2006 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 2007 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 2008 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 2009 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 2010 | p0##_type p0;\ |
| 2011 | p1##_type p1;\ |
| 2012 | p2##_type p2;\ |
| 2013 | p3##_type p3;\ |
| 2014 | p4##_type p4;\ |
| 2015 | p5##_type p5;\ |
| 2016 | p6##_type p6;\ |
| 2017 | p7##_type p7;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2018 | private:\ |
| 2019 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2020 | };\ |
| 2021 | template <typename F> operator ::testing::Action<F>() const {\ |
| 2022 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \ |
| 2023 | p6, p7));\ |
| 2024 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 2025 | p0##_type p0;\ |
| 2026 | p1##_type p1;\ |
| 2027 | p2##_type p2;\ |
| 2028 | p3##_type p3;\ |
| 2029 | p4##_type p4;\ |
| 2030 | p5##_type p5;\ |
| 2031 | p6##_type p6;\ |
| 2032 | p7##_type p7;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2033 | private:\ |
| 2034 | GTEST_DISALLOW_ASSIGN_(name##ActionP8);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2035 | };\ |
| 2036 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 2037 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 2038 | typename p6##_type, typename p7##_type>\ |
| 2039 | inline name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 2040 | p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \ |
| 2041 | p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \ |
| 2042 | p6##_type p6, p7##_type p7) {\ |
| 2043 | return name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 2044 | p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \ |
| 2045 | p6, p7);\ |
| 2046 | }\ |
| 2047 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 2048 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 2049 | typename p6##_type, typename p7##_type>\ |
| 2050 | template <typename F>\ |
| 2051 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 2052 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 2053 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 2054 | typename arg9_type>\ |
| 2055 | typename ::testing::internal::Function<F>::Result\ |
| 2056 | name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 2057 | p5##_type, p6##_type, \ |
| 2058 | p7##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 2059 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2060 | |
| 2061 | #define ACTION_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8)\ |
| 2062 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 2063 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 2064 | typename p6##_type, typename p7##_type, typename p8##_type>\ |
| 2065 | class name##ActionP9 {\ |
| 2066 | public:\ |
| 2067 | name##ActionP9(p0##_type gmock_p0, p1##_type gmock_p1, \ |
| 2068 | p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ |
| 2069 | p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 2070 | p8##_type gmock_p8) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 2071 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 2072 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 2073 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 2074 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 2075 | p5(::testing::internal::forward<p5##_type>(gmock_p5)), \ |
| 2076 | p6(::testing::internal::forward<p6##_type>(gmock_p6)), \ |
| 2077 | p7(::testing::internal::forward<p7##_type>(gmock_p7)), \ |
| 2078 | p8(::testing::internal::forward<p8##_type>(gmock_p8)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2079 | template <typename F>\ |
| 2080 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 2081 | public:\ |
| 2082 | typedef F function_type;\ |
| 2083 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 2084 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 2085 | args_type;\ |
| 2086 | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 2087 | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ |
| 2088 | p6##_type gmock_p6, p7##_type gmock_p7, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 2089 | p8##_type gmock_p8) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 2090 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 2091 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 2092 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 2093 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 2094 | p5(::testing::internal::forward<p5##_type>(gmock_p5)), \ |
| 2095 | p6(::testing::internal::forward<p6##_type>(gmock_p6)), \ |
| 2096 | p7(::testing::internal::forward<p7##_type>(gmock_p7)), \ |
| 2097 | p8(::testing::internal::forward<p8##_type>(gmock_p8)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2098 | virtual return_type Perform(const args_type& args) {\ |
| 2099 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 2100 | Perform(this, args);\ |
| 2101 | }\ |
| 2102 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 2103 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 2104 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 2105 | typename arg9_type>\ |
| 2106 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 2107 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 2108 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 2109 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 2110 | p0##_type p0;\ |
| 2111 | p1##_type p1;\ |
| 2112 | p2##_type p2;\ |
| 2113 | p3##_type p3;\ |
| 2114 | p4##_type p4;\ |
| 2115 | p5##_type p5;\ |
| 2116 | p6##_type p6;\ |
| 2117 | p7##_type p7;\ |
| 2118 | p8##_type p8;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2119 | private:\ |
| 2120 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2121 | };\ |
| 2122 | template <typename F> operator ::testing::Action<F>() const {\ |
| 2123 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \ |
| 2124 | p6, p7, p8));\ |
| 2125 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 2126 | p0##_type p0;\ |
| 2127 | p1##_type p1;\ |
| 2128 | p2##_type p2;\ |
| 2129 | p3##_type p3;\ |
| 2130 | p4##_type p4;\ |
| 2131 | p5##_type p5;\ |
| 2132 | p6##_type p6;\ |
| 2133 | p7##_type p7;\ |
| 2134 | p8##_type p8;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2135 | private:\ |
| 2136 | GTEST_DISALLOW_ASSIGN_(name##ActionP9);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2137 | };\ |
| 2138 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 2139 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 2140 | typename p6##_type, typename p7##_type, typename p8##_type>\ |
| 2141 | inline name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 2142 | p4##_type, p5##_type, p6##_type, p7##_type, \ |
| 2143 | p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ |
| 2144 | p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \ |
| 2145 | p8##_type p8) {\ |
| 2146 | return name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 2147 | p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \ |
| 2148 | p3, p4, p5, p6, p7, p8);\ |
| 2149 | }\ |
| 2150 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 2151 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 2152 | typename p6##_type, typename p7##_type, typename p8##_type>\ |
| 2153 | template <typename F>\ |
| 2154 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 2155 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 2156 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 2157 | typename arg9_type>\ |
| 2158 | typename ::testing::internal::Function<F>::Result\ |
| 2159 | name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 2160 | p5##_type, p6##_type, p7##_type, \ |
| 2161 | p8##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 2162 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2163 | |
| 2164 | #define ACTION_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)\ |
| 2165 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 2166 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 2167 | typename p6##_type, typename p7##_type, typename p8##_type, \ |
| 2168 | typename p9##_type>\ |
| 2169 | class name##ActionP10 {\ |
| 2170 | public:\ |
| 2171 | name##ActionP10(p0##_type gmock_p0, p1##_type gmock_p1, \ |
| 2172 | p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ |
| 2173 | p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 2174 | p8##_type gmock_p8, \ |
| 2175 | p9##_type gmock_p9) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 2176 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 2177 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 2178 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 2179 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 2180 | p5(::testing::internal::forward<p5##_type>(gmock_p5)), \ |
| 2181 | p6(::testing::internal::forward<p6##_type>(gmock_p6)), \ |
| 2182 | p7(::testing::internal::forward<p7##_type>(gmock_p7)), \ |
| 2183 | p8(::testing::internal::forward<p8##_type>(gmock_p8)), \ |
| 2184 | p9(::testing::internal::forward<p9##_type>(gmock_p9)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2185 | template <typename F>\ |
| 2186 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 2187 | public:\ |
| 2188 | typedef F function_type;\ |
| 2189 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 2190 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 2191 | args_type;\ |
| 2192 | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 2193 | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ |
| 2194 | p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 2195 | p9##_type gmock_p9) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 2196 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 2197 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 2198 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 2199 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 2200 | p5(::testing::internal::forward<p5##_type>(gmock_p5)), \ |
| 2201 | p6(::testing::internal::forward<p6##_type>(gmock_p6)), \ |
| 2202 | p7(::testing::internal::forward<p7##_type>(gmock_p7)), \ |
| 2203 | p8(::testing::internal::forward<p8##_type>(gmock_p8)), \ |
| 2204 | p9(::testing::internal::forward<p9##_type>(gmock_p9)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2205 | virtual return_type Perform(const args_type& args) {\ |
| 2206 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 2207 | Perform(this, args);\ |
| 2208 | }\ |
| 2209 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 2210 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 2211 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 2212 | typename arg9_type>\ |
| 2213 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 2214 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 2215 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 2216 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 2217 | p0##_type p0;\ |
| 2218 | p1##_type p1;\ |
| 2219 | p2##_type p2;\ |
| 2220 | p3##_type p3;\ |
| 2221 | p4##_type p4;\ |
| 2222 | p5##_type p5;\ |
| 2223 | p6##_type p6;\ |
| 2224 | p7##_type p7;\ |
| 2225 | p8##_type p8;\ |
| 2226 | p9##_type p9;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2227 | private:\ |
| 2228 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2229 | };\ |
| 2230 | template <typename F> operator ::testing::Action<F>() const {\ |
| 2231 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \ |
| 2232 | p6, p7, p8, p9));\ |
| 2233 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 2234 | p0##_type p0;\ |
| 2235 | p1##_type p1;\ |
| 2236 | p2##_type p2;\ |
| 2237 | p3##_type p3;\ |
| 2238 | p4##_type p4;\ |
| 2239 | p5##_type p5;\ |
| 2240 | p6##_type p6;\ |
| 2241 | p7##_type p7;\ |
| 2242 | p8##_type p8;\ |
| 2243 | p9##_type p9;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2244 | private:\ |
| 2245 | GTEST_DISALLOW_ASSIGN_(name##ActionP10);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2246 | };\ |
| 2247 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 2248 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 2249 | typename p6##_type, typename p7##_type, typename p8##_type, \ |
| 2250 | typename p9##_type>\ |
| 2251 | inline name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 2252 | p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \ |
| 2253 | p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ |
| 2254 | p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \ |
| 2255 | p9##_type p9) {\ |
| 2256 | return name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 2257 | p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \ |
| 2258 | p1, p2, p3, p4, p5, p6, p7, p8, p9);\ |
| 2259 | }\ |
| 2260 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 2261 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 2262 | typename p6##_type, typename p7##_type, typename p8##_type, \ |
| 2263 | typename p9##_type>\ |
| 2264 | template <typename F>\ |
| 2265 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 2266 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 2267 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 2268 | typename arg9_type>\ |
| 2269 | typename ::testing::internal::Function<F>::Result\ |
| 2270 | name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 2271 | p5##_type, p6##_type, p7##_type, p8##_type, \ |
| 2272 | p9##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 2273 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2274 | |
zhanyong.wan | e1cdce5 | 2009-02-06 01:09:43 +0000 | [diff] [blame] | 2275 | namespace testing { |
| 2276 | |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2277 | |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2278 | // The ACTION*() macros trigger warning C4100 (unreferenced formal |
| 2279 | // parameter) in MSVC with -W4. Unfortunately they cannot be fixed in |
| 2280 | // the macro definition, as the warnings are generated when the macro |
| 2281 | // is expanded and macro expansion cannot contain #pragma. Therefore |
| 2282 | // we suppress them here. |
| 2283 | #ifdef _MSC_VER |
zhanyong.wan | 658ac0b | 2011-02-24 07:29:13 +0000 | [diff] [blame] | 2284 | # pragma warning(push) |
| 2285 | # pragma warning(disable:4100) |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2286 | #endif |
| 2287 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2288 | // Various overloads for InvokeArgument<N>(). |
| 2289 | // |
| 2290 | // The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th |
| 2291 | // (0-based) argument, which must be a k-ary callable, of the mock |
| 2292 | // function, with arguments a1, a2, ..., a_k. |
| 2293 | // |
| 2294 | // Notes: |
| 2295 | // |
| 2296 | // 1. The arguments are passed by value by default. If you need to |
| 2297 | // pass an argument by reference, wrap it inside ByRef(). For |
| 2298 | // example, |
| 2299 | // |
| 2300 | // InvokeArgument<1>(5, string("Hello"), ByRef(foo)) |
| 2301 | // |
| 2302 | // passes 5 and string("Hello") by value, and passes foo by |
| 2303 | // reference. |
| 2304 | // |
| 2305 | // 2. If the callable takes an argument by reference but ByRef() is |
| 2306 | // not used, it will receive the reference to a copy of the value, |
| 2307 | // instead of the original value. For example, when the 0-th |
| 2308 | // argument of the mock function takes a const string&, the action |
| 2309 | // |
| 2310 | // InvokeArgument<0>(string("Hello")) |
| 2311 | // |
| 2312 | // makes a copy of the temporary string("Hello") object and passes a |
| 2313 | // reference of the copy, instead of the original temporary object, |
| 2314 | // to the callable. This makes it easy for a user to define an |
| 2315 | // InvokeArgument action from temporary values and have it performed |
| 2316 | // later. |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 2317 | |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2318 | namespace internal { |
| 2319 | namespace invoke_argument { |
| 2320 | |
| 2321 | // Appears in InvokeArgumentAdl's argument list to help avoid |
| 2322 | // accidental calls to user functions of the same name. |
| 2323 | struct AdlTag {}; |
| 2324 | |
| 2325 | // InvokeArgumentAdl - a helper for InvokeArgument. |
| 2326 | // The basic overloads are provided here for generic functors. |
| 2327 | // Overloads for other custom-callables are provided in the |
| 2328 | // internal/custom/callback-actions.h header. |
| 2329 | |
| 2330 | template <typename R, typename F> |
| 2331 | R InvokeArgumentAdl(AdlTag, F f) { |
| 2332 | return f(); |
| 2333 | } |
| 2334 | template <typename R, typename F, typename A1> |
| 2335 | R InvokeArgumentAdl(AdlTag, F f, A1 a1) { |
| 2336 | return f(a1); |
| 2337 | } |
| 2338 | template <typename R, typename F, typename A1, typename A2> |
| 2339 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2) { |
| 2340 | return f(a1, a2); |
| 2341 | } |
| 2342 | template <typename R, typename F, typename A1, typename A2, typename A3> |
| 2343 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3) { |
| 2344 | return f(a1, a2, a3); |
| 2345 | } |
| 2346 | template <typename R, typename F, typename A1, typename A2, typename A3, |
| 2347 | typename A4> |
| 2348 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4) { |
| 2349 | return f(a1, a2, a3, a4); |
| 2350 | } |
| 2351 | template <typename R, typename F, typename A1, typename A2, typename A3, |
| 2352 | typename A4, typename A5> |
| 2353 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { |
| 2354 | return f(a1, a2, a3, a4, a5); |
| 2355 | } |
| 2356 | template <typename R, typename F, typename A1, typename A2, typename A3, |
| 2357 | typename A4, typename A5, typename A6> |
| 2358 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { |
| 2359 | return f(a1, a2, a3, a4, a5, a6); |
| 2360 | } |
| 2361 | template <typename R, typename F, typename A1, typename A2, typename A3, |
| 2362 | typename A4, typename A5, typename A6, typename A7> |
| 2363 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, |
| 2364 | A7 a7) { |
| 2365 | return f(a1, a2, a3, a4, a5, a6, a7); |
| 2366 | } |
| 2367 | template <typename R, typename F, typename A1, typename A2, typename A3, |
| 2368 | typename A4, typename A5, typename A6, typename A7, typename A8> |
| 2369 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, |
| 2370 | A7 a7, A8 a8) { |
| 2371 | return f(a1, a2, a3, a4, a5, a6, a7, a8); |
| 2372 | } |
| 2373 | template <typename R, typename F, typename A1, typename A2, typename A3, |
| 2374 | typename A4, typename A5, typename A6, typename A7, typename A8, |
| 2375 | typename A9> |
| 2376 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, |
| 2377 | A7 a7, A8 a8, A9 a9) { |
| 2378 | return f(a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| 2379 | } |
| 2380 | template <typename R, typename F, typename A1, typename A2, typename A3, |
| 2381 | typename A4, typename A5, typename A6, typename A7, typename A8, |
| 2382 | typename A9, typename A10> |
| 2383 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, |
| 2384 | A7 a7, A8 a8, A9 a9, A10 a10) { |
| 2385 | return f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); |
| 2386 | } |
| 2387 | } // namespace invoke_argument |
| 2388 | } // namespace internal |
| 2389 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2390 | ACTION_TEMPLATE(InvokeArgument, |
| 2391 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2392 | AND_0_VALUE_PARAMS()) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2393 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2394 | return InvokeArgumentAdl<return_type>( |
| 2395 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2396 | ::testing::get<k>(args)); |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 2397 | } |
| 2398 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2399 | ACTION_TEMPLATE(InvokeArgument, |
| 2400 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2401 | AND_1_VALUE_PARAMS(p0)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2402 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2403 | return InvokeArgumentAdl<return_type>( |
| 2404 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2405 | ::testing::get<k>(args), p0); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2406 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2407 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2408 | ACTION_TEMPLATE(InvokeArgument, |
| 2409 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2410 | AND_2_VALUE_PARAMS(p0, p1)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2411 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2412 | return InvokeArgumentAdl<return_type>( |
| 2413 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2414 | ::testing::get<k>(args), p0, p1); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2415 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2416 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2417 | ACTION_TEMPLATE(InvokeArgument, |
| 2418 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2419 | AND_3_VALUE_PARAMS(p0, p1, p2)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2420 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2421 | return InvokeArgumentAdl<return_type>( |
| 2422 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2423 | ::testing::get<k>(args), p0, p1, p2); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2424 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2425 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2426 | ACTION_TEMPLATE(InvokeArgument, |
| 2427 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2428 | AND_4_VALUE_PARAMS(p0, p1, p2, p3)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2429 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2430 | return InvokeArgumentAdl<return_type>( |
| 2431 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2432 | ::testing::get<k>(args), p0, p1, p2, p3); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2433 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2434 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2435 | ACTION_TEMPLATE(InvokeArgument, |
| 2436 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2437 | AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2438 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2439 | return InvokeArgumentAdl<return_type>( |
| 2440 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2441 | ::testing::get<k>(args), p0, p1, p2, p3, p4); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2442 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2443 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2444 | ACTION_TEMPLATE(InvokeArgument, |
| 2445 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2446 | AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2447 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2448 | return InvokeArgumentAdl<return_type>( |
| 2449 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2450 | ::testing::get<k>(args), p0, p1, p2, p3, p4, p5); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2451 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2452 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2453 | ACTION_TEMPLATE(InvokeArgument, |
| 2454 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2455 | AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2456 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2457 | return InvokeArgumentAdl<return_type>( |
| 2458 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2459 | ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2460 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2461 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2462 | ACTION_TEMPLATE(InvokeArgument, |
| 2463 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2464 | AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2465 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2466 | return InvokeArgumentAdl<return_type>( |
| 2467 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2468 | ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2469 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2470 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2471 | ACTION_TEMPLATE(InvokeArgument, |
| 2472 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2473 | AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2474 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2475 | return InvokeArgumentAdl<return_type>( |
| 2476 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2477 | ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2478 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2479 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2480 | ACTION_TEMPLATE(InvokeArgument, |
| 2481 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2482 | AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2483 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2484 | return InvokeArgumentAdl<return_type>( |
| 2485 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2486 | ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2487 | } |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 2488 | |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2489 | // Various overloads for ReturnNew<T>(). |
| 2490 | // |
| 2491 | // The ReturnNew<T>(a1, a2, ..., a_k) action returns a pointer to a new |
| 2492 | // instance of type T, constructed on the heap with constructor arguments |
| 2493 | // a1, a2, ..., and a_k. The caller assumes ownership of the returned value. |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2494 | ACTION_TEMPLATE(ReturnNew, |
| 2495 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2496 | AND_0_VALUE_PARAMS()) { |
| 2497 | return new T(); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2498 | } |
| 2499 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2500 | ACTION_TEMPLATE(ReturnNew, |
| 2501 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2502 | AND_1_VALUE_PARAMS(p0)) { |
| 2503 | return new T(p0); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2504 | } |
| 2505 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2506 | ACTION_TEMPLATE(ReturnNew, |
| 2507 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2508 | AND_2_VALUE_PARAMS(p0, p1)) { |
| 2509 | return new T(p0, p1); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2510 | } |
| 2511 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2512 | ACTION_TEMPLATE(ReturnNew, |
| 2513 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2514 | AND_3_VALUE_PARAMS(p0, p1, p2)) { |
| 2515 | return new T(p0, p1, p2); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2516 | } |
| 2517 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2518 | ACTION_TEMPLATE(ReturnNew, |
| 2519 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2520 | AND_4_VALUE_PARAMS(p0, p1, p2, p3)) { |
| 2521 | return new T(p0, p1, p2, p3); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2522 | } |
| 2523 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2524 | ACTION_TEMPLATE(ReturnNew, |
| 2525 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2526 | AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) { |
| 2527 | return new T(p0, p1, p2, p3, p4); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2528 | } |
| 2529 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2530 | ACTION_TEMPLATE(ReturnNew, |
| 2531 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2532 | AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) { |
| 2533 | return new T(p0, p1, p2, p3, p4, p5); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2534 | } |
| 2535 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2536 | ACTION_TEMPLATE(ReturnNew, |
| 2537 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2538 | AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) { |
| 2539 | return new T(p0, p1, p2, p3, p4, p5, p6); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2540 | } |
| 2541 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2542 | ACTION_TEMPLATE(ReturnNew, |
| 2543 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2544 | AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) { |
| 2545 | return new T(p0, p1, p2, p3, p4, p5, p6, p7); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2546 | } |
| 2547 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2548 | ACTION_TEMPLATE(ReturnNew, |
| 2549 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2550 | AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) { |
| 2551 | return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2552 | } |
| 2553 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2554 | ACTION_TEMPLATE(ReturnNew, |
| 2555 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2556 | AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) { |
| 2557 | return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2558 | } |
| 2559 | |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2560 | #ifdef _MSC_VER |
zhanyong.wan | 658ac0b | 2011-02-24 07:29:13 +0000 | [diff] [blame] | 2561 | # pragma warning(pop) |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2562 | #endif |
| 2563 | |
zhanyong.wan | e1cdce5 | 2009-02-06 01:09:43 +0000 | [diff] [blame] | 2564 | } // namespace testing |
| 2565 | |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame^] | 2566 | // Include any custom callback actions added by the local installation. |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2567 | // We must include this header at the end to make sure it can use the |
| 2568 | // declarations from this file. |
kosak | 6e10872 | 2015-07-28 00:53:13 +0000 | [diff] [blame] | 2569 | #include "gmock/internal/custom/gmock-generated-actions.h" |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2570 | |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 2571 | #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ |