alelievr/libft-unit-test

Potential tests missing for ft_atoi

Javicobos opened this issue · 1 comments

Hi! I found out that some tests could be added for atoi that aren't there yet. Right now the tester checks the biggest and smallest long ints, which give -1 and 0 with the standard atoi. This means that if a user hardcodes anything below int_min to give 0 and anything above int_max to give -1, they'll pass the test but their function will not behave like atoi for most other long ints (that are not the max or min). I don't think moulinette checks this at all, but it can be nice to add to the tester for people who want to have exactly the same behavior as the system's atoi.
Here's a quick check I did. if the atoi is hardcoded with int_min and int_max the values will be different:

int main()
{
char asd[40] = "-9223372036854775805"; //value near long int min, but not exactly long int min
char dsa[40] = "9223372036854775802"; //value near long int max, but not exactly long int max
int i1;
int i2;
int i3;
int i4;
i1 = ft_atoi(asd);
i2 = atoi(asd);
i3 = ft_atoi(dsa);
i4 = atoi(dsa);
printf("my value is: %i \n", i1);
printf("atoi's value is: %i \n", i2);
printf("my value is: %i \n", i3);
printf("atoi's value is: %i \n", i4);
}

I hope this is correct and/or useful and thanks for the work you put into this!

Hello! Thanks for contributing to the libft unit test.

Note that this repository is not maintained by the owner anymore, instead there is a bot that will automatically merge any reviewed pull requests.
If you feel like it, here are some links that can help you submiting a change in the code base::