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

Add UINT8 and UINT16 equivalents for UtAssert_UINT32_<Comparison> macros #1196

Closed
asgibson opened this issue Nov 26, 2021 · 1 comment · Fixed by #1202
Closed

Add UINT8 and UINT16 equivalents for UtAssert_UINT32_<Comparison> macros #1196

asgibson opened this issue Nov 26, 2021 · 1 comment · Fixed by #1202

Comments

@asgibson
Copy link
Contributor

asgibson commented Nov 26, 2021

Is your feature request related to a problem? Please describe.
Using a UINT32 comparison for smaller uint types does not allow for roll-over situations that are considered a pass condition:

UtAssert_UINT32_EQ(Some_uint8_ValueUnderTest, UnknownStartValueThatHappensToBeMax_uint8 + 1);

outputs:
🔴[ FAIL] 01.001 a_test.c:5 - Some_uint8_ValueUnderTest (0) == UnknownStartValueThatHappensToBeMax_uint8 + 1 (256)

Describe the solution you'd like
A UINT8 comparison could provide an output like this:
🟢[ PASS] 01.001 a_test.c:5 - Some_uint8_ValueUnderTest (0) == UnknownStartValueThatHappensToBeMax_uint8 + 1 (0)

Additionally, use could be made of the desc argument in the actual call (UtAssert_GenericUnsignedCompare) to distinguish it from a UINT32 call and add pertinent information for the developer:
🟢[ PASS] 01.001 a_test.c:5 - Compare UINT8: SomeValueUnderTest (0) == UnknownStartValueThatHappensToBeMax + 1 (0)

Describe alternatives you've considered
Adding a typecast to every assert:

UtAssert_UINT32_EQ((uint8)SomeValueUnderTest, (uint8)(UnknownStartValueThatHappensToBeMax + 1));

which does provide decent output:
🟢[ PASS] 01.001 a_test.c:5 - (uint8)SomeValueUnderTest (0) == (uint8)(UnknownStartValueThatHappensToBeMax + 1) (0)

Additional context
The requirement for adding a typecast becomes cumbersome over time, but writing a line like this is simpler:

UtAssert_UINT8_EQ(SomeValueUnderTest, UnknownStartValueThatHappensToBeMax + 1);

and will provide just as much clarity, if not more.

Requester Info
Alan Gibson
NASA/GSFC 587

astrogeco added a commit that referenced this issue Jan 19, 2022
…uivalents-for-UtAssert_UINT32-macros

Fix #1196, Add UINT8 and UINT16 equivalents for UtAssert_UINT32_<Comparison> macros
@asgibson
Copy link
Contributor Author

Thanks!

@skliper skliper added this to the Draco milestone Mar 25, 2022
jphickey pushed a commit to jphickey/osal that referenced this issue Aug 10, 2022
cFE Integration candidate: 2021-03-02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants