Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to call real function with CMOCK_MOCK_FUNCTIONn macros #17

Closed
devesh25427 opened this issue Jul 16, 2020 · 5 comments · Fixed by #22
Closed

How to call real function with CMOCK_MOCK_FUNCTIONn macros #17

devesh25427 opened this issue Jul 16, 2020 · 5 comments · Fixed by #22

Comments

@devesh25427
Copy link

I am trying to use new style CMOCK_MOCK_FUNCTIONn macros and want to invoke real function in expectation. I am unable to figure out how to do that?

@hjagodzinski
Copy link
Owner

@devesh25427 please take a look at section Specifying expectations. The botom line is:

The functions are mocked as long as its corresponding mocker class instance exists

If not mocked, the real function will be called.

@devesh25427
Copy link
Author

@hjagodzinski thanks for reply. I understood that real function is called when there is no mock class instance. Earlier I was able to call real function using Invoke(<mock_class_name>::real) because there was a static member in class pointing to real function. I can still see static real function pointer created by CMOCK_MOCK_FUNCTIONn macro but don't know how to call it.
Sometimes I need to call real instance while setting expectation.

@hjagodzinski
Copy link
Owner

I see now what you're after. Unfortunately there is no support for calling a real function while specifying expectations. Internally C Mock keeps pointer to a real function and you could use that but it's far from being ideal. I will look into ways to expose a real function so it can be used in cases like yours.

@devesh25427
Copy link
Author

Thanks @hjagodzinski

@hjagodzinski
Copy link
Owner

@devesh25427 in case you are still interested I have created pull request #22 which provides the means to call a real function when using the CMockMocker class for mocking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants