alelievr / libft-unit-test

457 stars 88 forks source link

strlcat test 2 expects the wrong value #31

Closed TRON-N closed 7 years ago

TRON-N commented 7 years ago

I'm loving the libft-unit-test, it's really helpful, but I noticed an issue with the one of the strlcat tests.

On the second test ft_strlcat is given two strings: "the cake is a lie !\0I'm hidden lol\r\n" and "there are no stars in the sky"

According to the test ft_strlcat should return 42, but in actuality the combined length of those two strings is 47, I counted it, and double checked with strlen. I also took into account that the first string's length should be up to but not including the '\0', and completely ignoring the "I'm hidden" part.

I'm using the libft-unit-test on Ubuntu.

alelievr commented 7 years ago

Hello,

I think you missed something in the strlcat behaviour, your reasoning should be right without the size parameter of the strlcat function (which in this test is 23, smaller than the first string length).

I will not give you the solution here but try to have a look to the buffer in the test's code after a call of strlcat.

test code:

char    *str = "the cake is a lie !\0I'm hidden lol\r\n";
char    buff1[0xF00] = "there is no stars in the sky";
char    buff2[0xF00] = "there is no stars in the sky";
size_t  max = strlen("the cake is a lie !\0I'm hidden lol\r\n") + 4;

size_t  r1 = strlcat(buff1, str, max);
size_t  r2 = ft_strlcat(buff2, str, max);
SET_DIFF_INT((int)r1, (int)r2);
ASSERT_RETURN_VALUE(r1, r2);

Good luck !