Skip to content

Bug in TEST_ASSERT_DELTA() and TEST_ASSERT_DELTA_MSG() #18

@pvh513

Description

@pvh513

I just ran into a rather nasty bug. The TEST_ASSERT_DELTA() and TEST_ASSERT_DELTA_MSG() macros will happily accept the test if either a, b, or delta is NaN. In my opinion such a test should always fail. A simple fix would be to negate the test, i.e. change

if (((b) < (a) - (delta)) || ((b) > (a) + (delta)))

into

if (!(((b) >= (a) - (delta)) && ((b) <= (a) + (delta))))

since comparisons involving NaN will always return false (except for !=, but that is not relevant here).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions