Lines Matching +full:overloaded +full:- +full:virtual
36 // Google Mock - a framework for writing C++ mock classes.
39 #include "gmock/gmock-function-mocker.h"
84 virtual ~FooInterface() {} in ~FooInterface()
86 virtual void VoidReturning(int x) = 0;
88 virtual int Nullary() = 0;
89 virtual bool Unary(int x) = 0;
90 virtual long Binary(short x, int y) = 0; // NOLINT
91 virtual int Decimal(bool b, char c, short d, int e, long f, // NOLINT
95 virtual bool TakesNonConstReference(int& n) = 0; // NOLINT
96 virtual std::string TakesConstReference(const int& n) = 0;
97 virtual bool TakesConst(const int x) = 0;
99 virtual int OverloadedOnArgumentNumber() = 0;
100 virtual int OverloadedOnArgumentNumber(int n) = 0;
102 virtual int OverloadedOnArgumentType(int n) = 0;
103 virtual char OverloadedOnArgumentType(char c) = 0;
105 virtual int OverloadedOnConstness() = 0;
106 virtual char OverloadedOnConstness() const = 0;
108 virtual int TypeWithHole(int (*func)()) = 0;
109 virtual int TypeWithComma(const std::map<int, std::string>& a_map) = 0;
110 virtual int TypeWithTemplatedCopyCtor(const TemplatedCopyable<int>&) = 0;
112 virtual int (*ReturnsFunctionPointer1(int))(bool) = 0;
114 virtual fn_ptr ReturnsFunctionPointer2(int) = 0;
116 virtual int RefQualifiedConstRef() const& = 0;
117 virtual int RefQualifiedConstRefRef() const&& = 0;
118 virtual int RefQualifiedRef() & = 0;
119 virtual int RefQualifiedRefRef() && = 0;
121 virtual int RefQualifiedOverloaded() const& = 0;
122 virtual int RefQualifiedOverloaded() const&& = 0;
123 virtual int RefQualifiedOverloaded() & = 0;
124 virtual int RefQualifiedOverloaded() && = 0;
137 // significant in determining whether two virtual functions had the same
303 // Tests mocking a void-returning function.
305 EXPECT_CALL(this->mock_foo_, VoidReturning(Lt(100))); in TYPED_TEST()
306 this->foo_->VoidReturning(0); in TYPED_TEST()
311 EXPECT_CALL(this->mock_foo_, Nullary()) in TYPED_TEST()
315 EXPECT_EQ(0, this->foo_->Nullary()); in TYPED_TEST()
316 EXPECT_EQ(1, this->foo_->Nullary()); in TYPED_TEST()
321 EXPECT_CALL(this->mock_foo_, Unary(Eq(2))).Times(2).WillOnce(Return(true)); in TYPED_TEST()
323 EXPECT_TRUE(this->foo_->Unary(2)); in TYPED_TEST()
324 EXPECT_FALSE(this->foo_->Unary(2)); in TYPED_TEST()
329 EXPECT_CALL(this->mock_foo_, Binary(2, _)).WillOnce(Return(3)); in TYPED_TEST()
331 EXPECT_EQ(3, this->foo_->Binary(2, 1)); in TYPED_TEST()
336 EXPECT_CALL(this->mock_foo_, in TYPED_TEST()
340 EXPECT_EQ(5, this->foo_->Decimal(true, 'a', 0, 0, 1, 0, 0, 5, nullptr, "hi")); in TYPED_TEST()
343 // Tests mocking a function that takes a non-const reference.
346 EXPECT_CALL(this->mock_foo_, TakesNonConstReference(Ref(a))) in TYPED_TEST()
349 EXPECT_TRUE(this->foo_->TakesNonConstReference(a)); in TYPED_TEST()
355 EXPECT_CALL(this->mock_foo_, TakesConstReference(Ref(a))) in TYPED_TEST()
358 EXPECT_EQ("Hello", this->foo_->TakesConstReference(a)); in TYPED_TEST()
363 EXPECT_CALL(this->mock_foo_, TakesConst(Lt(10))).WillOnce(DoDefault()); in TYPED_TEST()
365 EXPECT_FALSE(this->foo_->TakesConst(5)); in TYPED_TEST()
368 // Tests mocking functions overloaded on the number of arguments.
370 EXPECT_CALL(this->mock_foo_, OverloadedOnArgumentNumber()) in TYPED_TEST()
372 EXPECT_CALL(this->mock_foo_, OverloadedOnArgumentNumber(_)) in TYPED_TEST()
375 EXPECT_EQ(2, this->foo_->OverloadedOnArgumentNumber(1)); in TYPED_TEST()
376 EXPECT_EQ(1, this->foo_->OverloadedOnArgumentNumber()); in TYPED_TEST()
379 // Tests mocking functions overloaded on the types of argument.
381 EXPECT_CALL(this->mock_foo_, OverloadedOnArgumentType(An<int>())) in TYPED_TEST()
383 EXPECT_CALL(this->mock_foo_, OverloadedOnArgumentType(TypedEq<char>('a'))) in TYPED_TEST()
386 EXPECT_EQ(1, this->foo_->OverloadedOnArgumentType(0)); in TYPED_TEST()
387 EXPECT_EQ('b', this->foo_->OverloadedOnArgumentType('a')); in TYPED_TEST()
390 // Tests mocking functions overloaded on the const-ness of this object.
392 EXPECT_CALL(this->mock_foo_, OverloadedOnConstness()); in TYPED_TEST()
393 EXPECT_CALL(Const(this->mock_foo_), OverloadedOnConstness()) in TYPED_TEST()
396 EXPECT_EQ(0, this->foo_->OverloadedOnConstness()); in TYPED_TEST()
397 EXPECT_EQ('a', Const(*this->foo_).OverloadedOnConstness()); in TYPED_TEST()
402 EXPECT_CALL(this->mock_foo_, ReturnTypeWithComma()).WillOnce(Return(a_map)); in TYPED_TEST()
403 EXPECT_CALL(this->mock_foo_, ReturnTypeWithComma(42)).WillOnce(Return(a_map)); in TYPED_TEST()
405 EXPECT_EQ(a_map, this->mock_foo_.ReturnTypeWithComma()); in TYPED_TEST()
406 EXPECT_EQ(a_map, this->mock_foo_.ReturnTypeWithComma(42)); in TYPED_TEST()
410 EXPECT_CALL(this->mock_foo_, TypeWithTemplatedCopyCtor(_)) in TYPED_TEST()
412 EXPECT_TRUE(this->foo_->TypeWithTemplatedCopyCtor(TemplatedCopyable<int>())); in TYPED_TEST()
418 EXPECT_CALL(this->mock_foo_, CTNullary()) in TYPED_TEST()
419 .WillOnce(Return(-1)) in TYPED_TEST()
422 EXPECT_EQ(-1, this->foo_->CTNullary()); in TYPED_TEST()
423 EXPECT_EQ(0, this->foo_->CTNullary()); in TYPED_TEST()
428 EXPECT_CALL(this->mock_foo_, CTUnary(Eq(2))) in TYPED_TEST()
433 EXPECT_TRUE(this->foo_->CTUnary(2)); in TYPED_TEST()
434 EXPECT_FALSE(this->foo_->CTUnary(2)); in TYPED_TEST()
439 EXPECT_CALL(this->mock_foo_, CTDecimal(true, 'a', 0, 0, 1L, A<float>(), in TYPED_TEST()
443 EXPECT_EQ(10, this->foo_->CTDecimal(true, 'a', 0, 0, 1, 0, 0, 5, NULL, "hi")); in TYPED_TEST()
446 // Tests mocking functions overloaded on the const-ness of this object.
448 EXPECT_CALL(Const(this->mock_foo_), CTConst(_)).WillOnce(Return('a')); in TYPED_TEST()
450 EXPECT_EQ('a', Const(*this->foo_).CTConst(0)); in TYPED_TEST()
455 EXPECT_CALL(this->mock_foo_, CTReturnTypeWithComma()).WillOnce(Return(a_map)); in TYPED_TEST()
457 EXPECT_EQ(a_map, this->mock_foo_.CTReturnTypeWithComma()); in TYPED_TEST()
545 virtual ~StackInterface() {} in ~StackInterface()
548 virtual void Push(const T& value) = 0;
549 virtual void Pop() = 0;
550 virtual int GetSize() const = 0;
552 virtual const T& GetTop() const = 0;
637 virtual ~StackInterfaceWithCallType() {} in ~StackInterfaceWithCallType()
711 MOCK_METHOD(void, Overloaded, ()); \
712 MOCK_METHOD(int, Overloaded, (int), (const)); \
713 MOCK_METHOD(bool, Overloaded, (bool f, int n))
716 MOCK_METHOD0(Overloaded, void()); \
717 MOCK_CONST_METHOD1(Overloaded, int(int n)); \
718 MOCK_METHOD2(Overloaded, bool(bool f, int n))
754 EXPECT_CALL(mock, Overloaded()); in TYPED_TEST()
755 EXPECT_CALL(mock, Overloaded(1)).WillOnce(Return(2)); in TYPED_TEST()
756 EXPECT_CALL(mock, Overloaded(true, 1)).WillOnce(Return(true)); in TYPED_TEST()
758 mock.Overloaded(); in TYPED_TEST()
759 EXPECT_EQ(2, mock.Overloaded(1)); in TYPED_TEST()
760 EXPECT_TRUE(mock.Overloaded(true, 1)); in TYPED_TEST()
764 MOCK_CONST_METHOD1(Overloaded, int(int n)); \
765 MOCK_METHOD1(Overloaded, int(int n))
782 EXPECT_CALL(mock, Overloaded(1)).WillOnce(Return(2)); in TEST()
783 EXPECT_CALL(*const_mock, Overloaded(1)).WillOnce(Return(3)); in TEST()
785 EXPECT_EQ(2, mock.Overloaded(1)); in TEST()
786 EXPECT_EQ(3, const_mock->Overloaded(1)); in TEST()
831 EXPECT_CALL(foo, Call(1)).WillOnce(Return(-1)); in TEST()
832 EXPECT_CALL(foo, Call(2)).WillOnce(Return(-2)); in TEST()
833 EXPECT_EQ(-1, call(foo.AsStdFunction(), 1)); in TEST()
834 EXPECT_EQ(-2, call(foo.AsStdFunction(), 2)); in TEST()
851 EXPECT_CALL(foo, Call(i)).WillOnce(Return(-1)); in TEST()
852 EXPECT_EQ(-1, call(foo.AsStdFunction(), i)); in TEST()
964 #pragma clang diagnostic error "-Wunused-member-function" in TEST()