alelievr / libft-unit-test

457 stars 88 forks source link

test missing ft_strnstr #50

Closed hugodu69 closed 5 years ago

hugodu69 commented 5 years ago

there is something that my ft_strnstr did wrong but that wasn't catch by this unit test : if the little string to find in the big string is one position ahead of the lenth sended, it should return NULL but I was returning little (at least in case little is a single character), like so :

strnstr("0123456789", "9", 8);

strnstr shouldn't find 9 because it's in ninth position and length is 8, but mine ft_strnstr was missing a >= instead of just > somewhere and it returned back 9.

alelievr commented 5 years ago

Hi, fixed in fb7eeb2, thanks for your contribution !