-
Notifications
You must be signed in to change notification settings - Fork 243
Open
Description
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:
- 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
Labels
No labels