Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, Actually am trying to mock the library function like(send, recv, connect, accept), but i do not how to mock to it. normally, for user-defined class member function using function overriding concept i will mock it. but for global function how to mock it?...

What I have tried:

Mocking related query need to know
Posted
Updated 13-Feb-22 21:47pm

Can't you simply include your header (containing the mocking functions) instead of sys/socket.h ?
 
Share this answer
 
Comments
KarstenK 14-Feb-22 2:56am    
and best is to use #define to include the mocking instead of the socket header.
As CPallini say, just add your own header. Or you can just create a module in your project that contains the functions you want. Something like:
C++
ssize_t send(int sockfd, const void *buf, size_t len, int flags)
{
    // Add whatever local code you need here
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900