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

Void pointers in function parameters make building mock failing #24

Open
Christer-Ekholm opened this issue Apr 26, 2022 · 3 comments
Open

Comments

@Christer-Ekholm
Copy link

If I studied correctly then the following code have problems to be mocked.

class A
{
void * b(void * a, const void *b);
}

ISEQUAL template cannot compare void poiters.

@maltekliemann
Copy link
Member

That's true. The interface of IsEqual is not made to handle this situation.

Could you tell me how exactly you would compare void pointers? The only immediate option I see is to check if both point to the same address.

If you have a rough idea what type of data these pointers refer to, then I recommend using a wrapper struct which contains the data and can be handled by our framework.

@Christer-Ekholm
Copy link
Author

I am working with embedded software and those void pointers are related to transfer buffers. Like UART_write(int fd, const void * data, int len);

I would do void pointer comparison so that unit test writer can decide if just compare if same address or maybe UT writer can give lambda function for testing equality of void pointers.

@maltekliemann
Copy link
Member

Hmm, okay. I don't have the time to dive into this, but you may be able to solve this by writing a custom implementation of IMatcher (see https://github.com/DrCpp/DrMock/blob/master/docs/tutorial/mock.md#matching-and-polymorphism)

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

No branches or pull requests

2 participants