alelievr / libft-unit-test

453 stars 88 forks source link

False positive in ft_toupper.c test #138

Closed pedrodesu closed 1 year ago

pedrodesu commented 1 year ago
#define THRESHOLD 'a' - 'A'

int ft_toupper(int c)
{
    if (c >= 'a' && c <= 'z')
    {
        return (c - THRESHOLD);
    }
    else
    {
        return (c);
    }
}
int ft_toupper(int c)
{
    if (c >= 'a' && c <= 'z')
    {
        return (c - ('a' - 'A'));
    }
    else
    {
        return (c);
    }
}

The first snippet fails, whereas the second one passes. They're equivalent and there doesn't seem to exist any apparent reason for the first one not to pass. I'm guessing it's some type of problem with macros?

github-actions[bot] commented 1 year ago

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::

pedrodesu commented 1 year ago

Complete noob mistake on my part, there's no false positive. thx for the heads up @Kuninoto. closing.