alelievr / libft-unit-test

457 stars 88 forks source link

Possible bug? #46

Closed Traezar closed 6 years ago

Traezar commented 6 years ago

ft_strnstr: [OK] [OK] [FAILED] [OK] [OK] [OK] [OK] [OK] [OK] [OK] [OK] [OK] [fail]: your strnstr does not work with basic input Test code: char s1 = "MZIRIBMZIRIBMZE123"; char s2 = "MZIRIBMZE"; size_t max = strlen(s2); char i1 = strnstr(s1, s2, max); char i2 = ft_strnstr(s1, s2, max);

if (i1 == i2)
    exit(TEST_SUCCESS);
exit(TEST_FAILED);

Diffs: strnstr: |(null)| ft_strnstr: |MZIRIBMZE123|

suiramdev commented 1 year ago

Same issue here, why would this be wrong ?

EDIT: Indeed, it's my fault. I found the issue. For who's having the same issue, when there is a matching character, you should check for the next ones until i < len too. I was watching for i < len in my first loop, not the matching loop.