I'm doing unit tests. I have to test ALL possible if..else
cases. But in this if
statement:
int32_t i32Res = snprintf(buffer, len, "The%d_String_%d", 0, u8Idx);
if ((i32Res < 0) || (i32Res >= len))
{
return enuErrVal;
}
i32Res
is never < 0
, it always ends up having the string's size value. I can only force the buffer
and len
variables. I have tried with a null buffer
but it crashes before actually reaching the if
. I have tried with very small and very big sizes in buffer
. I tried with low (2
) values on len
.
I know snprintf()
returns -1
on encoding errors, how can I force this?