Skip to content

Commit

Permalink
Merge pull request #1202 from kurtjd.fix-1196-add-uint8-and-uint16-eq…
Browse files Browse the repository at this point in the history
…uivalents-for-UtAssert_UINT32-macros

Fix #1196, Add UINT8 and UINT16 equivalents for UtAssert_UINT32_<Comparison> macros
  • Loading branch information
astrogeco committed Jan 19, 2022
2 parents 2b15096 + a3bf245 commit 3d1a7e4
Showing 1 changed file with 156 additions and 0 deletions.
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

0 comments on commit 3d1a7e4

Please sign in to comment.