In the C++ project I'm doing at work I have to accomplish high code coverage with gTest/gMock, but the problem is that I also have to use external C library (net-snmp in particular). Since I use that library a lot and and as far as I know C functions can't be mocked I don't see how I can get even close to above 90% line coverage.
For example, majority of my code is like this:
int status = snmp_synch_response(ss, pdu, &response);
if (status == STAT_SUCCESS && response->errstat == SNMP_ERR_NOERROR)
{
netsnmp_variable_list *vars = response->variables;
if (var->type == ASN_OCTET_STR)
{
//...
}
else if (var->type == ASN_INTEGER)
{
//...
}
else
{
//...
}
//...
}
Because the call to library function snmp_synch_response
is never successful in test this if branch is never entered and the majority of my code is like this.
I'm still a beginner, especially with writing tests, so I'm not sure if I'm missing something obviously here?