Skip to content

UtAssert_DoubleCmpRel fabs bug #1410

@nistacey

Description

@nistacey

Describe the bug
There is an issue with the macro UtAssert_DoubleCmpRel in the file osal/ut_assert/inc/utassert.h. If the input x is a positive number, then the test will always pass (assuming that Ratio is positive). Recommend changing this macro to

#define UtAssert_DoubleCmpRel(x, y, Ratio, ...)
UtAssertEx((fabs(((x) - (y)) / (x)) <= (Ratio)), UtAssert_GetContext(), FILE, LINE, VA_ARGS)

To Reproduce
Steps to reproduce the behavior:

  1. Create unit test where the first input to UtAssert_DoubleCmpRel is a large positive number (e.g., 1e3), the second input is a large negative number (e.g., -1e3), and the third input is a very small positive number (e.g., 1e-10).

Expected behavior
The output of UtAssert_DoubleCmpRel is success even though the first and second inputs are very different.

System observed on:
N/A

Reporter Info
Nathan Stacey, NASA GSFC

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