googletest/googlemock/test/gmock-function-mocker_test.cc
Go to the documentation of this file.
1 // Copyright 2007, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30 
31 // Google Mock - a framework for writing C++ mock classes.
32 //
33 // This file tests the function mocker classes.
34 #include "gmock/gmock-function-mocker.h"
35 
36 #if GTEST_OS_WINDOWS
37 // MSDN says the header file to be included for STDMETHOD is BaseTyps.h but
38 // we are getting compiler errors if we use basetyps.h, hence including
39 // objbase.h for definition of STDMETHOD.
40 # include <objbase.h>
41 #endif // GTEST_OS_WINDOWS
42 
43 #include <functional>
44 #include <map>
45 #include <string>
46 #include <type_traits>
47 
48 #include "gmock/gmock.h"
49 #include "gtest/gtest.h"
50 
51 namespace testing {
52 namespace gmock_function_mocker_test {
53 
54 using testing::_;
55 using testing::A;
56 using testing::An;
57 using testing::AnyNumber;
58 using testing::Const;
59 using testing::DoDefault;
60 using testing::Eq;
61 using testing::Lt;
63 using testing::Ref;
64 using testing::Return;
65 using testing::ReturnRef;
66 using testing::TypedEq;
67 
68 template<typename T>
69 class TemplatedCopyable {
70  public:
72 
73  template <typename U>
74  TemplatedCopyable(const U& other) {} // NOLINT
75 };
76 
77 class FooInterface {
78  public:
79  virtual ~FooInterface() {}
80 
81  virtual void VoidReturning(int x) = 0;
82 
83  virtual int Nullary() = 0;
84  virtual bool Unary(int x) = 0;
85  virtual long Binary(short x, int y) = 0; // NOLINT
86  virtual int Decimal(bool b, char c, short d, int e, long f, // NOLINT
87  float g, double h, unsigned i, char* j,
88  const std::string& k) = 0;
89 
90  virtual bool TakesNonConstReference(int& n) = 0; // NOLINT
91  virtual std::string TakesConstReference(const int& n) = 0;
92  virtual bool TakesConst(const int x) = 0;
93 
94  virtual int OverloadedOnArgumentNumber() = 0;
95  virtual int OverloadedOnArgumentNumber(int n) = 0;
96 
97  virtual int OverloadedOnArgumentType(int n) = 0;
98  virtual char OverloadedOnArgumentType(char c) = 0;
99 
100  virtual int OverloadedOnConstness() = 0;
101  virtual char OverloadedOnConstness() const = 0;
102 
103  virtual int TypeWithHole(int (*func)()) = 0;
104  virtual int TypeWithComma(const std::map<int, std::string>& a_map) = 0;
105  virtual int TypeWithTemplatedCopyCtor(const TemplatedCopyable<int>&) = 0;
106 
107  virtual int (*ReturnsFunctionPointer1(int))(bool) = 0;
108  using fn_ptr = int (*)(bool);
109  virtual fn_ptr ReturnsFunctionPointer2(int) = 0;
110 
111  virtual int RefQualifiedConstRef() const& = 0;
112  virtual int RefQualifiedConstRefRef() const&& = 0;
113  virtual int RefQualifiedRef() & = 0;
114  virtual int RefQualifiedRefRef() && = 0;
115 
116  virtual int RefQualifiedOverloaded() const& = 0;
117  virtual int RefQualifiedOverloaded() const&& = 0;
118  virtual int RefQualifiedOverloaded() & = 0;
119  virtual int RefQualifiedOverloaded() && = 0;
120 
121 #if GTEST_OS_WINDOWS
122  STDMETHOD_(int, CTNullary)() = 0;
123  STDMETHOD_(bool, CTUnary)(int x) = 0;
124  STDMETHOD_(int, CTDecimal)
125  (bool b, char c, short d, int e, long f, // NOLINT
126  float g, double h, unsigned i, char* j, const std::string& k) = 0;
127  STDMETHOD_(char, CTConst)(int x) const = 0;
128 #endif // GTEST_OS_WINDOWS
129 };
130 
131 // Const qualifiers on arguments were once (incorrectly) considered
132 // significant in determining whether two virtual functions had the same
133 // signature. This was fixed in Visual Studio 2008. However, the compiler
134 // still emits a warning that alerts about this change in behavior.
135 #ifdef _MSC_VER
136 # pragma warning(push)
137 # pragma warning(disable : 4373)
138 #endif
139 class MockFoo : public FooInterface {
140  public:
141  MockFoo() {}
142 
143  // Makes sure that a mock function parameter can be named.
144  MOCK_METHOD(void, VoidReturning, (int n)); // NOLINT
145 
146  MOCK_METHOD(int, Nullary, ()); // NOLINT
147 
148  // Makes sure that a mock function parameter can be unnamed.
149  MOCK_METHOD(bool, Unary, (int)); // NOLINT
150  MOCK_METHOD(long, Binary, (short, int)); // NOLINT
151  MOCK_METHOD(int, Decimal,
152  (bool, char, short, int, long, float, // NOLINT
153  double, unsigned, char*, const std::string& str),
154  (override));
155 
156  MOCK_METHOD(bool, TakesNonConstReference, (int&)); // NOLINT
158  MOCK_METHOD(bool, TakesConst, (const int)); // NOLINT
159 
160  // Tests that the function return type can contain unprotected comma.
161  MOCK_METHOD((std::map<int, std::string>), ReturnTypeWithComma, (), ());
162  MOCK_METHOD((std::map<int, std::string>), ReturnTypeWithComma, (int),
163  (const)); // NOLINT
164 
165  MOCK_METHOD(int, OverloadedOnArgumentNumber, ()); // NOLINT
166  MOCK_METHOD(int, OverloadedOnArgumentNumber, (int)); // NOLINT
167 
168  MOCK_METHOD(int, OverloadedOnArgumentType, (int)); // NOLINT
169  MOCK_METHOD(char, OverloadedOnArgumentType, (char)); // NOLINT
170 
171  MOCK_METHOD(int, OverloadedOnConstness, (), (override)); // NOLINT
172  MOCK_METHOD(char, OverloadedOnConstness, (), (override, const)); // NOLINT
173 
174  MOCK_METHOD(int, TypeWithHole, (int (*)()), ()); // NOLINT
175  MOCK_METHOD(int, TypeWithComma, ((const std::map<int, std::string>&)));
177  (const TemplatedCopyable<int>&)); // NOLINT
178 
179  MOCK_METHOD(int (*)(bool), ReturnsFunctionPointer1, (int), ());
181 
182 #if GTEST_OS_WINDOWS
183  MOCK_METHOD(int, CTNullary, (), (Calltype(STDMETHODCALLTYPE)));
184  MOCK_METHOD(bool, CTUnary, (int), (Calltype(STDMETHODCALLTYPE)));
185  MOCK_METHOD(int, CTDecimal,
186  (bool b, char c, short d, int e, long f, float g, double h,
187  unsigned i, char* j, const std::string& k),
188  (Calltype(STDMETHODCALLTYPE)));
189  MOCK_METHOD(char, CTConst, (int), (const, Calltype(STDMETHODCALLTYPE)));
190  MOCK_METHOD((std::map<int, std::string>), CTReturnTypeWithComma, (),
191  (Calltype(STDMETHODCALLTYPE)));
192 #endif // GTEST_OS_WINDOWS
193 
194  // Test reference qualified functions.
195  MOCK_METHOD(int, RefQualifiedConstRef, (), (const, ref(&), override));
196  MOCK_METHOD(int, RefQualifiedConstRefRef, (), (const, ref(&&), override));
197  MOCK_METHOD(int, RefQualifiedRef, (), (ref(&), override));
198  MOCK_METHOD(int, RefQualifiedRefRef, (), (ref(&&), override));
199 
200  MOCK_METHOD(int, RefQualifiedOverloaded, (), (const, ref(&), override));
201  MOCK_METHOD(int, RefQualifiedOverloaded, (), (const, ref(&&), override));
202  MOCK_METHOD(int, RefQualifiedOverloaded, (), (ref(&), override));
203  MOCK_METHOD(int, RefQualifiedOverloaded, (), (ref(&&), override));
204 
205  private:
207 };
208 
209 class LegacyMockFoo : public FooInterface {
210  public:
212 
213  // Makes sure that a mock function parameter can be named.
214  MOCK_METHOD1(VoidReturning, void(int n)); // NOLINT
215 
216  MOCK_METHOD0(Nullary, int()); // NOLINT
217 
218  // Makes sure that a mock function parameter can be unnamed.
219  MOCK_METHOD1(Unary, bool(int)); // NOLINT
220  MOCK_METHOD2(Binary, long(short, int)); // NOLINT
221  MOCK_METHOD10(Decimal, int(bool, char, short, int, long, float, // NOLINT
222  double, unsigned, char*, const std::string& str));
223 
224  MOCK_METHOD1(TakesNonConstReference, bool(int&)); // NOLINT
226  MOCK_METHOD1(TakesConst, bool(const int)); // NOLINT
227 
228  // Tests that the function return type can contain unprotected comma.
229  MOCK_METHOD0(ReturnTypeWithComma, std::map<int, std::string>());
230  MOCK_CONST_METHOD1(ReturnTypeWithComma,
231  std::map<int, std::string>(int)); // NOLINT
232 
233  MOCK_METHOD0(OverloadedOnArgumentNumber, int()); // NOLINT
234  MOCK_METHOD1(OverloadedOnArgumentNumber, int(int)); // NOLINT
235 
236  MOCK_METHOD1(OverloadedOnArgumentType, int(int)); // NOLINT
237  MOCK_METHOD1(OverloadedOnArgumentType, char(char)); // NOLINT
238 
239  MOCK_METHOD0(OverloadedOnConstness, int()); // NOLINT
240  MOCK_CONST_METHOD0(OverloadedOnConstness, char()); // NOLINT
241 
242  MOCK_METHOD1(TypeWithHole, int(int (*)())); // NOLINT
244  int(const std::map<int, std::string>&)); // NOLINT
246  int(const TemplatedCopyable<int>&)); // NOLINT
247 
248  MOCK_METHOD1(ReturnsFunctionPointer1, int (*(int))(bool));
250 
251 #if GTEST_OS_WINDOWS
252  MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, CTNullary, int());
253  MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, CTUnary, bool(int)); // NOLINT
254  MOCK_METHOD10_WITH_CALLTYPE(STDMETHODCALLTYPE, CTDecimal,
255  int(bool b, char c, short d, int e, // NOLINT
256  long f, float g, double h, // NOLINT
257  unsigned i, char* j, const std::string& k));
258  MOCK_CONST_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, CTConst,
259  char(int)); // NOLINT
260 
261  // Tests that the function return type can contain unprotected comma.
262  MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, CTReturnTypeWithComma,
263  std::map<int, std::string>());
264 #endif // GTEST_OS_WINDOWS
265 
266  // We can't mock these with the old macros, but we need to define them to make
267  // it concrete.
268  int RefQualifiedConstRef() const& override { return 0; }
269  int RefQualifiedConstRefRef() const&& override { return 0; }
270  int RefQualifiedRef() & override { return 0; }
271  int RefQualifiedRefRef() && override { return 0; }
272  int RefQualifiedOverloaded() const& override { return 0; }
273  int RefQualifiedOverloaded() const&& override { return 0; }
274  int RefQualifiedOverloaded() & override { return 0; }
275  int RefQualifiedOverloaded() && override { return 0; }
276 
277  private:
279 };
280 
281 #ifdef _MSC_VER
282 # pragma warning(pop)
283 #endif
284 
285 template <class T>
287  protected:
289 
292 };
295 
296 // Tests mocking a void-returning function.
297 TYPED_TEST(FunctionMockerTest, MocksVoidFunction) {
298  EXPECT_CALL(this->mock_foo_, VoidReturning(Lt(100)));
299  this->foo_->VoidReturning(0);
300 }
301 
302 // Tests mocking a nullary function.
303 TYPED_TEST(FunctionMockerTest, MocksNullaryFunction) {
304  EXPECT_CALL(this->mock_foo_, Nullary())
305  .WillOnce(DoDefault())
306  .WillOnce(Return(1));
307 
308  EXPECT_EQ(0, this->foo_->Nullary());
309  EXPECT_EQ(1, this->foo_->Nullary());
310 }
311 
312 // Tests mocking a unary function.
313 TYPED_TEST(FunctionMockerTest, MocksUnaryFunction) {
314  EXPECT_CALL(this->mock_foo_, Unary(Eq(2))).Times(2).WillOnce(Return(true));
315 
316  EXPECT_TRUE(this->foo_->Unary(2));
317  EXPECT_FALSE(this->foo_->Unary(2));
318 }
319 
320 // Tests mocking a binary function.
321 TYPED_TEST(FunctionMockerTest, MocksBinaryFunction) {
322  EXPECT_CALL(this->mock_foo_, Binary(2, _)).WillOnce(Return(3));
323 
324  EXPECT_EQ(3, this->foo_->Binary(2, 1));
325 }
326 
327 // Tests mocking a decimal function.
328 TYPED_TEST(FunctionMockerTest, MocksDecimalFunction) {
329  EXPECT_CALL(this->mock_foo_,
330  Decimal(true, 'a', 0, 0, 1L, A<float>(), Lt(100), 5U, NULL, "hi"))
331  .WillOnce(Return(5));
332 
333  EXPECT_EQ(5, this->foo_->Decimal(true, 'a', 0, 0, 1, 0, 0, 5, nullptr, "hi"));
334 }
335 
336 // Tests mocking a function that takes a non-const reference.
337 TYPED_TEST(FunctionMockerTest, MocksFunctionWithNonConstReferenceArgument) {
338  int a = 0;
339  EXPECT_CALL(this->mock_foo_, TakesNonConstReference(Ref(a)))
340  .WillOnce(Return(true));
341 
342  EXPECT_TRUE(this->foo_->TakesNonConstReference(a));
343 }
344 
345 // Tests mocking a function that takes a const reference.
346 TYPED_TEST(FunctionMockerTest, MocksFunctionWithConstReferenceArgument) {
347  int a = 0;
348  EXPECT_CALL(this->mock_foo_, TakesConstReference(Ref(a)))
349  .WillOnce(Return("Hello"));
350 
351  EXPECT_EQ("Hello", this->foo_->TakesConstReference(a));
352 }
353 
354 // Tests mocking a function that takes a const variable.
355 TYPED_TEST(FunctionMockerTest, MocksFunctionWithConstArgument) {
356  EXPECT_CALL(this->mock_foo_, TakesConst(Lt(10))).WillOnce(DoDefault());
357 
358  EXPECT_FALSE(this->foo_->TakesConst(5));
359 }
360 
361 // Tests mocking functions overloaded on the number of arguments.
362 TYPED_TEST(FunctionMockerTest, MocksFunctionsOverloadedOnArgumentNumber) {
363  EXPECT_CALL(this->mock_foo_, OverloadedOnArgumentNumber())
364  .WillOnce(Return(1));
365  EXPECT_CALL(this->mock_foo_, OverloadedOnArgumentNumber(_))
366  .WillOnce(Return(2));
367 
368  EXPECT_EQ(2, this->foo_->OverloadedOnArgumentNumber(1));
369  EXPECT_EQ(1, this->foo_->OverloadedOnArgumentNumber());
370 }
371 
372 // Tests mocking functions overloaded on the types of argument.
373 TYPED_TEST(FunctionMockerTest, MocksFunctionsOverloadedOnArgumentType) {
374  EXPECT_CALL(this->mock_foo_, OverloadedOnArgumentType(An<int>()))
375  .WillOnce(Return(1));
376  EXPECT_CALL(this->mock_foo_, OverloadedOnArgumentType(TypedEq<char>('a')))
377  .WillOnce(Return('b'));
378 
379  EXPECT_EQ(1, this->foo_->OverloadedOnArgumentType(0));
380  EXPECT_EQ('b', this->foo_->OverloadedOnArgumentType('a'));
381 }
382 
383 // Tests mocking functions overloaded on the const-ness of this object.
384 TYPED_TEST(FunctionMockerTest, MocksFunctionsOverloadedOnConstnessOfThis) {
385  EXPECT_CALL(this->mock_foo_, OverloadedOnConstness());
386  EXPECT_CALL(Const(this->mock_foo_), OverloadedOnConstness())
387  .WillOnce(Return('a'));
388 
389  EXPECT_EQ(0, this->foo_->OverloadedOnConstness());
390  EXPECT_EQ('a', Const(*this->foo_).OverloadedOnConstness());
391 }
392 
393 TYPED_TEST(FunctionMockerTest, MocksReturnTypeWithComma) {
394  const std::map<int, std::string> a_map;
395  EXPECT_CALL(this->mock_foo_, ReturnTypeWithComma()).WillOnce(Return(a_map));
396  EXPECT_CALL(this->mock_foo_, ReturnTypeWithComma(42)).WillOnce(Return(a_map));
397 
398  EXPECT_EQ(a_map, this->mock_foo_.ReturnTypeWithComma());
399  EXPECT_EQ(a_map, this->mock_foo_.ReturnTypeWithComma(42));
400 }
401 
402 TYPED_TEST(FunctionMockerTest, MocksTypeWithTemplatedCopyCtor) {
403  EXPECT_CALL(this->mock_foo_, TypeWithTemplatedCopyCtor(_))
404  .WillOnce(Return(true));
405  EXPECT_TRUE(this->foo_->TypeWithTemplatedCopyCtor(TemplatedCopyable<int>()));
406 }
407 
408 #if GTEST_OS_WINDOWS
409 // Tests mocking a nullary function with calltype.
410 TYPED_TEST(FunctionMockerTest, MocksNullaryFunctionWithCallType) {
411  EXPECT_CALL(this->mock_foo_, CTNullary())
412  .WillOnce(Return(-1))
413  .WillOnce(Return(0));
414 
415  EXPECT_EQ(-1, this->foo_->CTNullary());
416  EXPECT_EQ(0, this->foo_->CTNullary());
417 }
418 
419 // Tests mocking a unary function with calltype.
420 TYPED_TEST(FunctionMockerTest, MocksUnaryFunctionWithCallType) {
421  EXPECT_CALL(this->mock_foo_, CTUnary(Eq(2)))
422  .Times(2)
423  .WillOnce(Return(true))
424  .WillOnce(Return(false));
425 
426  EXPECT_TRUE(this->foo_->CTUnary(2));
427  EXPECT_FALSE(this->foo_->CTUnary(2));
428 }
429 
430 // Tests mocking a decimal function with calltype.
431 TYPED_TEST(FunctionMockerTest, MocksDecimalFunctionWithCallType) {
432  EXPECT_CALL(this->mock_foo_, CTDecimal(true, 'a', 0, 0, 1L, A<float>(),
433  Lt(100), 5U, NULL, "hi"))
434  .WillOnce(Return(10));
435 
436  EXPECT_EQ(10, this->foo_->CTDecimal(true, 'a', 0, 0, 1, 0, 0, 5, NULL, "hi"));
437 }
438 
439 // Tests mocking functions overloaded on the const-ness of this object.
440 TYPED_TEST(FunctionMockerTest, MocksFunctionsConstFunctionWithCallType) {
441  EXPECT_CALL(Const(this->mock_foo_), CTConst(_)).WillOnce(Return('a'));
442 
443  EXPECT_EQ('a', Const(*this->foo_).CTConst(0));
444 }
445 
446 TYPED_TEST(FunctionMockerTest, MocksReturnTypeWithCommaAndCallType) {
447  const std::map<int, std::string> a_map;
448  EXPECT_CALL(this->mock_foo_, CTReturnTypeWithComma()).WillOnce(Return(a_map));
449 
450  EXPECT_EQ(a_map, this->mock_foo_.CTReturnTypeWithComma());
451 }
452 
453 #endif // GTEST_OS_WINDOWS
454 
455 TEST(FunctionMockerTest, RefQualified) {
457 
458  EXPECT_CALL(mock_foo, RefQualifiedConstRef).WillOnce(Return(1));
459  EXPECT_CALL(std::move(mock_foo), // NOLINT
460  RefQualifiedConstRefRef)
461  .WillOnce(Return(2));
462  EXPECT_CALL(mock_foo, RefQualifiedRef).WillOnce(Return(3));
463  EXPECT_CALL(std::move(mock_foo), // NOLINT
464  RefQualifiedRefRef)
465  .WillOnce(Return(4));
466 
467  EXPECT_CALL(static_cast<const MockFoo&>(mock_foo), RefQualifiedOverloaded())
468  .WillOnce(Return(5));
469  EXPECT_CALL(static_cast<const MockFoo&&>(mock_foo), RefQualifiedOverloaded())
470  .WillOnce(Return(6));
471  EXPECT_CALL(static_cast<MockFoo&>(mock_foo), RefQualifiedOverloaded())
472  .WillOnce(Return(7));
473  EXPECT_CALL(static_cast<MockFoo&&>(mock_foo), RefQualifiedOverloaded())
474  .WillOnce(Return(8));
475 
477  EXPECT_EQ(std::move(mock_foo).RefQualifiedConstRefRef(), 2); // NOLINT
479  EXPECT_EQ(std::move(mock_foo).RefQualifiedRefRef(), 4); // NOLINT
480 
481  EXPECT_EQ(std::cref(mock_foo).get().RefQualifiedOverloaded(), 5);
482  EXPECT_EQ(std::move(std::cref(mock_foo).get()) // NOLINT
483  .RefQualifiedOverloaded(),
484  6);
486  EXPECT_EQ(std::move(mock_foo).RefQualifiedOverloaded(), 8); // NOLINT
487 }
488 
489 class MockB {
490  public:
491  MockB() {}
492 
493  MOCK_METHOD(void, DoB, ());
494 
495  private:
497 };
498 
499 class LegacyMockB {
500  public:
502 
503  MOCK_METHOD0(DoB, void());
504 
505  private:
507 };
508 
509 template <typename T>
510 class ExpectCallTest : public ::testing::Test {};
513 
514 // Tests that functions with no EXPECT_CALL() rules can be called any
515 // number of times.
516 TYPED_TEST(ExpectCallTest, UnmentionedFunctionCanBeCalledAnyNumberOfTimes) {
517  { TypeParam b; }
518 
519  {
520  TypeParam b;
521  b.DoB();
522  }
523 
524  {
525  TypeParam b;
526  b.DoB();
527  b.DoB();
528  }
529 }
530 
531 // Tests mocking template interfaces.
532 
533 template <typename T>
534 class StackInterface {
535  public:
536  virtual ~StackInterface() {}
537 
538  // Template parameter appears in function parameter.
539  virtual void Push(const T& value) = 0;
540  virtual void Pop() = 0;
541  virtual int GetSize() const = 0;
542  // Template parameter appears in function return type.
543  virtual const T& GetTop() const = 0;
544 };
545 
546 template <typename T>
547 class MockStack : public StackInterface<T> {
548  public:
550 
551  MOCK_METHOD(void, Push, (const T& elem), ());
552  MOCK_METHOD(void, Pop, (), (final));
553  MOCK_METHOD(int, GetSize, (), (const, override));
554  MOCK_METHOD(const T&, GetTop, (), (const));
555 
556  // Tests that the function return type can contain unprotected comma.
557  MOCK_METHOD((std::map<int, int>), ReturnTypeWithComma, (), ());
558  MOCK_METHOD((std::map<int, int>), ReturnTypeWithComma, (int), (const));
559 
560  private:
562 };
563 
564 template <typename T>
565 class LegacyMockStack : public StackInterface<T> {
566  public:
568 
569  MOCK_METHOD1_T(Push, void(const T& elem));
570  MOCK_METHOD0_T(Pop, void());
571  MOCK_CONST_METHOD0_T(GetSize, int()); // NOLINT
572  MOCK_CONST_METHOD0_T(GetTop, const T&());
573 
574  // Tests that the function return type can contain unprotected comma.
575  MOCK_METHOD0_T(ReturnTypeWithComma, std::map<int, int>());
576  MOCK_CONST_METHOD1_T(ReturnTypeWithComma, std::map<int, int>(int)); // NOLINT
577 
578  private:
580 };
581 
582 template <typename T>
584 using TemplateMockTestTypes =
587 
588 // Tests that template mock works.
590  TypeParam mock;
591 
592  EXPECT_CALL(mock, GetSize())
593  .WillOnce(Return(0))
594  .WillOnce(Return(1))
595  .WillOnce(Return(0));
596  EXPECT_CALL(mock, Push(_));
597  int n = 5;
598  EXPECT_CALL(mock, GetTop())
599  .WillOnce(ReturnRef(n));
600  EXPECT_CALL(mock, Pop())
601  .Times(AnyNumber());
602 
603  EXPECT_EQ(0, mock.GetSize());
604  mock.Push(5);
605  EXPECT_EQ(1, mock.GetSize());
606  EXPECT_EQ(5, mock.GetTop());
607  mock.Pop();
608  EXPECT_EQ(0, mock.GetSize());
609 }
610 
611 TYPED_TEST(TemplateMockTest, MethodWithCommaInReturnTypeWorks) {
612  TypeParam mock;
613 
614  const std::map<int, int> a_map;
615  EXPECT_CALL(mock, ReturnTypeWithComma())
616  .WillOnce(Return(a_map));
617  EXPECT_CALL(mock, ReturnTypeWithComma(1))
618  .WillOnce(Return(a_map));
619 
620  EXPECT_EQ(a_map, mock.ReturnTypeWithComma());
621  EXPECT_EQ(a_map, mock.ReturnTypeWithComma(1));
622 }
623 
624 #if GTEST_OS_WINDOWS
625 // Tests mocking template interfaces with calltype.
626 
627 template <typename T>
628 class StackInterfaceWithCallType {
629  public:
630  virtual ~StackInterfaceWithCallType() {}
631 
632  // Template parameter appears in function parameter.
633  STDMETHOD_(void, Push)(const T& value) = 0;
634  STDMETHOD_(void, Pop)() = 0;
635  STDMETHOD_(int, GetSize)() const = 0;
636  // Template parameter appears in function return type.
637  STDMETHOD_(const T&, GetTop)() const = 0;
638 };
639 
640 template <typename T>
641 class MockStackWithCallType : public StackInterfaceWithCallType<T> {
642  public:
643  MockStackWithCallType() {}
644 
645  MOCK_METHOD(void, Push, (const T& elem),
646  (Calltype(STDMETHODCALLTYPE), override));
647  MOCK_METHOD(void, Pop, (), (Calltype(STDMETHODCALLTYPE), override));
648  MOCK_METHOD(int, GetSize, (), (Calltype(STDMETHODCALLTYPE), override, const));
649  MOCK_METHOD(const T&, GetTop, (),
650  (Calltype(STDMETHODCALLTYPE), override, const));
651 
652  private:
653  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockStackWithCallType);
654 };
655 
656 template <typename T>
657 class LegacyMockStackWithCallType : public StackInterfaceWithCallType<T> {
658  public:
659  LegacyMockStackWithCallType() {}
660 
661  MOCK_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Push, void(const T& elem));
662  MOCK_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Pop, void());
663  MOCK_CONST_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, GetSize, int());
664  MOCK_CONST_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, GetTop, const T&());
665 
666  private:
667  GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockStackWithCallType);
668 };
669 
670 template <typename T>
671 class TemplateMockTestWithCallType : public ::testing::Test {};
672 using TemplateMockTestWithCallTypeTypes =
674  LegacyMockStackWithCallType<int>>;
675 TYPED_TEST_SUITE(TemplateMockTestWithCallType,
676  TemplateMockTestWithCallTypeTypes);
677 
678 // Tests that template mock with calltype works.
679 TYPED_TEST(TemplateMockTestWithCallType, Works) {
680  TypeParam mock;
681 
682  EXPECT_CALL(mock, GetSize())
683  .WillOnce(Return(0))
684  .WillOnce(Return(1))
685  .WillOnce(Return(0));
686  EXPECT_CALL(mock, Push(_));
687  int n = 5;
688  EXPECT_CALL(mock, GetTop())
689  .WillOnce(ReturnRef(n));
690  EXPECT_CALL(mock, Pop())
691  .Times(AnyNumber());
692 
693  EXPECT_EQ(0, mock.GetSize());
694  mock.Push(5);
695  EXPECT_EQ(1, mock.GetSize());
696  EXPECT_EQ(5, mock.GetTop());
697  mock.Pop();
698  EXPECT_EQ(0, mock.GetSize());
699 }
700 #endif // GTEST_OS_WINDOWS
701 
702 #define MY_MOCK_METHODS1_ \
703  MOCK_METHOD(void, Overloaded, ()); \
704  MOCK_METHOD(int, Overloaded, (int), (const)); \
705  MOCK_METHOD(bool, Overloaded, (bool f, int n))
706 
707 #define LEGACY_MY_MOCK_METHODS1_ \
708  MOCK_METHOD0(Overloaded, void()); \
709  MOCK_CONST_METHOD1(Overloaded, int(int n)); \
710  MOCK_METHOD2(Overloaded, bool(bool f, int n))
711 
712 class MockOverloadedOnArgNumber {
713  public:
715 
717 
718  private:
720 };
721 
723  public:
725 
727 
728  private:
730 };
731 
732 template <typename T>
738 
739 TYPED_TEST(OverloadedMockMethodTest, CanOverloadOnArgNumberInMacroBody) {
740  TypeParam mock;
741  EXPECT_CALL(mock, Overloaded());
742  EXPECT_CALL(mock, Overloaded(1)).WillOnce(Return(2));
743  EXPECT_CALL(mock, Overloaded(true, 1)).WillOnce(Return(true));
744 
745  mock.Overloaded();
746  EXPECT_EQ(2, mock.Overloaded(1));
747  EXPECT_TRUE(mock.Overloaded(true, 1));
748 }
749 
750 #define MY_MOCK_METHODS2_ \
751  MOCK_CONST_METHOD1(Overloaded, int(int n)); \
752  MOCK_METHOD1(Overloaded, int(int n))
753 
754 class MockOverloadedOnConstness {
755  public:
757 
759 
760  private:
762 };
763 
764 TEST(MockMethodOverloadedMockMethodTest, CanOverloadOnConstnessInMacroBody) {
765  MockOverloadedOnConstness mock;
766  const MockOverloadedOnConstness* const_mock = &mock;
767  EXPECT_CALL(mock, Overloaded(1)).WillOnce(Return(2));
768  EXPECT_CALL(*const_mock, Overloaded(1)).WillOnce(Return(3));
769 
770  EXPECT_EQ(2, mock.Overloaded(1));
771  EXPECT_EQ(3, const_mock->Overloaded(1));
772 }
773 
774 TEST(MockMethodMockFunctionTest, WorksForVoidNullary) {
775  MockFunction<void()> foo;
776  EXPECT_CALL(foo, Call());
777  foo.Call();
778 }
779 
780 TEST(MockMethodMockFunctionTest, WorksForNonVoidNullary) {
781  MockFunction<int()> foo;
782  EXPECT_CALL(foo, Call())
783  .WillOnce(Return(1))
784  .WillOnce(Return(2));
785  EXPECT_EQ(1, foo.Call());
786  EXPECT_EQ(2, foo.Call());
787 }
788 
789 TEST(MockMethodMockFunctionTest, WorksForVoidUnary) {
790  MockFunction<void(int)> foo;
791  EXPECT_CALL(foo, Call(1));
792  foo.Call(1);
793 }
794 
795 TEST(MockMethodMockFunctionTest, WorksForNonVoidBinary) {
796  MockFunction<int(bool, int)> foo;
797  EXPECT_CALL(foo, Call(false, 42))
798  .WillOnce(Return(1))
799  .WillOnce(Return(2));
800  EXPECT_CALL(foo, Call(true, Ge(100)))
801  .WillOnce(Return(3));
802  EXPECT_EQ(1, foo.Call(false, 42));
803  EXPECT_EQ(2, foo.Call(false, 42));
804  EXPECT_EQ(3, foo.Call(true, 120));
805 }
806 
807 TEST(MockMethodMockFunctionTest, WorksFor10Arguments) {
808  MockFunction<int(bool a0, char a1, int a2, int a3, int a4,
809  int a5, int a6, char a7, int a8, bool a9)> foo;
810  EXPECT_CALL(foo, Call(_, 'a', _, _, _, _, _, _, _, _))
811  .WillOnce(Return(1))
812  .WillOnce(Return(2));
813  EXPECT_EQ(1, foo.Call(false, 'a', 0, 0, 0, 0, 0, 'b', 0, true));
814  EXPECT_EQ(2, foo.Call(true, 'a', 0, 0, 0, 0, 0, 'b', 1, false));
815 }
816 
817 TEST(MockMethodMockFunctionTest, AsStdFunction) {
818  MockFunction<int(int)> foo;
819  auto call = [](const std::function<int(int)> &f, int i) {
820  return f(i);
821  };
822  EXPECT_CALL(foo, Call(1)).WillOnce(Return(-1));
823  EXPECT_CALL(foo, Call(2)).WillOnce(Return(-2));
824  EXPECT_EQ(-1, call(foo.AsStdFunction(), 1));
825  EXPECT_EQ(-2, call(foo.AsStdFunction(), 2));
826 }
827 
828 TEST(MockMethodMockFunctionTest, AsStdFunctionReturnsReference) {
829  MockFunction<int&()> foo;
830  int value = 1;
831  EXPECT_CALL(foo, Call()).WillOnce(ReturnRef(value));
832  int& ref = foo.AsStdFunction()();
833  EXPECT_EQ(1, ref);
834  value = 2;
835  EXPECT_EQ(2, ref);
836 }
837 
838 TEST(MockMethodMockFunctionTest, AsStdFunctionWithReferenceParameter) {
839  MockFunction<int(int &)> foo;
840  auto call = [](const std::function<int(int& )> &f, int &i) {
841  return f(i);
842  };
843  int i = 42;
844  EXPECT_CALL(foo, Call(i)).WillOnce(Return(-1));
845  EXPECT_EQ(-1, call(foo.AsStdFunction(), i));
846 }
847 
848 namespace {
849 
850 template <typename Expected, typename F>
851 static constexpr bool IsMockFunctionTemplateArgumentDeducedTo(
852  const internal::MockFunction<F>&) {
854 }
855 
856 } // namespace
857 
858 template <typename F>
860 
862  Types<void(), int(), void(int), int(int), int(bool, int),
863  int(bool, char, int, int, int, int, int, char, int, bool)>;
866 
868  IsMockFunctionTemplateArgumentDeducedForRawSignature) {
869  using Argument = TypeParam;
871  EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<TypeParam>(foo));
872 }
873 
875  IsMockFunctionTemplateArgumentDeducedForStdFunction) {
876  using Argument = std::function<TypeParam>;
878  EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<TypeParam>(foo));
879 }
880 
883  IsMockFunctionCallMethodSignatureTheSameForRawSignatureAndStdFunction) {
884  using ForRawSignature = decltype(&MockFunction<TypeParam>::Call);
885  using ForStdFunction =
886  decltype(&MockFunction<std::function<TypeParam>>::Call);
888 }
889 
890 template <typename F>
892 };
893 
895  IsMockFunctionTemplateArgumentDeducedForAlternateCallable) {
896  using Argument = AlternateCallable<TypeParam>;
898  EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<TypeParam>(foo));
899 }
900 
903  IsMockFunctionCallMethodSignatureTheSameForAlternateCallable) {
904  using ForRawSignature = decltype(&MockFunction<TypeParam>::Call);
905  using ForStdFunction =
906  decltype(&MockFunction<std::function<TypeParam>>::Call);
908 }
909 
910 
911 struct MockMethodSizes0 {
912  MOCK_METHOD(void, func, ());
913 };
914 struct MockMethodSizes1 {
915  MOCK_METHOD(void, func, (int));
916 };
917 struct MockMethodSizes2 {
918  MOCK_METHOD(void, func, (int, int));
919 };
920 struct MockMethodSizes3 {
921  MOCK_METHOD(void, func, (int, int, int));
922 };
923 struct MockMethodSizes4 {
924  MOCK_METHOD(void, func, (int, int, int, int));
925 };
926 
928  MOCK_METHOD0(func, void());
929 };
931  MOCK_METHOD1(func, void(int));
932 };
934  MOCK_METHOD2(func, void(int, int));
935 };
937  MOCK_METHOD3(func, void(int, int, int));
938 };
940  MOCK_METHOD4(func, void(int, int, int, int));
941 };
942 
943 
944 TEST(MockMethodMockFunctionTest, MockMethodSizeOverhead) {
945  EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes1));
946  EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes2));
947  EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes3));
948  EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes4));
949 
954 
956 }
957 
958 void hasTwoParams(int, int);
959 void MaybeThrows();
960 void DoesntThrow() noexcept;
962  MOCK_METHOD(void, func1, (), (noexcept));
963  MOCK_METHOD(void, func2, (), (noexcept(true)));
964  MOCK_METHOD(void, func3, (), (noexcept(false)));
965  MOCK_METHOD(void, func4, (), (noexcept(noexcept(MaybeThrows()))));
966  MOCK_METHOD(void, func5, (), (noexcept(noexcept(DoesntThrow()))));
967  MOCK_METHOD(void, func6, (), (noexcept(noexcept(DoesntThrow())), const));
968  MOCK_METHOD(void, func7, (), (const, noexcept(noexcept(DoesntThrow()))));
969  // Put commas in the noexcept expression
970  MOCK_METHOD(void, func8, (), (noexcept(noexcept(hasTwoParams(1, 2))), const));
971 };
972 
973 TEST(MockMethodMockFunctionTest, NoexceptSpecifierPreserved) {
974  EXPECT_TRUE(noexcept(std::declval<MockMethodNoexceptSpecifier>().func1()));
975  EXPECT_TRUE(noexcept(std::declval<MockMethodNoexceptSpecifier>().func2()));
976  EXPECT_FALSE(noexcept(std::declval<MockMethodNoexceptSpecifier>().func3()));
977  EXPECT_FALSE(noexcept(std::declval<MockMethodNoexceptSpecifier>().func4()));
978  EXPECT_TRUE(noexcept(std::declval<MockMethodNoexceptSpecifier>().func5()));
979  EXPECT_TRUE(noexcept(std::declval<MockMethodNoexceptSpecifier>().func6()));
980  EXPECT_TRUE(noexcept(std::declval<MockMethodNoexceptSpecifier>().func7()));
981  EXPECT_EQ(noexcept(std::declval<MockMethodNoexceptSpecifier>().func8()),
982  noexcept(hasTwoParams(1, 2)));
983 }
984 
985 } // namespace gmock_function_mocker_test
986 } // namespace testing
testing::gmock_function_mocker_test::MockOverloadedOnConstness::GTEST_DISALLOW_COPY_AND_ASSIGN_
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockOverloadedOnConstness)
xds_interop_client.str
str
Definition: xds_interop_client.py:487
EXPECT_FALSE
#define EXPECT_FALSE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1970
testing::gmock_function_mocker_test::TemplatedCopyable::TemplatedCopyable
TemplatedCopyable()
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:71
testing::gmock_function_mocker_test::FooInterface::TakesNonConstReference
virtual bool TakesNonConstReference(int &n)=0
testing::gmock_function_mocker_test::FooInterface::Decimal
virtual int Decimal(bool b, char c, short d, int e, long f, float g, double h, unsigned i, char *j, const std::string &k)=0
MOCK_CONST_METHOD1_WITH_CALLTYPE
#define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m,...)
Definition: bloaty/third_party/googletest/googlemock/include/gmock/gmock-generated-function-mockers.h:683
testing::gmock_function_mocker_test::FooInterface::RefQualifiedRefRef
virtual int RefQualifiedRefRef() &&=0
testing
Definition: aws_request_signer_test.cc:25
testing::gmock_function_mocker_test::LegacyMockOverloadedOnArgNumber::GTEST_DISALLOW_COPY_AND_ASSIGN_
GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockOverloadedOnArgNumber)
testing::gmock_function_mocker_test::MockMethodNoexceptSpecifier
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:961
testing::gmock_function_mocker_test::MockOverloadedOnArgNumber
Definition: bloaty/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc:516
testing::gmock_function_mocker_test::LegacyMockFoo::RefQualifiedConstRefRef
int RefQualifiedConstRefRef() const &&override
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:269
testing::gmock_function_mocker_test::LegacyMockMethodSizes0
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:927
testing::gmock_function_mocker_test::LegacyMockStack::GTEST_DISALLOW_COPY_AND_ASSIGN_
GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockStack)
testing::gmock_function_mocker_test::MockMethodSizes2
Definition: bloaty/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc:642
get
absl::string_view get(const Cont &c)
Definition: abseil-cpp/absl/strings/str_replace_test.cc:185
testing::Lt
internal::LtMatcher< Rhs > Lt(Rhs x)
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:8603
const
#define const
Definition: bloaty/third_party/zlib/zconf.h:230
testing::gmock_function_mocker_test::FooInterface::Unary
virtual bool Unary(int x)=0
bool
bool
Definition: setup_once.h:312
testing::gmock_function_mocker_test::LegacyMockMethodSizes3::MOCK_METHOD3
MOCK_METHOD3(func, void(int, int, int))
testing::gmock_function_mocker_test::TYPED_TEST
TYPED_TEST(FunctionMockerTest, MocksVoidFunction)
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:297
testing::gmock_function_mocker_test::MockFoo
Definition: bloaty/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc:122
testing::gmock_function_mocker_test::MockFoo::MOCK_METHOD
MOCK_METHOD(void, VoidReturning,(int n))
testing::gmock_generated_actions_test::Nullary
int Nullary()
Definition: bloaty/third_party/googletest/googlemock/test/gmock-generated-actions_test.cc:66
testing::gmock_function_mocker_test::LegacyMockMethodSizes2::MOCK_METHOD2
MOCK_METHOD2(func, void(int, int))
testing::Return
internal::ReturnAction< R > Return(R value)
Definition: bloaty/third_party/googletest/googlemock/include/gmock/gmock-actions.h:1004
testing::gmock_function_mocker_test::MockOverloadedOnConstness::MY_MOCK_METHODS2_
MY_MOCK_METHODS2_
Definition: bloaty/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc:545
testing::gmock_function_mocker_test::FooInterface::~FooInterface
virtual ~FooInterface()
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:79
testing::gmock_function_mocker_test::LegacyMockFoo::MOCK_CONST_METHOD1
MOCK_CONST_METHOD1(ReturnTypeWithComma, std::map< int, std::string >(int))
y
const double y
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3611
testing::gmock_function_mocker_test::StackInterface::Pop
virtual void Pop()=0
testing::gmock_function_mocker_test::FooInterface::ReturnsFunctionPointer1
virtual int(*)(bool) ReturnsFunctionPointer1(int)
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:107
testing::gmock_function_mocker_test::LegacyMockStack
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:565
testing::gmock_function_mocker_test::LegacyMockB::GTEST_DISALLOW_COPY_AND_ASSIGN_
GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockB)
MOCK_CONST_METHOD0_T_WITH_CALLTYPE
#define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m,...)
Definition: bloaty/third_party/googletest/googlemock/include/gmock/gmock-generated-function-mockers.h:727
testing::gmock_function_mocker_test::LegacyMockStack::MOCK_METHOD1_T
MOCK_METHOD1_T(Push, void(const T &elem))
testing::gmock_function_mocker_test::LegacyMockB
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:499
elem
Timer elem
Definition: event_engine/iomgr_event_engine/timer_heap_test.cc:109
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
testing::gmock_function_mocker_test::FooInterface::RefQualifiedConstRefRef
virtual int RefQualifiedConstRefRef() const &&=0
testing::gmock_function_mocker_test::LegacyMockFoo::MOCK_CONST_METHOD0
MOCK_CONST_METHOD0(OverloadedOnConstness, char())
testing::gmock_function_mocker_test::LegacyMockMethodSizes1::MOCK_METHOD1
MOCK_METHOD1(func, void(int))
testing::gmock_more_actions_test::Unary
bool Unary(int x)
Definition: bloaty/third_party/googletest/googlemock/test/gmock-more-actions_test.cc:85
foo
Definition: bloaty/third_party/googletest/googletest/test/googletest-output-test_.cc:546
testing::gmock_function_mocker_test::LegacyMockFoo::MOCK_METHOD2
MOCK_METHOD2(Binary, long(short, int))
testing::gmock_function_mocker_test::MockOverloadedOnArgNumber::MY_MOCK_METHODS1_
MY_MOCK_METHODS1_
Definition: bloaty/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc:520
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
testing::Ge
internal::GeMatcher< Rhs > Ge(Rhs x)
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:8585
testing::gmock_function_mocker_test::LegacyMockFoo::RefQualifiedOverloaded
int RefQualifiedOverloaded() const &&override
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:273
testing::gmock_function_mocker_test::DoesntThrow
void DoesntThrow() noexcept
MOCK_METHOD1_T_WITH_CALLTYPE
#define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m,...)
Definition: bloaty/third_party/googletest/googlemock/include/gmock/gmock-generated-function-mockers.h:706
testing::gmock_function_mocker_test::FooInterface::TypeWithComma
virtual int TypeWithComma(const std::map< int, std::string > &a_map)=0
setup.k
k
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:42
testing::Const
const T & Const(const T &x)
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:11004
testing::gmock_function_mocker_test::TemplatedCopyable::TemplatedCopyable
TemplatedCopyable(const U &other)
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:74
testing::ReturnRef
internal::ReturnRefAction< R > ReturnRef(R &x)
Definition: bloaty/third_party/googletest/googlemock/include/gmock/gmock-actions.h:1020
T
#define T(upbtypeconst, upbtype, ctype, default_value)
testing::gmock_function_mocker_test::StackInterface::GetSize
virtual int GetSize() const =0
gen_build_yaml.struct
def struct(**kwargs)
Definition: test/core/end2end/gen_build_yaml.py:30
testing::gmock_function_mocker_test::LegacyMockStack::MOCK_METHOD0_T
MOCK_METHOD0_T(Pop, void())
testing::Test
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:402
testing::gmock_function_mocker_test::MockStack::MockStack
MockStack()
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:549
testing::An
Matcher< T > An()
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:8555
call
FilterStackCall * call
Definition: call.cc:750
testing::gmock_function_mocker_test::LegacyMockFoo::RefQualifiedRefRef
int RefQualifiedRefRef() &&override
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:271
testing::gmock_function_mocker_test::FooInterface::OverloadedOnArgumentNumber
virtual int OverloadedOnArgumentNumber()=0
EXPECT_EQ
#define EXPECT_EQ(a, b)
Definition: iomgr/time_averaged_stats_test.cc:27
testing::internal::ProxyTypeList
Definition: googletest/googletest/include/gtest/internal/gtest-type-util.h:155
testing::gmock_function_mocker_test::TYPED_TEST_SUITE
TYPED_TEST_SUITE(FunctionMockerTest, FunctionMockerTestTypes)
testing::gmock_function_mocker_test::LegacyMockMethodSizes4::MOCK_METHOD4
MOCK_METHOD4(func, void(int, int, int, int))
testing::gmock_function_mocker_test::MockOverloadedOnArgNumber::MockOverloadedOnArgNumber
MockOverloadedOnArgNumber()
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:714
testing::gmock_function_mocker_test::LegacyMockFoo::MOCK_METHOD1
MOCK_METHOD1(VoidReturning, void(int n))
testing::gmock_function_mocker_test::FooInterface::Nullary
virtual int Nullary()=0
autogen_x86imm.f
f
Definition: autogen_x86imm.py:9
a2
T::first_type a2
Definition: abseil-cpp/absl/container/internal/hash_function_defaults_test.cc:307
xds_interop_client.int
int
Definition: xds_interop_client.py:113
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
testing::gmock_function_mocker_test::FooInterface::VoidReturning
virtual void VoidReturning(int x)=0
testing::gmock_function_mocker_test::FooInterface::fn_ptr
int(*)(bool) fn_ptr
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:108
testing::gmock_function_mocker_test::MockStack
Definition: bloaty/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc:402
testing::gmock_function_mocker_test::MockMethodSizes3
Definition: bloaty/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc:645
testing::gmock_function_mocker_test::MockMethodSizes3::MOCK_METHOD
MOCK_METHOD(void, func,(int, int, int))
testing::gmock_function_mocker_test::LegacyMockFoo::RefQualifiedConstRef
int RefQualifiedConstRef() const &override
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:268
google::protobuf::python::repeated_composite_container::Pop
static PyObject * Pop(PyObject *pself, PyObject *args)
Definition: bloaty/third_party/protobuf/python/google/protobuf/pyext/repeated_composite_container.cc:445
testing::gmock_function_mocker_test::LegacyMockOverloadedOnArgNumber::LegacyMockOverloadedOnArgNumber
LegacyMockOverloadedOnArgNumber()
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:724
testing::gmock_function_mocker_test::OverloadedMockMethodTest
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:733
testing::Eq
internal::EqMatcher< T > Eq(T x)
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:8561
testing::gmock_function_mocker_test::LegacyMockOverloadedOnArgNumber::LEGACY_MY_MOCK_METHODS1_
LEGACY_MY_MOCK_METHODS1_
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:726
testing::gmock_function_mocker_test::MockMethodSizes0
Definition: bloaty/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc:636
testing::gmock_function_mocker_test::FooInterface::Binary
virtual long Binary(short x, int y)=0
ref
unsigned ref
Definition: cxa_demangle.cpp:4909
testing::gmock_function_mocker_test::FooInterface::TakesConst
virtual bool TakesConst(const int x)=0
testing::gmock_function_mocker_test::MockOverloadedOnConstness
Definition: bloaty/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc:541
Call
Definition: api_fuzzer.cc:319
testing::gmock_function_mocker_test::FunctionMockerTest::FunctionMockerTest
FunctionMockerTest()
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:288
testing::gmock_function_mocker_test::LegacyMockStack::LegacyMockStack
LegacyMockStack()
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:567
testing::gmock_function_mocker_test::LegacyMockStack::MOCK_CONST_METHOD0_T
MOCK_CONST_METHOD0_T(GetSize, int())
testing::gmock_function_mocker_test::LegacyMockFoo::RefQualifiedOverloaded
int RefQualifiedOverloaded() &override
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:274
testing::gmock_function_mocker_test::MockB
Definition: bloaty/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc:357
x
int x
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3610
testing::gmock_function_mocker_test::LegacyMockFoo::RefQualifiedRef
int RefQualifiedRef() &override
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:270
a1
T::first_type a1
Definition: abseil-cpp/absl/container/internal/hash_function_defaults_test.cc:305
MOCK_METHOD1_WITH_CALLTYPE
#define MOCK_METHOD1_WITH_CALLTYPE(ct, m,...)
Definition: bloaty/third_party/googletest/googlemock/include/gmock/gmock-generated-function-mockers.h:660
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
g
struct @717 g
testing::gmock_function_mocker_test::FooInterface::TypeWithHole
virtual int TypeWithHole(int(*func)())=0
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
testing::gmock_function_mocker_test::StackInterface::GetTop
virtual const T & GetTop() const =0
testing::gmock_function_mocker_test::MockStack::GTEST_DISALLOW_COPY_AND_ASSIGN_
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockStack)
testing::gmock_function_mocker_test::MockStack::MOCK_METHOD
MOCK_METHOD(void, Push,(const T &elem),())
EXPECT_CALL
#define EXPECT_CALL(obj, call)
testing::gmock_function_mocker_test::FooInterface::RefQualifiedConstRef
virtual int RefQualifiedConstRef() const &=0
GTEST_DISALLOW_COPY_AND_ASSIGN_
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:683
testing::gmock_function_mocker_test::LegacyMockMethodSizes2
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:933
testing::gmock_function_mocker_test::LegacyMockB::LegacyMockB
LegacyMockB()
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:501
testing::gmock_function_mocker_test::StackInterface::Push
virtual void Push(const T &value)=0
value
const char * value
Definition: hpack_parser_table.cc:165
testing::gmock_function_mocker_test::MockMethodSizes4
Definition: bloaty/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc:648
testing::gmock_function_mocker_test::LegacyMockMethodSizes4
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:939
mock_foo
MockFoo * mock_foo
Definition: bloaty/third_party/googletest/googlemock/test/gmock_stress_test.cc:95
testing::gmock_function_mocker_test::MockMethodSizes2::MOCK_METHOD
MOCK_METHOD(void, func,(int, int))
testing::gmock_function_mocker_test::FooInterface::ReturnsFunctionPointer2
virtual fn_ptr ReturnsFunctionPointer2(int)=0
foo
int foo
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/statusor_test.cc:66
testing::_
const internal::AnythingMatcher _
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:8548
func
const EVP_CIPHER *(* func)(void)
Definition: cipher_extra.c:73
testing::gmock_function_mocker_test::FooInterface::OverloadedOnArgumentType
virtual int OverloadedOnArgumentType(int n)=0
testing::gmock_function_mocker_test::MockMethodSizes0::MOCK_METHOD
MOCK_METHOD(void, func,())
testing::gmock_function_mocker_test::FooInterface::TypeWithTemplatedCopyCtor
virtual int TypeWithTemplatedCopyCtor(const TemplatedCopyable< int > &)=0
tests.unit._server_ssl_cert_config_test.Call
Call
Definition: _server_ssl_cert_config_test.py:70
MOCK_METHOD10_WITH_CALLTYPE
#define MOCK_METHOD10_WITH_CALLTYPE(ct, m,...)
Definition: bloaty/third_party/googletest/googlemock/include/gmock/gmock-generated-function-mockers.h:678
testing::gmock_function_mocker_test::LegacyMockB::MOCK_METHOD0
MOCK_METHOD0(DoB, void())
testing::gmock_function_mocker_test::MockB::MOCK_METHOD
MOCK_METHOD(void, DoB,())
testing::gmock_function_mocker_test::LegacyMockFoo::RefQualifiedOverloaded
int RefQualifiedOverloaded() &&override
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:275
testing::TypedEq
Matcher< Lhs > TypedEq(const Rhs &rhs)
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:8581
testing::gmock_function_mocker_test::MockFoo::GTEST_DISALLOW_COPY_AND_ASSIGN_
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo)
testing::gmock_function_mocker_test::FunctionMockerTest::mock_foo_
T mock_foo_
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:291
MOCK_METHOD0_WITH_CALLTYPE
#define MOCK_METHOD0_WITH_CALLTYPE(ct, m,...)
Definition: bloaty/third_party/googletest/googlemock/include/gmock/gmock-generated-function-mockers.h:658
testing::gmock_function_mocker_test::LegacyMockMethodSizes0::MOCK_METHOD0
MOCK_METHOD0(func, void())
testing::gmock_function_mocker_test::LegacyMockFoo::MOCK_METHOD0
MOCK_METHOD0(Nullary, int())
testing::gmock_function_mocker_test::LegacyMockFoo::MOCK_METHOD10
MOCK_METHOD10(Decimal, int(bool, char, short, int, long, float, double, unsigned, char *, const std::string &str))
L
lua_State * L
Definition: upb/upb/bindings/lua/main.c:35
testing::gmock_function_mocker_test::TEST
TEST(MockMethodExpectCallTest, UnmentionedFunctionCanBeCalledAnyNumberOfTimes)
Definition: bloaty/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc:369
testing::MockFunction
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:11854
testing::gmock_function_mocker_test::LegacyMockOverloadedOnArgNumber
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:722
testing::gmock_function_mocker_test::FooInterface
Definition: bloaty/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc:74
A
Definition: miscompile_with_no_unique_address_test.cc:23
testing::gmock_function_mocker_test::FunctionMockerTest::foo_
FooInterface *const foo_
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:290
testing::gmock_function_mocker_test::FooInterface::TakesConstReference
virtual std::string TakesConstReference(const int &n)=0
testing::gmock_function_mocker_test::MockFoo::MockFoo
MockFoo()
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:141
testing::gmock_function_mocker_test::MockMethodMockFunctionSignatureTest
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:859
testing::gmock_function_mocker_test::MockB::GTEST_DISALLOW_COPY_AND_ASSIGN_
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockB)
MOCK_METHOD
#define MOCK_METHOD(...)
Definition: bloaty/third_party/googletest/googlemock/include/gmock/gmock-function-mocker.h:42
testing::gmock_function_mocker_test::StackInterface::~StackInterface
virtual ~StackInterface()
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:536
EXPECT_TRUE
#define EXPECT_TRUE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1967
testing::gmock_function_mocker_test::FooInterface::OverloadedOnConstness
virtual int OverloadedOnConstness()=0
testing::gmock_function_mocker_test::FooInterface::RefQualifiedOverloaded
virtual int RefQualifiedOverloaded() const &=0
testing::gmock_function_mocker_test::LegacyMockMethodSizes1
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:930
testing::gmock_function_mocker_test::MockOverloadedOnArgNumber::GTEST_DISALLOW_COPY_AND_ASSIGN_
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockOverloadedOnArgNumber)
testing::gmock_function_mocker_test::MockB::MockB
MockB()
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:491
testing::gmock_function_mocker_test::MockMethodSizes1
Definition: bloaty/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc:639
MOCK_METHOD0_T_WITH_CALLTYPE
#define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m,...)
Definition: bloaty/third_party/googletest/googlemock/include/gmock/gmock-generated-function-mockers.h:704
testing::gmock_function_mocker_test::LegacyMockMethodSizes3
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:936
testing::gmock_generated_actions_test::Binary
const char * Binary(const char *input, short n)
Definition: bloaty/third_party/googletest/googlemock/test/gmock-generated-actions_test.cc:79
testing::gmock_function_mocker_test::ExpectCallTest
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:510
testing::DoDefault
internal::DoDefaultAction DoDefault()
Definition: bloaty/third_party/googletest/googlemock/include/gmock/gmock-actions.h:1042
testing::AnyNumber
GTEST_API_ Cardinality AnyNumber()
Definition: bloaty/third_party/googletest/googlemock/src/gmock-cardinalities.cc:145
testing::gmock_function_mocker_test::LegacyMockFoo
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:209
testing::gmock_function_mocker_test::AlternateCallable
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:891
testing::gmock_function_mocker_test::StackInterface
Definition: bloaty/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc:389
testing::gmock_function_mocker_test::FooInterface::RefQualifiedRef
virtual int RefQualifiedRef() &=0
function
std::function< bool(GrpcTool *, int, const char **, const CliCredentials &, GrpcToolOutputCallback)> function
Definition: grpc_tool.cc:250
testing::gmock_function_mocker_test::LegacyMockFoo::GTEST_DISALLOW_COPY_AND_ASSIGN_
GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockFoo)
testing::gmock_function_mocker_test::MockMethodSizes1::MOCK_METHOD
MOCK_METHOD(void, func,(int))
testing::Ref
internal::RefMatcher< T & > Ref(T &x)
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:8628
testing::A
Matcher< T > A()
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:8551
testing::gmock_function_mocker_test::MaybeThrows
void MaybeThrows()
testing::gmock_function_mocker_test::MockOverloadedOnConstness::MockOverloadedOnConstness
MockOverloadedOnConstness()
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:756
testing::gmock_function_mocker_test::FunctionMockerTest
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:286
testing::gmock_function_mocker_test::TemplateMockTest
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:583
testing::gmock_function_mocker_test::hasTwoParams
void hasTwoParams(int, int)
testing::gmock_function_mocker_test::TemplatedCopyable
Definition: bloaty/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc:66
testing::gmock_function_mocker_test::LegacyMockFoo::LegacyMockFoo
LegacyMockFoo()
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:211
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
testing::gmock_function_mocker_test::MockMethodSizes4::MOCK_METHOD
MOCK_METHOD(void, func,(int, int, int, int))
testing::gmock_function_mocker_test::LegacyMockStack::MOCK_CONST_METHOD1_T
MOCK_CONST_METHOD1_T(ReturnTypeWithComma, std::map< int, int >(int))
testing::gmock_function_mocker_test::LegacyMockFoo::RefQualifiedOverloaded
int RefQualifiedOverloaded() const &override
Definition: googletest/googlemock/test/gmock-function-mocker_test.cc:272


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:30