You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
A very common use case in unit testing is to assert on an int32 value, as this is a common return value type for error codes and status values.
UT Assert provides a generic UtAssert_True() macro which can certainly test for integer equality, but it is still very repetitive and test cases may not include all the relevant information. For instance, the framework should encourage/require that the actual values are printed in addition to the pass/fail status, and the generic macro being totally free-form does not enforce this at all.
Describe the solution you'd like
Add a macro UtAssert_INT32_EQ() to check for equality of two values as int32 types.
Other types could be added too, but int32 is by far the most commonly needed as it is the return type of many API calls across OSAL and CFE.
Describe alternatives you've considered
Continue using the generic UtAssert_True() macro.
Additional context
Many test programs already use their own macros for testing return values. They've already evolved to be similar but different (e.g. CFE SB has ASSERT_EQ, and OSAL coverage testing has OSAPI_TEST_FUNCTION_RC()).
It would be worthwhile to put more of these in UT assert itself so these don't need to continue being duplicated.
Requester Info
Joseph Hickey, Vantage Systems, Inc.
The text was updated successfully, but these errors were encountered:
jphickey
added a commit
to jphickey/osal
that referenced
this issue
Jun 16, 2020
Add the following macros for UT assert:
UtAssert_INT32_EQ - check equality as 32 bit signed int
UtAssert_UINT32_EQ - check equality as 32 bit unsigned int
UtAssert_NOT_NULL - check pointer not null
UtAssert_NULL - check pointer is null
UtAssert_NONZERO - check integer is nonzero
UtAssert_ZERO - check integer is zero
UtAssert_STUB_COUNT - check stub count
These are all just wrappers around UtAssert_True for
commonly-used asserts. The description message is
auto generated so it is consistent.
Is your feature request related to a problem? Please describe.
A very common use case in unit testing is to assert on an
int32
value, as this is a common return value type for error codes and status values.UT Assert provides a generic
UtAssert_True()
macro which can certainly test for integer equality, but it is still very repetitive and test cases may not include all the relevant information. For instance, the framework should encourage/require that the actual values are printed in addition to the pass/fail status, and the generic macro being totally free-form does not enforce this at all.Describe the solution you'd like
Add a macro
UtAssert_INT32_EQ()
to check for equality of two values asint32
types.Other types could be added too, but
int32
is by far the most commonly needed as it is the return type of many API calls across OSAL and CFE.Describe alternatives you've considered
Continue using the generic
UtAssert_True()
macro.Additional context
Many test programs already use their own macros for testing return values. They've already evolved to be similar but different (e.g. CFE SB has
ASSERT_EQ
, and OSAL coverage testing hasOSAPI_TEST_FUNCTION_RC()
).It would be worthwhile to put more of these in UT assert itself so these don't need to continue being duplicated.
Requester Info
Joseph Hickey, Vantage Systems, Inc.
The text was updated successfully, but these errors were encountered: