Mock a base class function #4572
Unanswered
cole701
asked this question in
Community Help
Replies: 3 comments 2 replies
-
I assume you would mock it like you extend it.
As long as the method is |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you for the response. I thought the whole discussion group was dead!!
The base class is a Gtk library class and the function that I am attempting
to Mock is run().
Rich
…On Mon, Jul 29, 2024 at 21:39 Kenneth Cornett ***@***.***> wrote:
I assume you would mock it like you extend it.
class MockThirdlyDerivedStruct : public ThirdlyDerivedStruct {
MOCK_METHOD(ret_val, func_name, (params...), (override);
};
As long as the method is protected scope, you should be able to access it
from a derived class. You can also make the method virtual in the Base or
...Derived to let your compiler generate a Virtual Lookup Table entry for
the method.
—
Reply to this email directly, view it on GitHub
<#4572 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABBJS5ZVEGCNIWLDMAXMTATZO34HJAVCNFSM6AAAAABKFUSHACVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTAMJYGU3DIMQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Kenneth,
Part of my problem is that my tool set is limited. I am on a closed
government system that is only allowed to have certain authorized
applications and libraries installed. So I have to stick with the
official applications that have been approved and that is gtest and gmock.
Additionally we are also currently stuck at version 1.8 for both until a
newer revision is authorized. So this is why I am trying to get this to
work with gmock.
Rich
…On Fri, Aug 2, 2024 at 11:52 AM Kenneth Cornett ***@***.***> wrote:
So if you are using non-virtual polymorphism, I recommend using one of the
Global Mocking Libraries, currently and personally I trying JOMOCK
<https://github.com/jonah512/jomock> which has a non-virtual polymorphism
example with GTest.
—
Reply to this email directly, view it on GitHub
<#4572 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABBJS5ZO27A6HMKITGN6AQ3ZPO2MPAVCNFSM6AAAAABKFUSHACVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTAMRSGU4TIMQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How do you mock a function that is part of a base class 3 levels of inheritance deep?
Beta Was this translation helpful? Give feedback.
All reactions