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

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

Merged
merged 2 commits into from
Jan 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions ut_assert/inc/utassert.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,162 @@ typedef struct
UtAssert_GenericUnsignedCompare((uint32)(expr), UtAssert_Compare_GT, (uint32)(ref), UtAssert_Radix_DECIMAL, \
__FILE__, __LINE__, "", #expr, #ref)

/**
* \brief Compare two 16-bit values for equality with an auto-generated description message
*
* This macro confirms that the given expression is equal to the reference value
* The generated log message will include the actual and reference values in decimal notation
* Values will be compared in an "uint16" type context.
*/
#define UtAssert_UINT16_EQ(actual, ref) \
UtAssert_GenericUnsignedCompare((uint16)(actual), UtAssert_Compare_EQ, (uint16)(ref), UtAssert_Radix_DECIMAL, \
__FILE__, __LINE__, "Compare UINT16: ", #actual, #ref)

/**
* \brief Compare two 16-bit values for inequality with an auto-generated description message
*
* This macro confirms that the given expression is _not_ equal to the reference value
* The generated log message will include the actual and reference values in decimal notation
* Values will be compared in an "uint16" type context.
*/
#define UtAssert_UINT16_NEQ(actual, ref) \
UtAssert_GenericUnsignedCompare((uint16)(actual), UtAssert_Compare_NEQ, (uint16)(ref), UtAssert_Radix_DECIMAL, \
__FILE__, __LINE__, "Compare UINT16: ", #actual, #ref)

/**
* \brief Asserts the minimum 16-bit value of a given function or expression
*
* \par Description
* This macro confirms that the given expression is at least the minimum 16-bit value (inclusive)
*
* \par Assumptions, External Events, and Notes:
* None
*
*/
#define UtAssert_UINT16_GTEQ(expr, ref) \
UtAssert_GenericUnsignedCompare((uint16)(expr), UtAssert_Compare_GTEQ, (uint16)(ref), UtAssert_Radix_DECIMAL, \
__FILE__, __LINE__, "Compare UINT16: ", #expr, #ref)

/**
* \brief Asserts the maximum 16-bit value of a given function or expression
*
* \par Description
* This macro confirms that the given expression is at most the maximum 16-bit value (inclusive)
*
* \par Assumptions, External Events, and Notes:
* None
*
*/
#define UtAssert_UINT16_LTEQ(expr, ref) \
UtAssert_GenericUnsignedCompare((uint16)(expr), UtAssert_Compare_LTEQ, (uint16)(ref), UtAssert_Radix_DECIMAL, \
__FILE__, __LINE__, "Compare UINT16: ", #expr, #ref)

/**
* \brief Asserts the 16-bit value of a given function or expression is less than the 16-bit reference value
*
* \par Description
* This macro confirms that the given expression is less than the maximum 16-bit value (exclusive)
*
* \par Assumptions, External Events, and Notes:
* None
*
*/
#define UtAssert_UINT16_LT(expr, ref) \
UtAssert_GenericUnsignedCompare((uint16)(expr), UtAssert_Compare_LT, (uint16)(ref), UtAssert_Radix_DECIMAL, \
__FILE__, __LINE__, "Compare UINT16: ", #expr, #ref)

/**
* \brief Asserts the 16-bit value of a given function or expression is greater than the 16-bit reference value
*
* \par Description
* This macro confirms that the given expression is greater than the minimum 16-bit value (exclusive)
*
* \par Assumptions, External Events, and Notes:
* None
*
*/
#define UtAssert_UINT16_GT(expr, ref) \
UtAssert_GenericUnsignedCompare((uint16)(expr), UtAssert_Compare_GT, (uint16)(ref), UtAssert_Radix_DECIMAL, \
__FILE__, __LINE__, "Compare UINT16: ", #expr, #ref)

/**
* \brief Compare two 8-bit values for equality with an auto-generated description message
*
* This macro confirms that the given expression is equal to the reference value
* The generated log message will include the actual and reference values in decimal notation
* Values will be compared in an "uint8" type context.
*/
#define UtAssert_UINT8_EQ(actual, ref) \
UtAssert_GenericUnsignedCompare((uint8)(actual), UtAssert_Compare_EQ, (uint8)(ref), UtAssert_Radix_DECIMAL, \
__FILE__, __LINE__, "Compare UINT8: ", #actual, #ref)

/**
* \brief Compare two 8-bit values for inequality with an auto-generated description message
*
* This macro confirms that the given expression is _not_ equal to the reference value
* The generated log message will include the actual and reference values in decimal notation
* Values will be compared in an "uint8" type context.
*/
#define UtAssert_UINT8_NEQ(actual, ref) \
UtAssert_GenericUnsignedCompare((uint8)(actual), UtAssert_Compare_NEQ, (uint8)(ref), UtAssert_Radix_DECIMAL, \
__FILE__, __LINE__, "Compare UINT8: ", #actual, #ref)

/**
* \brief Asserts the minimum 8-bit value of a given function or expression
*
* \par Description
* This macro confirms that the given expression is at least the minimum 8-bit value (inclusive)
*
* \par Assumptions, External Events, and Notes:
* None
*
*/
#define UtAssert_UINT8_GTEQ(expr, ref) \
UtAssert_GenericUnsignedCompare((uint8)(expr), UtAssert_Compare_GTEQ, (uint8)(ref), UtAssert_Radix_DECIMAL, \
__FILE__, __LINE__, "Compare UINT8: ", #expr, #ref)

/**
* \brief Asserts the maximum 8-bit value of a given function or expression
*
* \par Description
* This macro confirms that the given expression is at most the maximum 8-bit value (inclusive)
*
* \par Assumptions, External Events, and Notes:
* None
*
*/
#define UtAssert_UINT8_LTEQ(expr, ref) \
UtAssert_GenericUnsignedCompare((uint8)(expr), UtAssert_Compare_LTEQ, (uint8)(ref), UtAssert_Radix_DECIMAL, \
__FILE__, __LINE__, "Compare UINT8: ", #expr, #ref)

/**
* \brief Asserts the 8-bit value of a given function or expression is less than the 8-bit reference value
*
* \par Description
* This macro confirms that the given expression is less than the maximum 8-bit value (exclusive)
*
* \par Assumptions, External Events, and Notes:
* None
*
*/
#define UtAssert_UINT8_LT(expr, ref) \
UtAssert_GenericUnsignedCompare((uint8)(expr), UtAssert_Compare_LT, (uint8)(ref), UtAssert_Radix_DECIMAL, \
__FILE__, __LINE__, "Compare UINT8: ", #expr, #ref)

/**
* \brief Asserts the 8-bit value of a given function or expression is greater than the 8-bit reference value
*
* \par Description
* This macro confirms that the given expression is greater than the minimum 8-bit value (exclusive)
*
* \par Assumptions, External Events, and Notes:
* None
*
*/
#define UtAssert_UINT8_GT(expr, ref) \
UtAssert_GenericUnsignedCompare((uint8)(expr), UtAssert_Compare_GT, (uint8)(ref), UtAssert_Radix_DECIMAL, \
__FILE__, __LINE__, "Compare UINT8: ", #expr, #ref)

/**
* \brief Macro for checking that bits in a bit field are set
*
Expand Down