Skip to content

Bug in ASSERT_IN_RANGE with NaN? #108

Open
@breuderink

Description

@breuderink

I think I have encountered a bug in ASSERT_IN_RANGE. When the value to be tested is NaN, the test passes. For example, this test passes:

TEST nan_handling(void) {
    ASSERT_IN_RANGE(1, NAN, 1e-6);
    PASS();
}

(Tested with Apple clang version 12.0.0 on macOS 11.2.3).

Since NaN is not equal to any number, and thus not equal to numbers in the range, this test should fail. I am willing to create a pull-request if this is indeed a bug. It can probably be corrected by inverting some of the inequalities in https://github.com/silentbicycle/greatest/blob/master/greatest.h#L541-L544.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions