Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UtAssert_DoubleCmpRel fabs bug #1410

Open
nistacey opened this issue Sep 1, 2023 · 0 comments
Open

UtAssert_DoubleCmpRel fabs bug #1410

nistacey opened this issue Sep 1, 2023 · 0 comments

Comments

@nistacey
Copy link

nistacey commented Sep 1, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant