alelievr / libft-unit-test

457 stars 88 forks source link

More tests in strncmp #80

Closed cos18 closed 3 years ago

cos18 commented 4 years ago

Hello. I'm doing Libft with your unit test. It seems that in strncmp, there is no testcase in particular situation. ( similar with #41 )

My code was this

int ft_strncmp(const char *s1, const char *s2, size_t n)
{
    size_t  locate;
    locate = -1;
    while (++locate < n && *s1 && *s2)
    {
        if (*s1 != *s2)
            break;
        s1++;
        s2++;
    }
    return ((unsigned char)(*s1) - (unsigned char)(*s2));
}

and all of your unit test seems to OK, but when s1 = "abc", s2 = "abcde", n = 3, my ft function can't find s1 and s2 is same. I think you should add test similar to #41.

Thank you for making this great unit test program.

alelievr commented 3 years ago

Hello, I added this test in this commit: https://github.com/alelievr/libft-unit-test/commit/7f20a2844a33870cd444e8cf117b8974a2f25209

Thanks for reporting this issue :)