I’m currently trying to test a strcat() function that I wrote myself. Instead of printing the outputs and checking them line by line manually, I’ve decided to use assert from assert.h. The problem is that assert is showing errors even though the outputs look totally fine. The following is my code:
void mystrcat_test()
{
char str[BUFSIZ];
assert(strcmp(str, ""));
mystrcat(str, "hello");
assert(strcmo(str, "hello"));
}
strcmpreturns 0 if both strings are same.asserttakes 0 (false) as an indication that the test failed and will report error. So the test should be: