proxygen
testing::gmock_generated_function_mockers_test Namespace Reference

Classes

class  FooInterface
 
class  FunctionMockerTest
 
class  MockB
 
class  MockFoo
 
class  MockOverloadedOnArgNumber
 
class  MockOverloadedOnConstness
 
class  MockStack
 
class  StackInterface
 

Functions

 TEST_F (FunctionMockerTest, MocksVoidFunction)
 
 TEST_F (FunctionMockerTest, MocksNullaryFunction)
 
 TEST_F (FunctionMockerTest, MocksUnaryFunction)
 
 TEST_F (FunctionMockerTest, MocksBinaryFunction)
 
 TEST_F (FunctionMockerTest, MocksDecimalFunction)
 
 TEST_F (FunctionMockerTest, MocksFunctionWithNonConstReferenceArgument)
 
 TEST_F (FunctionMockerTest, MocksFunctionWithConstReferenceArgument)
 
 TEST_F (FunctionMockerTest, MocksFunctionWithConstArgument)
 
 TEST_F (FunctionMockerTest, MocksFunctionsOverloadedOnArgumentNumber)
 
 TEST_F (FunctionMockerTest, MocksFunctionsOverloadedOnArgumentType)
 
 TEST_F (FunctionMockerTest, MocksFunctionsOverloadedOnConstnessOfThis)
 
 TEST_F (FunctionMockerTest, MocksReturnTypeWithComma)
 
 TEST (ExpectCallTest, UnmentionedFunctionCanBeCalledAnyNumberOfTimes)
 
 TEST (TemplateMockTest, Works)
 
 TEST (TemplateMockTest, MethodWithCommaInReturnTypeWorks)
 
 TEST (OverloadedMockMethodTest, CanOverloadOnArgNumberInMacroBody)
 
 TEST (OverloadedMockMethodTest, CanOverloadOnConstnessInMacroBody)
 
 TEST (MockFunctionTest, WorksForVoidNullary)
 
 TEST (MockFunctionTest, WorksForNonVoidNullary)
 
 TEST (MockFunctionTest, WorksForVoidUnary)
 
 TEST (MockFunctionTest, WorksForNonVoidBinary)
 
 TEST (MockFunctionTest, WorksFor10Arguments)
 

Function Documentation

testing::gmock_generated_function_mockers_test::TEST ( ExpectCallTest  ,
UnmentionedFunctionCanBeCalledAnyNumberOfTimes   
)
testing::gmock_generated_function_mockers_test::TEST ( TemplateMockTest  ,
Works   
)

Definition at line 416 of file gmock-generated-function-mockers_test.cc.

References testing::_, testing::AnyNumber(), EXPECT_CALL, EXPECT_EQ, testing::gmock_generated_function_mockers_test::StackInterface< T >::GetSize(), testing::gmock_generated_function_mockers_test::StackInterface< T >::GetTop(), testing::gmock_generated_function_mockers_test::StackInterface< T >::Pop(), Push, testing::gmock_generated_function_mockers_test::StackInterface< T >::Push(), testing::Return(), and testing::ReturnRef().

416  {
417  MockStack<int> mock;
418 
419  EXPECT_CALL(mock, GetSize())
420  .WillOnce(Return(0))
421  .WillOnce(Return(1))
422  .WillOnce(Return(0));
423  EXPECT_CALL(mock, Push(_));
424  int n = 5;
425  EXPECT_CALL(mock, GetTop())
426  .WillOnce(ReturnRef(n));
427  EXPECT_CALL(mock, Pop())
428  .Times(AnyNumber());
429 
430  EXPECT_EQ(0, mock.GetSize());
431  mock.Push(5);
432  EXPECT_EQ(1, mock.GetSize());
433  EXPECT_EQ(5, mock.GetTop());
434  mock.Pop();
435  EXPECT_EQ(0, mock.GetSize());
436 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::ReturnRefAction< R > ReturnRef(R &x)
GTEST_API_ Cardinality AnyNumber()
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
TotalRequest HTTPRequestExchange HTTPResponseBodyRead PreConnect PostConnect DNSResolution DNSCache RetryingDNSResolution TCPConnect TLSSetup TotalConnect decompression_filter cert_verification proxy_connect Push
internal::ReturnAction< R > Return(R value)
testing::gmock_generated_function_mockers_test::TEST ( TemplateMockTest  ,
MethodWithCommaInReturnTypeWorks   
)

Definition at line 438 of file gmock-generated-function-mockers_test.cc.

References testing::_, testing::AnyNumber(), EXPECT_CALL, EXPECT_EQ, GTEST_DISALLOW_COPY_AND_ASSIGN_, MOCK_CONST_METHOD0_T_WITH_CALLTYPE, MOCK_METHOD0_T_WITH_CALLTYPE, MOCK_METHOD1_T_WITH_CALLTYPE, Push, testing::Return(), testing::ReturnRef(), T, TEST(), and value.

438  {
439  MockStack<int> mock;
440 
441  const std::map<int, int> a_map;
442  EXPECT_CALL(mock, ReturnTypeWithComma())
443  .WillOnce(Return(a_map));
444  EXPECT_CALL(mock, ReturnTypeWithComma(1))
445  .WillOnce(Return(a_map));
446 
447  EXPECT_EQ(a_map, mock.ReturnTypeWithComma());
448  EXPECT_EQ(a_map, mock.ReturnTypeWithComma(1));
449 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
testing::gmock_generated_function_mockers_test::TEST ( OverloadedMockMethodTest  ,
CanOverloadOnArgNumberInMacroBody   
)

Definition at line 520 of file gmock-generated-function-mockers_test.cc.

References EXPECT_CALL, EXPECT_EQ, EXPECT_TRUE, and testing::Return().

520  {
521  MockOverloadedOnArgNumber mock;
522  EXPECT_CALL(mock, Overloaded());
523  EXPECT_CALL(mock, Overloaded(1)).WillOnce(Return(2));
524  EXPECT_CALL(mock, Overloaded(true, 1)).WillOnce(Return(true));
525 
526  mock.Overloaded();
527  EXPECT_EQ(2, mock.Overloaded(1));
528  EXPECT_TRUE(mock.Overloaded(true, 1));
529 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
testing::gmock_generated_function_mockers_test::TEST ( OverloadedMockMethodTest  ,
CanOverloadOnConstnessInMacroBody   
)

Definition at line 545 of file gmock-generated-function-mockers_test.cc.

References EXPECT_CALL, EXPECT_EQ, and testing::Return().

545  {
546  MockOverloadedOnConstness mock;
547  const MockOverloadedOnConstness* const_mock = &mock;
548  EXPECT_CALL(mock, Overloaded(1)).WillOnce(Return(2));
549  EXPECT_CALL(*const_mock, Overloaded(1)).WillOnce(Return(3));
550 
551  EXPECT_EQ(2, mock.Overloaded(1));
552  EXPECT_EQ(3, const_mock->Overloaded(1));
553 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
testing::gmock_generated_function_mockers_test::TEST ( MockFunctionTest  ,
WorksForVoidNullary   
)

Definition at line 555 of file gmock-generated-function-mockers_test.cc.

References EXPECT_CALL, and testing::gmock_matchers_test::foo.

555  {
556  MockFunction<void()> foo;
557  EXPECT_CALL(foo, Call());
558  foo.Call();
559 }
#define EXPECT_CALL(obj, call)
testing::gmock_generated_function_mockers_test::TEST ( MockFunctionTest  ,
WorksForNonVoidNullary   
)

Definition at line 561 of file gmock-generated-function-mockers_test.cc.

References EXPECT_CALL, EXPECT_EQ, testing::gmock_matchers_test::foo, and testing::Return().

561  {
562  MockFunction<int()> foo;
563  EXPECT_CALL(foo, Call())
564  .WillOnce(Return(1))
565  .WillOnce(Return(2));
566  EXPECT_EQ(1, foo.Call());
567  EXPECT_EQ(2, foo.Call());
568 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
testing::gmock_generated_function_mockers_test::TEST ( MockFunctionTest  ,
WorksForVoidUnary   
)

Definition at line 570 of file gmock-generated-function-mockers_test.cc.

References EXPECT_CALL, and testing::gmock_matchers_test::foo.

570  {
571  MockFunction<void(int)> foo;
572  EXPECT_CALL(foo, Call(1));
573  foo.Call(1);
574 }
#define EXPECT_CALL(obj, call)
testing::gmock_generated_function_mockers_test::TEST ( MockFunctionTest  ,
WorksForNonVoidBinary   
)

Definition at line 576 of file gmock-generated-function-mockers_test.cc.

References EXPECT_CALL, EXPECT_EQ, testing::gmock_matchers_test::foo, testing::Ge(), and testing::Return().

576  {
577  MockFunction<int(bool, int)> foo;
578  EXPECT_CALL(foo, Call(false, 42))
579  .WillOnce(Return(1))
580  .WillOnce(Return(2));
581  EXPECT_CALL(foo, Call(true, Ge(100)))
582  .WillOnce(Return(3));
583  EXPECT_EQ(1, foo.Call(false, 42));
584  EXPECT_EQ(2, foo.Call(false, 42));
585  EXPECT_EQ(3, foo.Call(true, 120));
586 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_CALL(obj, call)
internal::GeMatcher< Rhs > Ge(Rhs x)
internal::ReturnAction< R > Return(R value)
testing::gmock_generated_function_mockers_test::TEST ( MockFunctionTest  ,
WorksFor10Arguments   
)

Definition at line 588 of file gmock-generated-function-mockers_test.cc.

References testing::_, call(), EXPECT_CALL, EXPECT_EQ, f, testing::gmock_matchers_test::foo, i, testing::Return(), testing::ReturnRef(), TEST(), and value.

588  {
589  MockFunction<int(bool a0, char a1, int a2, int a3, int a4,
590  int a5, int a6, char a7, int a8, bool a9)> foo;
591  EXPECT_CALL(foo, Call(_, 'a', _, _, _, _, _, _, _, _))
592  .WillOnce(Return(1))
593  .WillOnce(Return(2));
594  EXPECT_EQ(1, foo.Call(false, 'a', 0, 0, 0, 0, 0, 'b', 0, true));
595  EXPECT_EQ(2, foo.Call(true, 'a', 0, 0, 0, 0, 0, 'b', 1, false));
596 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
internal::ReturnAction< R > Return(R value)
testing::gmock_generated_function_mockers_test::TEST_F ( FunctionMockerTest  ,
MocksVoidFunction   
)

Definition at line 191 of file gmock-generated-function-mockers_test.cc.

References EXPECT_CALL, testing::Lt(), and testing::gmock_generated_function_mockers_test::FooInterface::VoidReturning().

Referenced by testing::gmock_generated_function_mockers_test::FunctionMockerTest::FunctionMockerTest(), and TEST_F().

191  {
192  EXPECT_CALL(mock_foo_, VoidReturning(Lt(100)));
193  foo_->VoidReturning(0);
194 }
internal::LtMatcher< Rhs > Lt(Rhs x)
#define EXPECT_CALL(obj, call)
testing::gmock_generated_function_mockers_test::TEST_F ( FunctionMockerTest  ,
MocksNullaryFunction   
)

Definition at line 197 of file gmock-generated-function-mockers_test.cc.

References testing::DoDefault(), EXPECT_CALL, EXPECT_EQ, testing::gmock_generated_function_mockers_test::FooInterface::Nullary(), and testing::Return().

197  {
198  EXPECT_CALL(mock_foo_, Nullary())
199  .WillOnce(DoDefault())
200  .WillOnce(Return(1));
201 
202  EXPECT_EQ(0, foo_->Nullary());
203  EXPECT_EQ(1, foo_->Nullary());
204 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::DoDefaultAction DoDefault()
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
testing::gmock_generated_function_mockers_test::TEST_F ( FunctionMockerTest  ,
MocksUnaryFunction   
)

Definition at line 207 of file gmock-generated-function-mockers_test.cc.

References testing::Eq(), EXPECT_CALL, EXPECT_FALSE, EXPECT_TRUE, testing::Return(), and testing::gmock_generated_function_mockers_test::FooInterface::Unary().

207  {
208  EXPECT_CALL(mock_foo_, Unary(Eq(2)))
209  .Times(2)
210  .WillOnce(Return(true));
211 
212  EXPECT_TRUE(foo_->Unary(2));
213  EXPECT_FALSE(foo_->Unary(2));
214 }
internal::EqMatcher< T > Eq(T x)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_CALL(obj, call)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
internal::ReturnAction< R > Return(R value)
testing::gmock_generated_function_mockers_test::TEST_F ( FunctionMockerTest  ,
MocksBinaryFunction   
)

Definition at line 217 of file gmock-generated-function-mockers_test.cc.

References testing::_, testing::gmock_generated_function_mockers_test::FooInterface::Binary(), EXPECT_CALL, EXPECT_EQ, and testing::Return().

217  {
218  EXPECT_CALL(mock_foo_, Binary(2, _))
219  .WillOnce(Return(3));
220 
221  EXPECT_EQ(3, foo_->Binary(2, 1));
222 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
const char * Binary(const char *input, short n)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
internal::ReturnAction< R > Return(R value)
testing::gmock_generated_function_mockers_test::TEST_F ( FunctionMockerTest  ,
MocksDecimalFunction   
)

Definition at line 225 of file gmock-generated-function-mockers_test.cc.

References testing::gmock_generated_function_mockers_test::FooInterface::Decimal(), EXPECT_CALL, EXPECT_EQ, testing::Lt(), and testing::Return().

225  {
226  EXPECT_CALL(mock_foo_, Decimal(true, 'a', 0, 0, 1L, A<float>(),
227  Lt(100), 5U, NULL, "hi"))
228  .WillOnce(Return(5));
229 
230  EXPECT_EQ(5, foo_->Decimal(true, 'a', 0, 0, 1, 0, 0, 5, NULL, "hi"));
231 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::LtMatcher< Rhs > Lt(Rhs x)
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
testing::gmock_generated_function_mockers_test::TEST_F ( FunctionMockerTest  ,
MocksFunctionWithNonConstReferenceArgument   
)

Definition at line 234 of file gmock-generated-function-mockers_test.cc.

References a, EXPECT_CALL, EXPECT_TRUE, testing::Ref(), testing::Return(), and testing::gmock_generated_function_mockers_test::FooInterface::TakesNonConstReference().

234  {
235  int a = 0;
236  EXPECT_CALL(mock_foo_, TakesNonConstReference(Ref(a)))
237  .WillOnce(Return(true));
238 
239  EXPECT_TRUE(foo_->TakesNonConstReference(a));
240 }
internal::RefMatcher< T & > Ref(T &x)
char a
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
testing::gmock_generated_function_mockers_test::TEST_F ( FunctionMockerTest  ,
MocksFunctionWithConstReferenceArgument   
)

Definition at line 243 of file gmock-generated-function-mockers_test.cc.

References a, EXPECT_CALL, EXPECT_EQ, testing::Ref(), testing::Return(), and testing::gmock_generated_function_mockers_test::FooInterface::TakesConstReference().

243  {
244  int a = 0;
245  EXPECT_CALL(mock_foo_, TakesConstReference(Ref(a)))
246  .WillOnce(Return("Hello"));
247 
248  EXPECT_EQ("Hello", foo_->TakesConstReference(a));
249 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
internal::RefMatcher< T & > Ref(T &x)
char a
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
testing::gmock_generated_function_mockers_test::TEST_F ( FunctionMockerTest  ,
MocksFunctionWithConstArgument   
)

Definition at line 253 of file gmock-generated-function-mockers_test.cc.

References testing::DoDefault(), EXPECT_CALL, EXPECT_FALSE, testing::Lt(), and testing::gmock_generated_function_mockers_test::FooInterface::TakesConst().

253  {
254  EXPECT_CALL(mock_foo_, TakesConst(Lt(10)))
255  .WillOnce(DoDefault());
256 
257  EXPECT_FALSE(foo_->TakesConst(5));
258 }
internal::LtMatcher< Rhs > Lt(Rhs x)
internal::DoDefaultAction DoDefault()
#define EXPECT_CALL(obj, call)
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
testing::gmock_generated_function_mockers_test::TEST_F ( FunctionMockerTest  ,
MocksFunctionsOverloadedOnArgumentNumber   
)

Definition at line 262 of file gmock-generated-function-mockers_test.cc.

References testing::_, EXPECT_CALL, EXPECT_EQ, testing::gmock_generated_function_mockers_test::FooInterface::OverloadedOnArgumentNumber(), and testing::Return().

262  {
263  EXPECT_CALL(mock_foo_, OverloadedOnArgumentNumber())
264  .WillOnce(Return(1));
265  EXPECT_CALL(mock_foo_, OverloadedOnArgumentNumber(_))
266  .WillOnce(Return(2));
267 
268  EXPECT_EQ(2, foo_->OverloadedOnArgumentNumber(1));
269  EXPECT_EQ(1, foo_->OverloadedOnArgumentNumber());
270 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
internal::ReturnAction< R > Return(R value)
testing::gmock_generated_function_mockers_test::TEST_F ( FunctionMockerTest  ,
MocksFunctionsOverloadedOnArgumentType   
)

Definition at line 273 of file gmock-generated-function-mockers_test.cc.

References EXPECT_CALL, EXPECT_EQ, testing::gmock_generated_function_mockers_test::FooInterface::OverloadedOnArgumentType(), and testing::Return().

273  {
274  EXPECT_CALL(mock_foo_, OverloadedOnArgumentType(An<int>()))
275  .WillOnce(Return(1));
276  EXPECT_CALL(mock_foo_, OverloadedOnArgumentType(TypedEq<char>('a')))
277  .WillOnce(Return('b'));
278 
279  EXPECT_EQ(1, foo_->OverloadedOnArgumentType(0));
280  EXPECT_EQ('b', foo_->OverloadedOnArgumentType('a'));
281 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
testing::gmock_generated_function_mockers_test::TEST_F ( FunctionMockerTest  ,
MocksFunctionsOverloadedOnConstnessOfThis   
)

Definition at line 284 of file gmock-generated-function-mockers_test.cc.

References testing::Const(), EXPECT_CALL, EXPECT_EQ, testing::gmock_generated_function_mockers_test::FooInterface::OverloadedOnConstness(), and testing::Return().

284  {
285  EXPECT_CALL(mock_foo_, OverloadedOnConstness());
286  EXPECT_CALL(Const(mock_foo_), OverloadedOnConstness())
287  .WillOnce(Return('a'));
288 
289  EXPECT_EQ(0, foo_->OverloadedOnConstness());
290  EXPECT_EQ('a', Const(*foo_).OverloadedOnConstness());
291 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)
testing::gmock_generated_function_mockers_test::TEST_F ( FunctionMockerTest  ,
MocksReturnTypeWithComma   
)

Definition at line 293 of file gmock-generated-function-mockers_test.cc.

References testing::_, testing::Const(), testing::Eq(), EXPECT_CALL, EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, testing::Lt(), testing::Return(), and TEST_F().

293  {
294  const std::map<int, string> a_map;
295  EXPECT_CALL(mock_foo_, ReturnTypeWithComma())
296  .WillOnce(Return(a_map));
297  EXPECT_CALL(mock_foo_, ReturnTypeWithComma(42))
298  .WillOnce(Return(a_map));
299 
300  EXPECT_EQ(a_map, mock_foo_.ReturnTypeWithComma());
301  EXPECT_EQ(a_map, mock_foo_.ReturnTypeWithComma(42));
302 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_CALL(obj, call)
internal::ReturnAction< R > Return(R value)