diff --git a/Demo/cmd_shell/demo.c b/Demo/cmd_shell/demo.c index a49a12b84168339ea9d45684748438adb9cd2291..a976d631ca6c9947c8b093a07788e7cdb7b64079 100644 --- a/Demo/cmd_shell/demo.c +++ b/Demo/cmd_shell/demo.c @@ -1,170 +1,46 @@ -#include "param.h" +#include "param_demo.h" +#include #include -PARAM_DEFINE_DAT (test, PARAM_INT16, 10, -100, 100); -PARAM_DEFINE_DAT (test_2, PARAM_UINT16, 20, 0, 100); -PARAM_DEFINE_DAT (test_3, PARAM_DOUBLE, 3.15, -10, 10); -PARAM_DEFINE_STR (test_str, 10, "abcdef"); -PARAM_DEFINE_DAT (test_4, PARAM_INT8, 8, -10, 10); -PARAM_DEFINE_DAT (test_5, PARAM_UINT32, 620, 500, 10000); -PARAM_DEFINE_DAT (test_6, PARAM_UINT8, 4, 5, 100); -PARAM_DEFINE_DAT (test_7, PARAM_INT64, 5, -542, 5450); - -ParamInfo_t sg_ParamTable[] = { - PARAM_ITEM_DAT(1, test, PARAM_ATTR_ALL), - PARAM_ITEM_DAT(2, test_2, PARAM_ATTR_READ), - PARAM_ITEM_DAT(3, test_3, PARAM_ATTR_READ | PARAM_ATTR_WRITE), - PARAM_ITEM_STR(4, test_str, PARAM_ATTR_READ | PARAM_ATTR_WRITE), - PARAM_ITEM_DAT(5, test_4, PARAM_ATTR_READ), - PARAM_ITEM_DAT(6, test_5, PARAM_ATTR_READ), - PARAM_ITEM_DAT(7, test_6, PARAM_ATTR_READ), - PARAM_ITEM_DAT(8, test_7, PARAM_ATTR_WRITE), -}; - -#define ATTR(x) ((x & (PARAM_ATTR_READ | PARAM_ATTR_WRITE)) == (PARAM_ATTR_READ | PARAM_ATTR_WRITE) ? \ - "wr" : (x & (PARAM_ATTR_READ) ? "r" : ((x & (PARAM_ATTR_WRITE) ? "w" : "")))) -#define VIEW(type, val) (type##_T)(*(type##_T *)val) - -void ShowAllParam(const ParamInfo_t *paramTable, uint16_t num) + +int main() { - printf("%4s %-15s %-8s %-8s %-8s %-10s %-10s %-10s %-10s\n", "id", "name", "type", "length", "attr", "val", "def", "min", "max"); - - for (int i = 0; i < num; i++) - { - switch (paramTable[i].type) - { - case PARAM_INT8: - printf(" %-4d %-15s %-10s %-6d %-8s %-10d %-10d %-10d %-10d\n", - paramTable[i].id, paramTable[i].pszName, "int8_t", paramTable[i].length, ATTR(paramTable[i].attr), - VIEW(PARAM_INT8, paramTable[i].pCurValue), VIEW(PARAM_INT8, paramTable[i].pDefValue), - VIEW(PARAM_INT8, paramTable[i].pMinValue), VIEW(PARAM_INT8, paramTable[i].pMaxValue)); - break; - case PARAM_INT16: - printf(" %-4d %-15s %-10s %-6d %-8s %-10d %-10d %-10d %-10d\n", - paramTable[i].id, paramTable[i].pszName, "int16_t", paramTable[i].length, ATTR(paramTable[i].attr), - VIEW(PARAM_INT16, paramTable[i].pCurValue), VIEW(PARAM_INT16, paramTable[i].pDefValue), - VIEW(PARAM_INT16, paramTable[i].pMinValue), VIEW(PARAM_INT16, paramTable[i].pMaxValue)); - break; - case PARAM_INT32: - printf(" %-4d %-15s %-10s %-6d %-8s %-10d %-10d %-10d %-10d\n", - paramTable[i].id, paramTable[i].pszName, "int32_t", paramTable[i].length, ATTR(paramTable[i].attr), - VIEW(PARAM_INT32, paramTable[i].pCurValue), VIEW(PARAM_INT32, paramTable[i].pDefValue), - VIEW(PARAM_INT32, paramTable[i].pMinValue), VIEW(PARAM_INT32, paramTable[i].pMaxValue)); - break; - case PARAM_INT64: - printf(" %-4d %-15s %-10s %-6d %-8s %-10lld %-10lld %-10lld %-10lld\n", - paramTable[i].id, paramTable[i].pszName, "int64_t", paramTable[i].length, ATTR(paramTable[i].attr), - VIEW(PARAM_INT64, paramTable[i].pCurValue), VIEW(PARAM_INT64, paramTable[i].pDefValue), - VIEW(PARAM_INT64, paramTable[i].pMinValue), VIEW(PARAM_INT64, paramTable[i].pMaxValue)); - break; - case PARAM_UINT8: - printf(" %-4d %-15s %-10s %-6d %-8s %-10u %-10u %-10u %-10u\n", - paramTable[i].id, paramTable[i].pszName, "uint8_t", paramTable[i].length, ATTR(paramTable[i].attr), - VIEW(PARAM_UINT8, paramTable[i].pCurValue), VIEW(PARAM_UINT8, paramTable[i].pDefValue), - VIEW(PARAM_UINT8, paramTable[i].pMinValue), VIEW(PARAM_UINT8, paramTable[i].pMaxValue)); - break; - case PARAM_UINT16: - printf(" %-4d %-15s %-10s %-6d %-8s %-10u %-10u %-10u %-10u\n", - paramTable[i].id, paramTable[i].pszName, "uint16_t", paramTable[i].length, ATTR(paramTable[i].attr), - VIEW(PARAM_UINT16, paramTable[i].pCurValue), VIEW(PARAM_UINT16, paramTable[i].pDefValue), - VIEW(PARAM_UINT16, paramTable[i].pMinValue), VIEW(PARAM_UINT16, paramTable[i].pMaxValue)); - break; - case PARAM_UINT32: - printf(" %-4d %-15s %-10s %-6d %-8s %-10u %-10u %-10u %-10u\n", - paramTable[i].id, paramTable[i].pszName, "uint32_t", paramTable[i].length, ATTR(paramTable[i].attr), - VIEW(PARAM_UINT32, paramTable[i].pCurValue), VIEW(PARAM_UINT32, paramTable[i].pDefValue), - VIEW(PARAM_UINT32, paramTable[i].pMinValue), VIEW(PARAM_UINT32, paramTable[i].pMaxValue)); - break; - case PARAM_UINT64: - printf(" %-4d %-15s %-10s %-6d %-8s %-10llu %-10llu %-10llu %-10llu\n", - paramTable[i].id, paramTable[i].pszName, "uint64_t", paramTable[i].length, ATTR(paramTable[i].attr), - VIEW(PARAM_UINT64, paramTable[i].pCurValue), VIEW(PARAM_UINT64, paramTable[i].pDefValue), - VIEW(PARAM_UINT64, paramTable[i].pMinValue), VIEW(PARAM_UINT64, paramTable[i].pMaxValue)); - break; - case PARAM_FLOAT: - printf(" %-4d %-15s %-10s %-6d %-8s %-10f %-10f %-10f %-10f\n", - paramTable[i].id, paramTable[i].pszName, "float", paramTable[i].length, ATTR(paramTable[i].attr), - VIEW(PARAM_FLOAT, paramTable[i].pCurValue), VIEW(PARAM_FLOAT, paramTable[i].pDefValue), - VIEW(PARAM_FLOAT, paramTable[i].pMinValue), VIEW(PARAM_FLOAT, paramTable[i].pMaxValue)); - break; - case PARAM_DOUBLE: - printf(" %-4d %-15s %-10s %-6d %-8s %-10f %-10f %-10f %-10f\n", - paramTable[i].id, paramTable[i].pszName, "double", paramTable[i].length, ATTR(paramTable[i].attr), - VIEW(PARAM_DOUBLE, paramTable[i].pCurValue), VIEW(PARAM_DOUBLE, paramTable[i].pDefValue), - VIEW(PARAM_DOUBLE, paramTable[i].pMinValue), VIEW(PARAM_DOUBLE, paramTable[i].pMaxValue)); - break; - case PARAM_STARING: - printf(" %-4d %-15s %-10s %-6d %-8s %-10s %-10s\n", - paramTable[i].id, paramTable[i].pszName, "string", paramTable[i].length, ATTR(paramTable[i].attr), - (char *)paramTable[i].pCurValue, (char *)paramTable[i].pDefValue); - break; - - default: - break; - } - } -} + InitParam(true); -#define HEX_PRINTF(str, hex, len) \ - printf("%s: [%d] -> ", str, len);\ - for (int i = 0; i < (len); i++){printf("%02x ", hex[i]);}\ - printf("\n"); + ShowAllParam(); -uint8_t sg_buf[500]; + g_test = 80; + g_test_3 = -20.5; + + SaveParam(false); + ReloadParam(false); + + int ret = PARAM_DAT_SET_NEW_VALUE(g_test_6, 50, PARAM_DEF); + printf("ret = %d, g_test_6 = %d\n", ret, g_test_6); + + ret = PARAM_DAT_SET_NEW_VALUE(g_test_6, 101, PARAM_DEF); + printf("ret = %d, g_test_6 = %d\n", ret, g_test_6); + + ret = PARAM_DAT_SET_NEW_VALUE(g_test_6, 101, PARAM_NONE); + printf("ret = %d, g_test_6 = %d\n", ret, g_test_6); + + ret = PARAM_DAT_SET_NEW_VALUE(g_test_6, 101, PARAM_MIN_MAX); + printf("ret = %d, g_test_6 = %d\n", ret, g_test_6); + + ret = PARAM_DAT_SET_NEW_VALUE(g_test_6, 1, PARAM_MIN_MAX); + printf("ret = %d, g_test_6 = %d\n", ret, g_test_6); + + PARAM_STR_SET_NEW_VALUE(g_test_str, "123aa9", PARAM_NONE); + printf("ret = %d, g_test_str = %s\n", ret, g_test_str); + + PARAM_STR_SET_NEW_VALUE(g_test_str, "123aa1245249", PARAM_DEF); + printf("ret = %d, g_test_str = %s\n", ret, g_test_str); + + PARAM_STR_SET_NEW_VALUE(g_test_str, "123aa945457", PARAM_MIN_MAX); + printf("ret = %d, g_test_str = %s\n", ret, g_test_str); + + ShowAllParam(); -int main() -{ - size_t length; - - printf("\nInit:\n"); - ShowAllParam(sg_ParamTable, sizeof(sg_ParamTable) / sizeof(ParamInfo_t)); - - /* 展示多种序列化方式效果 */ - - length = Param_Serialize(sg_buf, sg_ParamTable, sizeof(sg_ParamTable) / sizeof(ParamInfo_t), 0, 0); // 普通序列化 - HEX_PRINTF("\n1- Serialize", sg_buf, length); - - length = Param_Serialize(sg_buf, sg_ParamTable, sizeof(sg_ParamTable) / sizeof(ParamInfo_t), 0, 1); // 编码序列化 - HEX_PRINTF("2- Serialize", sg_buf, length); - - length = Param_Serialize(sg_buf, sg_ParamTable, sizeof(sg_ParamTable) / sizeof(ParamInfo_t), 1, 0); // 增加键值序列化 - HEX_PRINTF("3- Serialize", sg_buf, length); - - length = Param_Serialize(sg_buf, sg_ParamTable, sizeof(sg_ParamTable) / sizeof(ParamInfo_t), 1, 1); // 增加键值并编码序列化 - HEX_PRINTF("4- Serialize", sg_buf, length); - - /* 直接使用该值修改后显示 */ - test = -50; - test_2 = 10; - test_3 = 8.265; - sprintf(test_str, "%s", "ertb"); - - printf("\nchange:\n"); - ShowAllParam(sg_ParamTable, sizeof(sg_ParamTable) / sizeof(ParamInfo_t)); - - - /* 对修改之前的序列化后的数据反序列化(需要使用序列化前定义的参数表信息),得到的是修改前的数据 */ - Param_Parse(sg_buf, length, sg_ParamTable, sizeof(sg_ParamTable) / sizeof(ParamInfo_t), 1, 1); - printf("\nParse:\n"); - ShowAllParam(sg_ParamTable, sizeof(sg_ParamTable) / sizeof(ParamInfo_t)); - - /* 使用完整信息接口序列化数据(无序列化选项,可修改看效果) */ - length = Param_MultiSerialize(sg_buf, sg_ParamTable, sizeof(sg_ParamTable) / sizeof(ParamInfo_t), 0); // PARAM_PACK_ATTR | PARAM_PACK_NAME - HEX_PRINTF("\nMultiSerialize", sg_buf, length); - - /* 使用完整信息接口序列化数据(序列化选项拉满,可修改看效果) */ - length = Param_MultiSerialize(sg_buf, sg_ParamTable, sizeof(sg_ParamTable) / sizeof(ParamInfo_t), PARAM_PACK_ALL); // PARAM_PACK_ATTR | PARAM_PACK_NAME - HEX_PRINTF("\nMultiSerialize", sg_buf, length); - - - // 模拟跨设备使用该代码解析,定义一个空的数据参数表 - ParamInfo_t tParamTable[10]; - - uint16_t num = Param_MultiParse(sg_buf, length, &tParamTable[0], 10); // 将完整信息接口序列化数据反序列化出来 - - printf("\nMultiParse:\n"); - ShowAllParam(tParamTable, num); // 展示信息 - return 0; } diff --git a/Demo/cmd_shell/makefile b/Demo/cmd_shell/makefile index 4c17bf3b9bd9b7926098acf9797d4e1fed8fd2c2..863f05ec868e4a9112a74443cfac56114ae23ab7 100644 --- a/Demo/cmd_shell/makefile +++ b/Demo/cmd_shell/makefile @@ -7,8 +7,8 @@ INC+=-I${CURR_DIR_PATH}/../../Param/inc INC+=-I${CURR_DIR_PATH}/ SRC+=${CURR_DIR_PATH}/../../Param/src/param.c -SRC+=${CURR_DIR_PATH}/../../Param/src/stream.c SRC+=${CURR_DIR_PATH}/demo.c +SRC+=${CURR_DIR_PATH}/param_demo.c AIM_NAME:=demo diff --git a/Demo/cmd_shell/param_demo.c b/Demo/cmd_shell/param_demo.c new file mode 100644 index 0000000000000000000000000000000000000000..afce39c74c8517e19a2e5c4ecabf6b94ac4d9c32 --- /dev/null +++ b/Demo/cmd_shell/param_demo.c @@ -0,0 +1,433 @@ +#include "param_demo.h" +#include +#include +#include + +/****************************************** 模拟储存设备操作 ******************************************************/ +// 储存空间定义 +uint8_t sg_buf[500]; +uint32_t sg_length = 0; + +#define HEX_PRINTF(str, hex, len) \ + printf("%s: [%d] -> ", str, len);\ + for (int i = 0; i < (len); i++){printf("%02x ", hex[i]);}\ + printf("\n"); + +// 从储存空间读取数据 +int OnLoadCallback(uint8_t *pBuf, uint16_t *len, bool *pisFinish) +{ + uint16_t needReadLen = *len; + static uint32_t s_offset = 0; + + if (sg_length == s_offset) + { + *len = 0; + s_offset = 0; + *pisFinish = true; + return 0; + } + else + { + *pisFinish = false; + } + + if (sg_length - s_offset < needReadLen) + { + needReadLen = sg_length - s_offset; + } + + memcpy(pBuf, &sg_buf[s_offset], needReadLen); + HEX_PRINTF("\tread", pBuf, needReadLen); + *len = needReadLen; + s_offset += needReadLen; + + return 0; +} + +// 写数据至储存空间 +int OnSaveCallback(const uint8_t *pBuf, uint16_t len, bool isFinish) +{ + static uint32_t s_offset = 0; + + if (isFinish) + { + HEX_PRINTF("\tsave", sg_buf, s_offset + len); + s_offset = 0; + return 0; + } + + memcpy(&sg_buf[s_offset], pBuf, len); + HEX_PRINTF("\tsave", pBuf, len); + s_offset += len; + sg_length = s_offset; + + return 0; +} + +/****************************************** 模拟储存设备操作 ******************************************************/ + + + +PARAM_DEFINE_DAT (g_test, PARAM_INT16, 10); +PARAM_DEFINE_DAT_DEF (g_test_2, PARAM_UINT16, 20); +PARAM_DEFINE_DAT_RANGE (g_test_3, PARAM_DOUBLE, 3.15, -10, 10); +PARAM_DEFINE_STR_RANGE (g_test_str, 10, "abcdef", 5); +PARAM_DEFINE_DAT_RANGE (g_test_4, PARAM_INT8, 8, -10, 10); +PARAM_DEFINE_DAT_RANGE (g_test_5, PARAM_UINT32, 620, 500, 10000); +PARAM_DEFINE_DAT_RANGE (g_test_6, PARAM_UINT8, 45, 5, 100); +PARAM_DEFINE_DAT_RANGE (g_test_7, PARAM_INT64, 5, -542, 5450); + +ParamInfo_t sg_ParamTable[] = { + PARAM_ITEM_DAT(1, g_test, PARAM_ATTR_WR), + PARAM_ITEM_DAT_DEF(2, g_test_2, PARAM_ATTR_WR), + PARAM_ITEM_DAT_RANGE(3, g_test_3, PARAM_ATTR_WR), + PARAM_ITEM_STR_RANGE(4, g_test_str, PARAM_ATTR_WR), + PARAM_ITEM_DAT_RANGE(5, g_test_4, PARAM_ATTR_WR), + PARAM_ITEM_DAT_RANGE(6, g_test_5, PARAM_ATTR_WR), + PARAM_ITEM_DAT_RANGE(7, g_test_6, PARAM_ATTR_WR), + PARAM_ITEM_DAT_RANGE(8, g_test_7, PARAM_ATTR_WR), +}; + + +static ParamManager_t sg_tParamManager; + +static void ShowSingleParam(const ParamInfo_t *paramInfo); + +// 数据校验出错时恢复默认处理 +int OnCheckErrorResetHandle(const ParamInfo_t *pParamInfo) +{ + printf("\n--------error list start ----------\n"); + printf("%4s %-15s %-8s %-8s %-8s %-10s %-10s %-10s %-10s\n", "id", "name", "type", "length", "attr", "val", "def", "min", "max"); + ShowSingleParam(pParamInfo); + printf("--------error list end ------------\n"); + Param_ResetDefaultValue(pParamInfo); + return 0; +} + +void InitParam(bool isReset) +{ + Param_Init(&sg_tParamManager, sg_ParamTable, PARAM_TABLE_SIZE(sg_ParamTable)); + + if (sg_length == 0) // 储存设备中没有储存过参数则首次进行储存 + { + printf("frist save param\n"); + Param_Save(&sg_tParamManager, OnSaveCallback, NULL); // 初次储存可以认为数据都是默认值,无需数据校验出错时恢复默认处理 + } + + ReloadParam(isReset); +} + +void ReloadParam(bool isReset) +{ + printf("load param\n"); + + if (isReset) + { + Param_Load(&sg_tParamManager, OnLoadCallback, OnCheckErrorResetHandle); + } + else + { + Param_Load(&sg_tParamManager, OnLoadCallback, NULL); + } +} + +void ResetParam(void) +{ + printf("reset param\n"); + Param_ResetParam(&sg_tParamManager); +} + +void SaveParam(bool isReset) +{ + printf("save param\n"); + if (isReset) + { + Param_Save(&sg_tParamManager, OnSaveCallback, OnCheckErrorResetHandle); + } + else + { + Param_Save(&sg_tParamManager, OnSaveCallback, NULL); + } +} + +#define ATTR(x) ((x & (PARAM_ATTR_READ | PARAM_ATTR_WRITE)) == (PARAM_ATTR_READ | PARAM_ATTR_WRITE) ? \ + "wr" : (x & (PARAM_ATTR_READ) ? "r" : ((x & (PARAM_ATTR_WRITE) ? "w" : "")))) + +char *Attr(uint8_t attr) +{ + static char buf[10]; + char *p = buf; + + if (attr & PARAM_ATTR_READ) + { + p += sprintf(p, "r"); + } + + if (attr & PARAM_ATTR_WRITE) + { + p += sprintf(p, "w"); + } + + if (attr & PARAM_ATTR_RESET) + { + p += sprintf(p, "s"); + } + + if (attr & PARAM_ATTR_RANGE) + { + p += sprintf(p, "m"); + } + + return buf; +} + +void ShowSingleParam(const ParamInfo_t *paramInfo) +{ + if (paramInfo != NULL) + { + switch (paramInfo->type) + { + case PARAM_INT8: + printf(" %-4d %-15s %-10s %-6d %-8s %-10d ", paramInfo->id, paramInfo->pszName, + "int8_t", paramInfo->length, Attr(paramInfo->attr), *paramInfo->unCurValuePtr.pInt8); + + if (paramInfo->attr & PARAM_ATTR_RESET) + printf("%-10d ", *paramInfo->unDefValuePtr.pInt8); + else + printf("%-10s ", "-"); + + if (paramInfo->attr & PARAM_ATTR_RANGE) + { + printf("%-10d ", *paramInfo->unMinValuePtr.pInt8); + printf("%-10d ", *paramInfo->unMaxValuePtr.pInt8); + } + else + { + printf("%-10s ", "-"); + printf("%-10s ", "-"); + } + break; + case PARAM_INT16: + printf(" %-4d %-15s %-10s %-6d %-8s %-10d ", paramInfo->id, paramInfo->pszName, + "int16_t", paramInfo->length, Attr(paramInfo->attr), *paramInfo->unCurValuePtr.pInt16); + + if (paramInfo->attr & PARAM_ATTR_RESET) + printf("%-10d ", *paramInfo->unDefValuePtr.pInt16); + else + printf("%-10s ", "-"); + + if (paramInfo->attr & PARAM_ATTR_RANGE) + { + printf("%-10d ", *paramInfo->unMinValuePtr.pInt16); + printf("%-10d ", *paramInfo->unMaxValuePtr.pInt16); + } + else + { + printf("%-10s ", "-"); + printf("%-10s ", "-"); + } + break; + case PARAM_INT32: + printf(" %-4d %-15s %-10s %-6d %-8s %-10d ", paramInfo->id, paramInfo->pszName, + "int32_t", paramInfo->length, Attr(paramInfo->attr), *paramInfo->unCurValuePtr.pInt32); + + if (paramInfo->attr & PARAM_ATTR_RESET) + printf("%-10d ", *paramInfo->unDefValuePtr.pInt32); + else + printf("%-10s ", "-"); + + if (paramInfo->attr & PARAM_ATTR_RANGE) + { + printf("%-10d ", *paramInfo->unMinValuePtr.pInt32); + printf("%-10d ", *paramInfo->unMaxValuePtr.pInt32); + } + else + { + printf("%-10s ", "-"); + printf("%-10s ", "-"); + } + break; + case PARAM_INT64: + printf(" %-4d %-15s %-10s %-6d %-8s %-10d ", paramInfo->id, paramInfo->pszName, + "int64_t", paramInfo->length, Attr(paramInfo->attr), *paramInfo->unCurValuePtr.pInt64); + + if (paramInfo->attr & PARAM_ATTR_RESET) + printf("%-10d ", *paramInfo->unDefValuePtr.pInt64); + else + printf("%-10s ", "-"); + + if (paramInfo->attr & PARAM_ATTR_RANGE) + { + printf("%-10d ", *paramInfo->unMinValuePtr.pInt64); + printf("%-10d ", *paramInfo->unMaxValuePtr.pInt64); + } + else + { + printf("%-10s ", "-"); + printf("%-10s ", "-"); + } + break; + case PARAM_UINT8: + printf(" %-4d %-15s %-10s %-6d %-8s %-10u ", paramInfo->id, paramInfo->pszName, + "uint8_t", paramInfo->length, Attr(paramInfo->attr), *paramInfo->unCurValuePtr.pUint8); + + if (paramInfo->attr & PARAM_ATTR_RESET) + printf("%-10u ", *paramInfo->unDefValuePtr.pUint8); + else + printf("%-10s ", "-"); + + if (paramInfo->attr & PARAM_ATTR_RANGE) + { + printf("%-10u ", *paramInfo->unMinValuePtr.pUint8); + printf("%-10u ", *paramInfo->unMaxValuePtr.pUint8); + } + else + { + printf("%-10s ", "-"); + printf("%-10s ", "-"); + } + break; + case PARAM_UINT16: + printf(" %-4d %-15s %-10s %-6d %-8s %-10u ", paramInfo->id, paramInfo->pszName, + "uint16_t", paramInfo->length, Attr(paramInfo->attr), *paramInfo->unCurValuePtr.pUint16); + + if (paramInfo->attr & PARAM_ATTR_RESET) + printf("%-10u ", *paramInfo->unDefValuePtr.pUint16); + else + printf("%-10s ", "-"); + + if (paramInfo->attr & PARAM_ATTR_RANGE) + { + printf("%-10u ", *paramInfo->unMinValuePtr.pUint16); + printf("%-10u ", *paramInfo->unMaxValuePtr.pUint16); + } + else + { + printf("%-10s ", "-"); + printf("%-10s ", "-"); + } + break; + case PARAM_UINT32: + printf(" %-4d %-15s %-10s %-6d %-8s %-10u ", paramInfo->id, paramInfo->pszName, + "uint32_t", paramInfo->length, Attr(paramInfo->attr), *paramInfo->unCurValuePtr.pUint32); + + if (paramInfo->attr & PARAM_ATTR_RESET) + printf("%-10u ", *paramInfo->unDefValuePtr.pUint32); + else + printf("%-10s ", "-"); + + if (paramInfo->attr & PARAM_ATTR_RANGE) + { + printf("%-10u ", *paramInfo->unMinValuePtr.pUint32); + printf("%-10u ", *paramInfo->unMaxValuePtr.pUint32); + } + else + { + printf("%-10s ", "-"); + printf("%-10s ", "-"); + } + break; + case PARAM_UINT64: + printf(" %-4d %-15s %-10s %-6d %-8s %-10u ", paramInfo->id, paramInfo->pszName, + "uint64_t", paramInfo->length, Attr(paramInfo->attr), *paramInfo->unCurValuePtr.pUint64); + + if (paramInfo->attr & PARAM_ATTR_RESET) + printf("%-10u ", *paramInfo->unDefValuePtr.pUint64); + else + printf("%-10s ", "-"); + + if (paramInfo->attr & PARAM_ATTR_RANGE) + { + printf("%-10u ", *paramInfo->unMinValuePtr.pUint64); + printf("%-10u ", *paramInfo->unMaxValuePtr.pUint64); + } + else + { + printf("%-10s ", "-"); + printf("%-10s ", "-"); + } + break; + case PARAM_FLOAT: + printf(" %-4d %-15s %-10s %-6d %-8s %-10f ", paramInfo->id, paramInfo->pszName, + "float", paramInfo->length, Attr(paramInfo->attr), *paramInfo->unCurValuePtr.pFloat); + + if (paramInfo->attr & PARAM_ATTR_RESET) + printf("%-10f ", *paramInfo->unDefValuePtr.pFloat); + else + printf("%-10s ", "-"); + + if (paramInfo->attr & PARAM_ATTR_RANGE) + { + printf("%-10f ", *paramInfo->unMinValuePtr.pFloat); + printf("%-10f ", *paramInfo->unMaxValuePtr.pFloat); + } + else + { + printf("%-10s ", "-"); + printf("%-10s ", "-"); + } + break; + case PARAM_DOUBLE: + printf(" %-4d %-15s %-10s %-6d %-8s %-10f ", paramInfo->id, paramInfo->pszName, + "double", paramInfo->length, Attr(paramInfo->attr), *paramInfo->unCurValuePtr.pDouble); + + if (paramInfo->attr & PARAM_ATTR_RESET) + printf("%-10f ", *paramInfo->unDefValuePtr.pDouble); + else + printf("%-10s ", "-"); + + if (paramInfo->attr & PARAM_ATTR_RANGE) + { + printf("%-10f ", *paramInfo->unMinValuePtr.pDouble); + printf("%-10f ", *paramInfo->unMaxValuePtr.pDouble); + } + else + { + printf("%-10s ", "-"); + printf("%-10s ", "-"); + } + break; + case PARAM_STRING: + printf(" %-4d %-15s %-10s %-6d %-8s %-10s ", paramInfo->id, paramInfo->pszName, + "string", paramInfo->length, Attr(paramInfo->attr), paramInfo->unCurValuePtr.pString); + + if (paramInfo->attr & PARAM_ATTR_RESET) + printf("%-10s ", paramInfo->unDefValuePtr.pString); + else + printf("%-10s ", "-"); + + if (paramInfo->attr & PARAM_ATTR_RANGE) + { + printf("%-10u ", *paramInfo->unMinValuePtr.pStringLength); + printf("%-10u ", *paramInfo->unMaxValuePtr.pStringLength); + } + else + { + printf("%-10s ", "-"); + printf("%-10s ", "-"); + } + break; + + default: + break; + } + + printf("\n"); + + } +} + +void ShowAllParam(void) +{ + size_t idx = 0; + ParamInfo_t *paramInfo; + + printf("%4s %-15s %-8s %-8s %-8s %-10s %-10s %-10s %-10s\n", "id", "name", "type", "length", "attr", "val", "def", "min", "max"); + + do + { + paramInfo = Param_IterateList(&sg_tParamManager, &idx); + + ShowSingleParam(paramInfo); + } while (paramInfo != NULL); +} diff --git a/Demo/cmd_shell/param_demo.h b/Demo/cmd_shell/param_demo.h new file mode 100644 index 0000000000000000000000000000000000000000..a110a1e845466570de836ccb68cb11ffdb366fbd --- /dev/null +++ b/Demo/cmd_shell/param_demo.h @@ -0,0 +1,29 @@ +#ifndef _PARAM_DEMO_H_ +#define _PARAM_DEMO_H_ + +#include "param.h" + +PARAM_EXTERN_DAT(g_test, PARAM_INT16); +PARAM_EXTERN_DAT(g_test_2, PARAM_UINT16); +PARAM_EXTERN_DAT(g_test_3, PARAM_DOUBLE); +PARAM_EXTERN_STR(g_test_str, 10); +PARAM_EXTERN_DAT(g_test_4, PARAM_INT8); +PARAM_EXTERN_DAT(g_test_5, PARAM_UINT32); +PARAM_EXTERN_DAT(g_test_6, PARAM_UINT8); +PARAM_EXTERN_DAT(g_test_7, PARAM_INT64); + + +#define PARAM_UPDATE(name, val, ret) {\ + param_##name##_t t = val;\ + SetParamNewValue(&name, &t);\ +} + +void InitParam(bool isReset); +void ReloadParam(bool isReset); + +void ResetParam(void); +void SaveParam(bool isReset); + +extern const bool SetParamNewValue(const void *curParamPtr, const void *newValue); +void ShowAllParam(void); +#endif diff --git a/Param/inc/param.h b/Param/inc/param.h index 4aee52fdbe35f6dc5949b081c387a9b4536c7660..053d001c0f3d2e229f9099137c65d880bed3aa62 100644 --- a/Param/inc/param.h +++ b/Param/inc/param.h @@ -3,8 +3,8 @@ * @file param.h * @brief 该文件提供参数管理框架所有函数原型 * @author const_zpc any question please send mail to const_zpc@163.com - * @version V0.1 - * @date 2023-02-07 + * @version V1.0 + * @date 2023-06-09 ********************************************************************************************************************** * ********************************************************************************************************************** @@ -22,52 +22,240 @@ extern "C" { #endif - /** * @brief 定义普通参数 * * @param name 参数名(变量名) * @param type 参数类型 @enum ParamType_e 取值 - * @param defVal 默认值 + * @param initVal 初始值 + */ +#define PARAM_DEFINE_DAT(name, type, initVal) \ + enum {PARAM_TYPE_##name = type};\ + enum {PARAM_INIT_ATTR_##name = 0};\ + type##_T name = initVal; + +/** + * @brief 定义普通参数, 具有默认值 + * + * @param name 参数名(变量名) + * @param type 参数类型 @enum ParamType_e 取值 + * @param defVal 默认值/初始值 + */ +#define PARAM_DEFINE_DAT_DEF(name, type, defVal) \ + enum {PARAM_TYPE_##name = type};\ + enum {PARAM_INIT_ATTR_##name = (PARAM_ATTR_RESET)};\ + type##_T name = defVal;\ + const type##_T def_##name = defVal; + +/** + * @brief 定义普通参数, 具有默认值和范围校验 + * + * @param name 参数名(变量名) + * @param type 参数类型 @enum ParamType_e 取值 + * @param defVal 默认值/初始值 * @param minVal 最小值 * @param maxVal 最大值 */ -#define PARAM_DEFINE_DAT(name, type, defVal, minVal, maxVal) \ - enum {TYPE_##name = type};\ +#define PARAM_DEFINE_DAT_RANGE(name, type, defVal, minVal, maxVal) \ + enum {PARAM_TYPE_##name = type};\ + enum {PARAM_INIT_ATTR_##name = (PARAM_ATTR_RANGE | PARAM_ATTR_RESET)};\ type##_T name = defVal;\ const type##_T def_##name = defVal;\ const type##_T min_##name = minVal;\ const type##_T max_##name = maxVal; +#if PARAM_USE_STRING_TYPE /** * @brief 定义字符串参数 * * @param name 参数名(变量名) - * @param length 字符串预留最大长度 - * @param defVal 默认值 + * @param length 字符串预留最大长度(包括结束符'\0') + * @param initVal 初始值 */ #define PARAM_DEFINE_STR(name, length, defVal) \ + enum {PARAM_INIT_ATTR_##name = 0};\ + char name[length] = {defVal};\ + +/** + * @brief 定义字符串参数 + * + * @param name 参数名(变量名) + * @param length 字符串预留最大长度(包括结束符'\0') + * @param defVal 默认值 + */ +#define PARAM_DEFINE_STR_DEF(name, length, defVal) \ + enum {PARAM_INIT_ATTR_##name = (PARAM_ATTR_RESET)};\ char name[length] = {defVal};\ const char def_##name[] = {defVal}; /** - * @brief 普通参数注册 + * @brief 定义字符串参数, 具有默认值和长度校验 * - * @param id 参数唯一 ID * @param name 参数名(变量名) - * @param attr 参数属性 + * @param length 字符串预留最大长度(包括结束符'\0') + * @param defVal 默认值 + * @param minLength 最小长度 + */ +#define PARAM_DEFINE_STR_RANGE(name, length, defVal, minLength) \ + enum {PARAM_INIT_ATTR_##name = (PARAM_ATTR_RANGE | PARAM_ATTR_RESET)};\ + char name[length] = {defVal};\ + const char def_##name[] = {defVal};\ + const param_size_t min_##name = minLength;\ + const param_size_t max_##name = length - 1; +#endif + +#if (PARAM_NAME_MAX_LENGTH > 1) +/** + * @brief 普通参数注册 + * + * @param _id 参数唯一 ID + * @param _name 参数名(变量名) + * @param _attr 参数读/写属性组合(PARAM_ATTR_READ/PARAM_ATTR_WRITE) */ -#define PARAM_ITEM_DAT(id, name, attr) { #name, id, TYPE_##name, sizeof(name), attr, &name, \ - (void *)&def_##name, (void *)&min_##name, (void *)&max_##name } +#define PARAM_ITEM_DAT(_id, _name, _attr) { .pszName = #_name, \ + .id = _id, \ + .type = PARAM_TYPE_##_name, \ + .length = sizeof(_name), \ + .attr = (_attr | PARAM_INIT_ATTR_##_name), \ + .unCurValuePtr.pVoid = &_name, \ + .unDefValuePtr.pVoid = NULL, \ + .unMinValuePtr.pVoid = NULL, \ + .unMaxValuePtr.pVoid = NULL} +#define PARAM_ITEM_DAT_DEF(_id, _name, _attr) { .pszName = #_name, \ + .id = _id, \ + .type = PARAM_TYPE_##_name, \ + .length = sizeof(_name), \ + .attr = (_attr | PARAM_INIT_ATTR_##_name), \ + .unCurValuePtr.pVoid = &_name, \ + .unDefValuePtr.pVoid = (void *)&def_##_name, \ + .unMinValuePtr.pVoid = NULL, \ + .unMaxValuePtr.pVoid = NULL} + +#define PARAM_ITEM_DAT_RANGE(_id, _name, _attr) { .pszName = #_name, \ + .id = _id, \ + .type = PARAM_TYPE_##_name, \ + .length = sizeof(_name), \ + .attr = (_attr | PARAM_INIT_ATTR_##_name), \ + .unCurValuePtr.pVoid = &_name, \ + .unDefValuePtr.pVoid = (void *)&def_##_name, \ + .unMinValuePtr.pVoid = (void *)&min_##_name, \ + .unMaxValuePtr.pVoid = (void *)&max_##_name} +#if PARAM_USE_STRING_TYPE /** * @brief 字符串参数注册 * - * @param id 参数唯一 ID - * @param name 参数名(变量名) + * @param _id 参数唯一 ID + * @param _name 参数名(变量名) + * @param _attr 参数读/写属性组合(PARAM_ATTR_READ/PARAM_ATTR_WRITE) */ -#define PARAM_ITEM_STR(id, name, attr) { #name, id, PARAM_STARING, sizeof(name), attr, name, \ - (void *)def_##name, NULL, NULL } +#define PARAM_ITEM_STR(_id, _name, _attr) { .pszName = #_name, \ + .id = _id, \ + .type = PARAM_STRING, \ + .length = sizeof(_name), \ + .attr = (_attr | PARAM_INIT_ATTR_##_name), \ + .unCurValuePtr.pVoid = &_name, \ + .unDefValuePtr.pVoid = NULL, \ + .unMinValuePtr.pVoid = NULL, \ + .unMaxValuePtr.pVoid = NULL} + +#define PARAM_ITEM_STR_DEF(_id, _name, _attr) { .pszName = #_name, \ + .id = _id, \ + .type = PARAM_STRING, \ + .length = sizeof(_name), \ + .attr = (_attr | PARAM_INIT_ATTR_##_name), \ + .unCurValuePtr.pVoid = &_name, \ + .unDefValuePtr.pVoid = (void *)&def_##_name, \ + .unMinValuePtr.pVoid = NULL, \ + .unMaxValuePtr.pVoid = NULL} + +#define PARAM_ITEM_STR_RANGE(_id, _name, _attr) { .pszName = #_name, \ + .id = _id, \ + .type = PARAM_STRING, \ + .length = sizeof(_name), \ + .attr = (_attr | PARAM_INIT_ATTR_##_name), \ + .unCurValuePtr.pVoid = &_name, \ + .unDefValuePtr.pVoid = (void *)&def_##_name, \ + .unMinValuePtr.pVoid = (void *)&min_##_name, \ + .unMaxValuePtr.pVoid = (void *)&max_##_name} +#endif +#else + +/** + * @brief 普通参数注册 + * + * @param _id 参数唯一 ID + * @param _name 参数名(变量名) + * @param _attr 参数读/写属性组合(PARAM_ATTR_READ/PARAM_ATTR_WRITE) + */ +#define PARAM_ITEM_DAT(_id, _name, _attr) {\ + .id = _id, \ + .type = PARAM_TYPE_##_name, \ + .length = sizeof(_name), \ + .attr = (_attr | PARAM_INIT_ATTR_##_name), \ + .unCurValuePtr.pVoid = &_name, \ + .unDefValuePtr.pVoid = NULL, \ + .unMinValuePtr.pVoid = NULL, \ + .unMaxValuePtr.pVoid = NULL} + +#define PARAM_ITEM_DAT_DEF(_id, _name, _attr) {\ + .id = _id, \ + .type = PARAM_TYPE_##_name, \ + .length = sizeof(_name), \ + .attr = (_attr | PARAM_INIT_ATTR_##_name), \ + .unCurValuePtr.pVoid = &_name, \ + .unDefValuePtr.pVoid = (void *)&def_##_name, \ + .unMinValuePtr.pVoid = NULL, \ + .unMaxValuePtr.pVoid = NULL} + +#define PARAM_ITEM_DAT_RANGE(_id, _name, _attr) {\ + .id = _id, \ + .type = PARAM_TYPE_##_name, \ + .length = sizeof(_name), \ + .attr = (_attr | PARAM_INIT_ATTR_##_name), \ + .unCurValuePtr.pVoid = &_name, \ + .unDefValuePtr.pVoid = (void *)&def_##_name, \ + .unMinValuePtr.pVoid = (void *)&min_##_name, \ + .unMaxValuePtr.pVoid = (void *)&max_##_name} +#if PARAM_USE_STRING_TYPE +/** + * @brief 字符串参数注册 + * + * @param _id 参数唯一 ID + * @param _name 参数名(变量名) + * @param _attr 参数读/写属性组合(PARAM_ATTR_READ/PARAM_ATTR_WRITE) + */ +#define PARAM_ITEM_STR(_id, _name, _attr) {\ + .id = _id, \ + .type = PARAM_STRING, \ + .length = sizeof(_name), \ + .attr = (_attr | PARAM_INIT_ATTR_##_name), \ + .pCurValue = &_name, \ + .unDefValuePtr.pVoid = NULL, \ + .unMinValuePtr.pVoid = NULL, \ + .unMaxValuePtr.pVoid = NULL} + +#define PARAM_ITEM_STR_DEF(_id, _name, _attr) {\ + .id = _id, \ + .type = PARAM_STRING, \ + .length = sizeof(_name), \ + .attr = (_attr | PARAM_INIT_ATTR_##_name), \ + .pCurValue = &_name, \ + .unDefValuePtr.pVoid = (void *)&def_##_name, \ + .unMinValuePtr.pVoid = NULL, \ + .unMaxValuePtr.pVoid = NULL} + +#define PARAM_ITEM_STR_RANGE(_id, _name, _attr) {\ + .id = _id, \ + .type = PARAM_STRING, \ + .length = sizeof(_name), \ + .attr = (_attr | PARAM_INIT_ATTR_##_name), \ + .pCurValue = &_name, \ + .unDefValuePtr.pVoid = (void *)&def_##_name, \ + .unMinValuePtr.pVoid = (void *)&min_##_name, \ + .unMaxValuePtr.pVoid = (void *)&max_##_name} +#endif +#endif /** * @brief 参数声明 @@ -75,7 +263,12 @@ * @param name 参数名(变量名) * @param type 参数类型 @enum ParamType_e 取值 */ -#define PARAM_EXTERN_DAT(name, type) extern type##_T name; +#define PARAM_EXTERN_DAT(name, type) \ + typedef type##_T param_##name##_t;\ + extern type##_T name;\ + const extern type##_T def_##name;\ + const extern type##_T min_##name;\ + const extern type##_T max_##name; /** * @brief 字符串参数声明 @@ -83,15 +276,125 @@ * @param name 参数名(变量名) * @param length 字符串预留最大长度 */ -#define PARAM_EXTERN_STR(name, length) extern char name[length]; +#define PARAM_EXTERN_STR(name, length) \ + typedef char* param_##name##_t;\ + extern char name[length];\ + const extern char def_##name[];\ + const extern param_size_t min_##name;\ + const extern param_size_t max_##name; + +// 根据参数名获取该参数的类型定义 +#define PARAM_DECLTYPE(name) param_##name##_t + +#define PARAM_DAT_CUR_VALUE(name) name +#define PARAM_DAT_DEF_VALUE(name) def_##name +#define PARAM_DAT_MIN_VALUE(name) min_##name +#define PARAM_DAT_MAX_VALUE(name) max_##name + +#define PARAM_STR_CUR_VALUE(name) name +#define PARAM_STR_DEF_VALUE(name) def_##name +#define PARAM_STR_MIN_LENGTH(name) min_##name +#define PARAM_STR_MAX_LENGTH(name) max_##name + + +#define PARAM_NONE 0 +#define PARAM_DEF 1 +#define PARAM_MIN_MAX 2 + + +#define _PARAM_DAT_PARAM_NONE(name, def, min_or_max) (0) +#define _PARAM_DAT_PARAM_DEF(name, def, min_or_max) (name = def##_##name) +#define _PARAM_DAT_PARAM_MIN_MAX(name, def, min_or_max) (name = min_or_max##_##name) +#define _PARAM_STR_PARAM_NONE(name, def, min_or_max) (0) +#define _PARAM_STR_PARAM_DEF(name, def, min_or_max) (strcpy(name, def##_##name)) +#define _PARAM_STR_PARAM_MIN_MAX(name, def, min_or_max) (0) + +/** + * @brief 使用 PARAM_DEFINE_DAT_RANGE 定义的数值类型参数可以通过该宏进行最新值的范围校验 + * + * @attention 使用该宏请确保在头文件已经使用宏 PARAM_EXTERN_DAT 声明 + * @param name 参数名 + * @param opt 超出范围的处理选项: + * @arg PARAM_NONE, 参数不变, 即不做处理 + * @arg PARAM_DEF, 参数恢复默认 + * @arg PARAM_MIN_MAX, 参数小于最小值则为最小值, 参数大于最大值则为最大值; 但对字符串类型参数该选项无效, 即不做处理 + * @return 0,正常; 1,参数小于最小值; 2,参数大于最大值 + */ +#define PARAM_DAT_CHECK_RANGE(name, opt) \ + (PARAM_DAT_CUR_VALUE(name) < PARAM_DAT_MIN_VALUE(name) ? (_PARAM_DAT_##opt(name, def, min), 1) : \ + PARAM_DAT_CUR_VALUE(name) > PARAM_DAT_MAX_VALUE(name) ? (_PARAM_DAT_##opt(name, def, max), 2) : 0) + +/** + * @brief 使用 PARAM_DEFINE_STR_RANGE 定义的字符串类型参数可以通过该宏进行长度的校验 + * + * @attention 使用该宏请确保在头文件已经使用宏 PARAM_EXTERN_STR 声明 + * @param name 参数名 + * @param opt 超出范围的处理选项: + * @arg PARAM_NONE, 参数不变, 即不做处理 + * @arg PARAM_DEF, 参数恢复默认 + * @arg PARAM_MIN_MAX, 参数小于最小值则为最小值, 参数大于最大值则为最大值; 但对字符串类型参数该选项无效, 即不做处理 + * @return 0,正常; 1,字符串长度小于最小限制长度; 2,字符串长度大于最大限制长度 + */ +#define PARAM_STR_CHECK_RANGE(name, opt) \ + (strlen(PARAM_STR_CUR_VALUE(name)) < PARAM_STR_MIN_LENGTH(name) ? (_PARAM_STR_##opt(name, def, min), 1) : \ + strlen(PARAM_STR_CUR_VALUE(name)) > PARAM_STR_MAX_LENGTH(name) ? (_PARAM_STR_##opt(name, def, max), 2) : 0) + +/** + * @brief 使用 PARAM_DEFINE_DAT_RANGE 定义的参数可以通过该宏修改 + * + * @attention 使用该宏请确保在头文件已经使用宏 PARAM_EXTERN_DAT 声明 + * @param name 参数名 + * @param val 参数新的值 + * @param opt 超出范围的处理选项: + * @arg PARAM_NONE, 参数不变, 即不做处理 + * @arg PARAM_DEF, 参数恢复默认 + * @arg PARAM_MIN_MAX, 参数小于最小值则为最小值, 参数大于最大值则为最大值 + * @return 0,正常; 1,参数小于最小值; 2,参数大于最大值 + */ +#define PARAM_DAT_SET_NEW_VALUE(name, val, opt) \ + (val < PARAM_DAT_MIN_VALUE(name) ? (_PARAM_DAT_##opt(name, def, min), 1) : \ + val > PARAM_DAT_MAX_VALUE(name) ? (_PARAM_DAT_##opt(name, def, max), 2) : \ + (PARAM_DAT_CUR_VALUE(name) = val, 0)) + +/** + * @brief 使用 PARAM_DEFINE_STR_RANGE 定义的参数可以通过该宏修改 + * + * @attention 使用该宏请确保在头文件已经使用宏 PARAM_EXTERN_STR 声明 + * @param name 参数名 + * @param val 参数新的字符串 + * @param opt 超出范围的处理选项: + * @arg PARAM_NONE, 参数不变, 即不做处理 + * @arg PARAM_DEF, 参数恢复默认 + * @arg PARAM_MIN_MAX, 该选项无效, 参数不变, 即不做处理 + * @return 0,正常; 1,字符串长度小于最小限制长度; 2,字符串长度大于最大限制长度 + */ +#define PARAM_STR_SET_NEW_VALUE(name, str, opt) \ + (strlen(str) < PARAM_STR_MIN_LENGTH(name) ? (_PARAM_STR_##opt(name, def, min), 1) : \ + strlen(str) > PARAM_STR_MAX_LENGTH(name) ? (_PARAM_STR_##opt(name, def, max), 2) : \ + (strcpy(PARAM_STR_CUR_VALUE(name), str), 0)) + +// 得到参数表的元素数目 +#define PARAM_TABLE_SIZE(tab) (sizeof(tab) / sizeof(ParamInfo_t)) + + +extern int Param_Init(ParamManager_t* manager, ParamInfo_t* pParamTable, uint16_t count); +extern int Param_ResetParam(const ParamManager_t *manager); + +extern int Param_Load(ParamManager_t* manager, pfnLoad_cb pfnLoadCallback, pfnCheckError_cb pfnCheckError); +extern int Param_Save(ParamManager_t* manager, pfnSave_cb pfnSaveCallback, pfnCheckError_cb pfnCheckError); +extern ParamInfo_t *Param_IterateList(ParamManager_t *manager, size_t *psIdx); -extern size_t Param_MultiSerialize(uint8_t *pBuf, const ParamInfo_t *paramTable, uint16_t num, uint8_t opt); -extern uint16_t Param_MultiParse(uint8_t *pBuf, size_t length, ParamInfo_t *paramTable, uint16_t num); +extern const ParamInfo_t *Param_FindParamByName(ParamManager_t *manager, const char *pszName); +extern const ParamInfo_t *Param_FindParamByID(ParamManager_t* manager, uint16_t id); +extern const ParamInfo_t *Param_FindParamByParamPtr(ParamManager_t* manager, const void *curParamPtr); +extern int Param_CheckRange(const ParamInfo_t *param, uint8_t opt); -extern size_t Param_Serialize(uint8_t *pBuf, const ParamInfo_t *paramTable, uint16_t num, uint8_t isAddKey, uint8_t isUseEncoded); -extern uint16_t Param_Parse(uint8_t *pBuf, size_t length, ParamInfo_t *paramTable, uint16_t num, uint8_t isAddKey, uint8_t isUseEncoded); +extern int Param_SetNewValue(const ParamInfo_t *param, const void *value, uint8_t opt); +extern bool Param_ResetDefaultValue(const ParamInfo_t *param); +extern bool Param_ResetMinValue(const ParamInfo_t *param); +extern bool Param_ResetMaxValue(const ParamInfo_t *param); #ifdef __cplusplus } diff --git a/Param/inc/param_cfg.h b/Param/inc/param_cfg.h index 8e11ff407ad34db5ef63af63101afcd386432ccf..a0a1a3047de3fa21451918baab0ee32294b6e507 100644 --- a/Param/inc/param_cfg.h +++ b/Param/inc/param_cfg.h @@ -16,15 +16,57 @@ /* Includes ----------------------------------------------------------------------------------------------------------*/ -/** 反序列化完整信息的解析单次得到最大参数表元素数目设置 */ -#define PARAM_PARSE_MAX_NUM 10 +/** 参数保存时是否采用键值对方式保存 + * 1,采用键值对, 该方式在参数表更改时可以向下兼容 + * 0,禁止, 该方式在参数表更改时可以不一定兼容, 删除/添加表中参数时无法兼容, 即使不使用也不能删除, 只有在参数表末尾不断添加才能保证向下兼容 + * */ +#define PARAM_USE_KEY_VALUE 1 +/** + * @brief 使用字符串参数类型 + * 0,禁止; 1,使能 + */ +#define PARAM_USE_STRING_TYPE 1 + +/** + * @brief 使用64位的参数类型 + * 0,禁止; 1,使能 + */ +#define PARAM_USE_64_BIT_LENGTH 1 + +/** 参数名字最大定义长度(包括结束符'\0'), 因此小于或等于1则禁用参数名字字符串相关功能 */ +#define PARAM_NAME_MAX_LENGTH 15 -/** 字符串参数长度需要使用的字节(1:最长可定义254长度的字符串参数, 2:最长可定义63335长度的字符串参数) */ -#define PARAM_STRING_SIZE 1 +#if PARAM_USE_STRING_TYPE +/** 字符串类型的参数取值最大定义长度(包括结束符) */ +#define PARAM_STRING_MAX_LENGTH 15 +#endif + +#if PARAM_USE_KEY_VALUE + +/** 最多支持多少个参数 */ +#define PARAM_SUPPORT_NUM PARAM_SUPPORT_16 +#define PARAM_SUPPORT_16 1 +#define PARAM_SUPPORT_256 2 +#define PARAM_SUPPORT_4096 3 -/** 参数名字最大定义长度(包括结束符) */ -#define PARAM_NAME_MAX_LENGTH 32 +#endif + +#if PARAM_USE_KEY_VALUE + #if (PARAM_SUPPORT_NUM == PARAM_SUPPORT_16) + #if PARAM_STRING_MAX_LENGTH >= 16 + #error "Param: The maximum length of a string can not over 15" + #endif + #elif (PARAM_SUPPORT_NUM == PARAM_SUPPORT_256) + #if PARAM_STRING_MAX_LENGTH >= 256 + #error "Param: The maximum length of a string can not over 256" + #endif + #elif (PARAM_SUPPORT_NUM == PARAM_SUPPORT_4096) + #if PARAM_STRING_MAX_LENGTH >= 4096 + #error "Param: The maximum length of a string can not over 4096" + #endif + #endif +#endif #endif diff --git a/Param/inc/param_type.h b/Param/inc/param_type.h index 2843d434086f4f46779867933199f0f6539e2d23..f53e96363a2dfe08a67fa55fce53308e6cc16a81 100644 --- a/Param/inc/param_type.h +++ b/Param/inc/param_type.h @@ -16,28 +16,24 @@ #define _PARAM_TYPE_H_ /* Includes ----------------------------------------------------------------------------------------------------------*/ +#include "param_cfg.h" #include +#include #include #ifdef __cplusplus - extern "C" { -#endif +extern "C" { +#endif /** 参数权限属性 */ -#define PARAM_ATTR_ALL 0XFF // 所有权限 -#define PARAM_ATTR_READ 0X01 // 可读权限 -#define PARAM_ATTR_WRITE 0X02 // 可写权限 -#define PARAM_ATTR_RESET 0X04 // 可重置权限 - -/** 参数序列化选项 */ +#define PARAM_ATTR_WR (PARAM_ATTR_READ | PARAM_ATTR_WRITE) // 读写权限 +#define PARAM_ATTR_NONE 0X00 // 无读写权限(不使用键值对模式储存参数则用于删除参数的属性) +#define PARAM_ATTR_READ 0X01 // 可读权限属性 +#define PARAM_ATTR_WRITE 0X02 // 可写权限属性 +#define PARAM_ATTR_RESET 0X04 // 可重置权限属性 +#define PARAM_ATTR_RANGE 0X10 // 支持最大/最小值校验 -#define PARAM_PACK_ALL 0x7F // 所有信息都序列化 -#define PARAM_PACK_NAME 0x01 // 参数名字信息序列化 -#define PARAM_PACK_ATTR 0x02 // 参数属性信息序列化 -#define PARAM_PACK_DEF_VAL 0x04 // 参数默认值信息序列化 -#define PARAM_PACK_MIN_VAL 0x08 // 参数最小值信息序列化 -#define PARAM_PACK_MAX_VAL 0x10 // 参数最大值信息序列化 typedef int8_t PARAM_INT8_T; typedef int16_t PARAM_INT16_T; @@ -49,38 +45,94 @@ typedef uint32_t PARAM_UINT32_T; typedef uint64_t PARAM_UINT64_T; typedef float PARAM_FLOAT_T; typedef double PARAM_DOUBLE_T; -typedef char PARAM_STARING_T; +typedef char PARAM_STRING_T; + +#if PARAM_STRING_MAX_LENGTH >= 256 +typedef uint16_t param_size_t; +#else +typedef uint8_t param_size_t; +#endif typedef enum { PARAM_INT8 = 0, PARAM_INT16, PARAM_INT32, +#if PARAM_USE_64_BIT_LENGTH PARAM_INT64, +#endif PARAM_UINT8, PARAM_UINT16, PARAM_UINT32, +#if PARAM_USE_64_BIT_LENGTH PARAM_UINT64, +#endif PARAM_FLOAT, +#if PARAM_USE_64_BIT_LENGTH PARAM_DOUBLE, - PARAM_STARING, -}ParamType_e; +#endif +#if PARAM_USE_STRING_TYPE + PARAM_STRING, +#endif +} ParamType_e; -typedef struct +typedef union { + PARAM_INT8_T *pInt8; + PARAM_INT16_T *pInt16; + PARAM_INT32_T *pInt32; +#if PARAM_USE_64_BIT_LENGTH + PARAM_INT64_T *pInt64; +#endif + PARAM_UINT8_T *pUint8; + PARAM_UINT16_T *pUint16; + PARAM_UINT32_T *pUint32; +#if PARAM_USE_64_BIT_LENGTH + PARAM_UINT64_T *pUint64; +#endif + PARAM_FLOAT_T *pFloat; +#if PARAM_USE_64_BIT_LENGTH + PARAM_DOUBLE_T *pDouble; +#endif +#if PARAM_USE_STRING_TYPE + PARAM_STRING_T *pString; + param_size_t *pStringLength; +#endif + void *pVoid; +} ParamTypePtr_u; + +/** + * @brief 定义无内存的参数结构体信息 + * + */ +typedef struct stuParamInfo { - char *pszName; /*!< 名称 */ - uint16_t id; /*!< 唯一ID */ - uint8_t type; /*!< 类型, @enum ParamType_e */ - uint16_t length; /*!< 长度 */ - uint8_t attr; /*!< 属性 */ - void *pCurValue; /*!< 当前值指针 */ - void *pDefValue; /*!< 默认值指针 */ - void *pMinValue; /*!< 最小值指针 */ - void *pMaxValue; /*!< 最大值指针 */ +#if (PARAM_NAME_MAX_LENGTH > 1) + const char *pszName; /*!< 名称 */ +#endif + uint16_t id; /*!< 唯一ID */ + uint8_t type; /*!< 类型, @enum ParamType_e */ + uint16_t length; /*!< 长度(字节数) */ + uint8_t attr; /*!< 属性 */ + ParamTypePtr_u unCurValuePtr; /*!< 当前值指针 */ + const ParamTypePtr_u unDefValuePtr; /*!< 默认值指针 */ + const ParamTypePtr_u unMinValuePtr; /*!< 最小值指针(字符串参数限制最小长度时需要 param_size_t 定义) */ + const ParamTypePtr_u unMaxValuePtr; /*!< 最大值指针(字符串参数限制最大长度时需要 param_size_t 定义) */ } ParamInfo_t; +typedef int (*pfnCheckError_cb)(const ParamInfo_t *pParamInfo); +typedef int (*pfnLoad_cb)(uint8_t *pBuf, uint16_t *len, bool *pisFinish); +typedef int (*pfnSave_cb)(const uint8_t *pBuf, uint16_t len, bool isFinish); + +// 定义参数管理结构体 +typedef struct +{ + ParamInfo_t *pParamTable; /*!< 参数信息数组表 */ + uint16_t count; /*!< 参数信息数组元素个数 */ +} ParamManager_t; + + #ifdef __cplusplus - } +} #endif #endif diff --git a/Param/inc/stream.h b/Param/inc/stream.h deleted file mode 100644 index 0a088e2a8c8964f8e8f71c1b34ba94e9aa795495..0000000000000000000000000000000000000000 --- a/Param/inc/stream.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - ********************************************************************************************************************** - * @file param.h - * @brief 该文件提供参数序列化所有函数原型 - * @author const_zpc any question please send mail to const_zpc@163.com - * @version V0.1 - * @date 2023-02-07 - ********************************************************************************************************************** - * - ********************************************************************************************************************** - */ - -/* Define to prevent recursive inclusion -----------------------------------------------------------------------------*/ -#ifndef _PARAM_STREAM_H_ -#define _PARAM_STREAM_H_ - -/* Includes ----------------------------------------------------------------------------------------------------------*/ -#include "param_type.h" - -#ifdef __cplusplus - extern "C" { -#endif - - - -uint8_t *PackParam(uint8_t *pBuf, const ParamInfo_t *pParam, uint8_t isUseEncoded, uint8_t opt); -uint8_t *PackTagAndParam(uint8_t *pBuf, const ParamInfo_t *pParam, uint8_t isUseEncoded, uint8_t opt); -uint8_t *PackTagAndOptAndParam(uint8_t *pBuf, const ParamInfo_t *pParam, uint8_t isUseEncoded, uint8_t opt); - -uint8_t *UnPackParam(uint8_t *pBuf, ParamInfo_t *pParam, uint8_t isUseDecode, uint8_t opt); -uint8_t *UnPackTagAndParam(uint8_t *pBuf, ParamInfo_t *pParam, uint8_t isUseDecode, uint8_t opt); -uint8_t *UnPackTagAndOptAndParam(uint8_t *pBuf, ParamInfo_t *pParam); - -#ifdef __cplusplus - } -#endif - -#endif diff --git a/Param/src/param.c b/Param/src/param.c index d77979bc99008d87e34d6ac0c658e34810255bec..57de83cc3cd29ad01770e597e84b36e2259b70b8 100644 --- a/Param/src/param.c +++ b/Param/src/param.c @@ -3,8 +3,8 @@ * @file param.c * @brief 该文件提供参数管理框架功能 * @author const_zpc any question please send mail to const_zpc@163.com - * @version V0.1 - * @date 2023-02-07 + * @version V1.0 + * @date 2023-06-09 * * @details 功能详细说明: * + 参数修改和重置管理 @@ -19,149 +19,1061 @@ /* Includes ----------------------------------------------------------------------------------------------------------*/ #include "param.h" -#include "param_cfg.h" -#include "stream.h" #include +#include + + +typedef union +{ + uint64_t u64val; + int64_t s64val; + double fVal; +#if PARAM_USE_STRING_TYPE + char str[PARAM_STRING_MAX_LENGTH + 2]; +#endif +} Value_u; + +static uint8_t *SerializeUint(uint8_t *ptr, uint64_t value, uint8_t len) +{ + for (int i = 0; i < len; i++) + { + *ptr++ = value >> (i * 8); + } + + return ptr; +} + +static uint8_t *SerializeInt(uint8_t *ptr, int64_t value, uint8_t len) +{ + for (int i = 0; i < len; i++) + { + *ptr++ = value >> (i * 8); + } + + return ptr; +} + +static uint8_t *SerializeFloat(uint8_t *ptr, float value) +{ + uint32_t ivalue = *((uint32_t *)&value); + + for (int i = 0; i < sizeof(ivalue); i++) + { + *ptr++ = ivalue >> (i * 8); + } + + return ptr; +} + +static uint8_t *SerializeDouble(uint8_t *ptr, double value) +{ + uint64_t ivalue = *((uint64_t *)&value); + + for (int i = 0; i < sizeof(ivalue); i++) + { + *ptr++ = ivalue >> (i * 8); + } + + return ptr; +} + +static uint8_t *UnSerializeUint(const uint8_t *ptr, uint64_t *value, uint8_t len) +{ + *value = 0; + + for (int i = 0; i < len; i++) + { + *value |= (uint64_t)(*ptr++) << (i * 8); + } + + return (uint8_t *)ptr; +} + +static uint8_t *UnSerializeInt(const uint8_t *ptr, int64_t *value, uint8_t len) +{ + *value = 0; + + for (int i = 0; i < len; i++) + { + *value |= (int64_t)(*ptr++) << (i * 8); + } + + return (uint8_t *)ptr; +} + +static uint8_t *UnSerializeFloat(const uint8_t *ptr, float *value) +{ + uint32_t ivalue = 0; + + for (int i = 0; i < sizeof(ivalue); i++) + { + ivalue |= (uint32_t)(*ptr++) << (i * 8); + } + + *value = *((float *)&ivalue); + + return (uint8_t *)ptr; +} + +static uint8_t *UnSerializeDouble(const uint8_t *ptr, double *value) +{ + uint64_t ivalue = 0; + + for (int i = 0; i < sizeof(ivalue); i++) + { + ivalue |= (uint64_t)(*ptr++) << (i * 8); + } + + *value = *((double *)&ivalue); + + return (uint8_t *)ptr; +} + +static bool ResetParamValue(const ParamInfo_t *param) +{ + if (param != NULL && (param->attr & PARAM_ATTR_RESET)) + { +#if PARAM_USE_STRING_TYPE + if (param->type != PARAM_STRING) + { + memcpy(param->unCurValuePtr.pVoid, param->unDefValuePtr.pVoid, param->length); + } + else + { + strcpy(param->unCurValuePtr.pString, param->unDefValuePtr.pString); + } +#else + memcpy(param->unCurValuePtr.pVoid, param->unDefValuePtr.pVoid, param->length); +#endif + return true; + } + + return false; +} + +static bool ResetParamMinValue(const ParamInfo_t *param) +{ + if (param != NULL && (param->attr & PARAM_ATTR_RANGE)) + { +#if PARAM_USE_STRING_TYPE + if (param->type != PARAM_STRING) +#endif + { + memcpy(param->unCurValuePtr.pVoid, param->unMinValuePtr.pVoid, param->length); + } + + return true; + } + + return false; +} + +static bool ResetParamMaxValue(const ParamInfo_t *param) +{ + if (param != NULL && (param->attr & PARAM_ATTR_RANGE)) + { +#if PARAM_USE_STRING_TYPE + if (param->type != PARAM_STRING) +#endif + { + memcpy(param->unCurValuePtr.pVoid, param->unMaxValuePtr.pVoid, param->length); + } + + return true; + } + + return false; +} /** - * @brief 将参数编码序列化,具备完整的解析信息 - * - * @note 序列化后的数据可支持跨设备传输解析 - * @param[out] pBuf 序列化后的数据 - * @param[in] paramTable 需要进行序列化的参数表 - * @param[in] num 参数表元素数目 - * @param[in] opt 参数序列化选项 PARAM_PACK_NAME、PARAM_PACK_LENGTH 等, 可以将其他信息也进行序列化后传输解析 - * @return 序列化后的数据大小 + * @brief 参数表初始化 + * + * @param manager 参数表管理句柄 + * @param pParamTable 参数表 + * @param count 参数表元素数目, 可以通过宏 PARAM_TABLE_SIZE 获取 + * @return 0,成功; -1,失败 */ -size_t Param_MultiSerialize(uint8_t *pBuf, const ParamInfo_t *paramTable, uint16_t num, uint8_t opt) +int Param_Init(ParamManager_t *manager, ParamInfo_t *pParamTable, uint16_t count) { - uint8_t *pPtr = pBuf; + if (manager == NULL || pParamTable == NULL) + { + return -1; + } - for (int i = 0; i < num; i++) + for (uint16_t i = 0; i < count; i++) { - pPtr = PackTagAndOptAndParam(pPtr, ¶mTable[i], 1, opt); + if (pParamTable[i].unMaxValuePtr.pVoid == NULL || pParamTable[i].unMinValuePtr.pVoid == NULL) + { + pParamTable[i].attr &= ~PARAM_ATTR_RANGE; + } + + if (!(pParamTable[i].attr & PARAM_ATTR_READ)) + { + pParamTable[i].attr &= ~PARAM_ATTR_WRITE; + } + + if (pParamTable[i].unDefValuePtr.pVoid == NULL) + { + pParamTable[i].attr &= ~PARAM_ATTR_RESET; + } + + if (pParamTable[i].unCurValuePtr.pVoid == NULL) + { + return -1; + } } - return pPtr - pBuf; + manager->pParamTable = pParamTable; + manager->count = count; + return 0; } -#if PARAM_PARSE_MAX_NUM != 0 +/** + * @brief 重置所有参数,恢复为缺省值 + * + * @attention 无可重置权限的参数不能恢复为缺省值 + * @param manager 参数表管理句柄 + * @return 0,成功; -1,失败 + */ +int Param_ResetParam(const ParamManager_t *manager) +{ + if (manager == NULL) + { + return -1; + } + + for (uint16_t i = 0; i < manager->count; ++i) + { + ResetParamValue(&manager->pParamTable[i]); + } -static uint8_t sg_Buf[PARAM_PARSE_MAX_NUM * (PARAM_NAME_MAX_LENGTH + 32)]; + return 0; +} + +static ParamInfo_t *FindParamByParamPtr(ParamManager_t *manager, const void *curParamPtr) +{ + for (uint16_t i = 0; i < manager->count; ++i) + { + if (manager->pParamTable[i].unCurValuePtr.pVoid == curParamPtr) + { + return &manager->pParamTable[i]; + } + } + + return NULL; +} /** - * @brief 将数据反序列化得到参数表信息 + * @brief 参数列表迭代器 * - * @attention 必须是函数 Param_MultiSerialize 序列化后的数据 - * @param[in] pBuf 需要反序列化后的数据 - * @param[in] length 需要反序列化后的数据长度 - * @param[out] paramTable 反序列化得到参数表信息 - * @param[in] num 参数表元素最大数目, 最大限制 PARAM_PARSE_MAX_NUM - * @return 反序列化得到参数表元素数目 + * @attention 无读取权限的参数会自动跳过 + * @param manager 参数表管理句柄 + * @param psIdx 参数表起始索引 + * @return 参数信息 */ -uint16_t Param_MultiParse(uint8_t *pBuf, size_t length, ParamInfo_t *paramTable, uint16_t num) +ParamInfo_t *Param_IterateList(ParamManager_t *manager, size_t *psIdx) { - uint8_t *pPtr = pBuf; - uint16_t idx = 0; + ParamInfo_t *p = NULL; - num = num < PARAM_PARSE_MAX_NUM ? num : PARAM_PARSE_MAX_NUM; + if (manager == NULL || psIdx == NULL || *psIdx > manager->count) + { + return NULL; + } - memset(paramTable, 0, num * sizeof(ParamInfo_t)); + while (*psIdx < manager->count) + { + if (manager->pParamTable[*psIdx].attr & PARAM_ATTR_READ) + { + p = &manager->pParamTable[*psIdx]; + (*psIdx)++; + break; + } + + (*psIdx)++; + } + + return p; +} - while (pPtr - pBuf < length && idx < num) +#if (PARAM_NAME_MAX_LENGTH > 1) +static ParamInfo_t *FindParamByName(ParamManager_t *manager, const char *pszName) +{ + for (uint16_t i = 0; i < manager->count; ++i) { - paramTable[idx].pszName = &sg_Buf[idx * (PARAM_NAME_MAX_LENGTH + 32)]; - paramTable[idx].pCurValue = &sg_Buf[idx * (PARAM_NAME_MAX_LENGTH + 32) + PARAM_NAME_MAX_LENGTH]; - paramTable[idx].pDefValue = &sg_Buf[idx * (PARAM_NAME_MAX_LENGTH + 32) + PARAM_NAME_MAX_LENGTH + 8]; - paramTable[idx].pMinValue = &sg_Buf[idx * (PARAM_NAME_MAX_LENGTH + 32) + PARAM_NAME_MAX_LENGTH + 16]; - paramTable[idx].pMaxValue = &sg_Buf[idx * (PARAM_NAME_MAX_LENGTH + 32) + PARAM_NAME_MAX_LENGTH + 24]; - pPtr = UnPackTagAndOptAndParam(pPtr, ¶mTable[idx]); - idx++; + if (strcmp(manager->pParamTable[i].pszName, pszName) == 0) + { + return &manager->pParamTable[i]; + } } - return idx; + return NULL; } +#endif + +/** + * @brief 根据参数名称查找参数信息 + * + * @attention 无可读权限时会查找失败 + * @param manager 参数表管理句柄 + * @param pszName 参数名称 + * @return 参数信息 + */ +const ParamInfo_t *Param_FindParamByName(ParamManager_t *manager, const char *pszName) +{ +#if (PARAM_NAME_MAX_LENGTH > 1) + ParamInfo_t *pInfo; + + if (manager != NULL) + { + pInfo = FindParamByName(manager, pszName); + + if (pInfo->attr & PARAM_ATTR_READ) + { + return pInfo; + } + } #endif + return NULL; +} + + +static ParamInfo_t *FindParamByID(ParamManager_t *manager, uint16_t id) +{ + for (uint16_t i = 0; i < manager->count; ++i) + { + if (manager->pParamTable[i].id == id) + { + return &manager->pParamTable[i]; + } + } + + return NULL; +} /** - * @brief 将参数编码序列化,不具备完整的解析信息 + * @brief 根据参数ID查找参数信息 + * + * @attention 无可读权限时会查找失败 + * @param manager 参数表管理句柄 + * @param id 参数ID + * @return 参数信息 + */ +const ParamInfo_t *Param_FindParamByID(ParamManager_t *manager, uint16_t id) +{ + ParamInfo_t *pInfo; + + if (manager != NULL) + { + pInfo = FindParamByID(manager, id); + + if (pInfo->attr & PARAM_ATTR_READ) + { + return pInfo; + } + } + + return NULL; +} + +/** + * @brief 根据当前参数数据地址指针查找参数信息 + * + * @attention 无可读权限时会查找失败 + * @param manager 参数表管理句柄 + * @param curParamPtr 当前参数数据地址指针 + * @return 参数信息 + */ +const ParamInfo_t *Param_FindParamByParamPtr(ParamManager_t *manager, const void *curParamPtr) +{ + ParamInfo_t *pInfo; + + if (manager != NULL) + { + pInfo = FindParamByParamPtr(manager, curParamPtr); + + if (pInfo->attr & PARAM_ATTR_READ) + { + return pInfo; + } + } + + return NULL; +} + + +// 验证参数是否在指定范围内 +static int ValidateRange(const ParamInfo_t *param, const Value_u *pval) +{ + if (!(param->attr & PARAM_ATTR_RANGE)) + { + return 0; + } + + switch (param->type) + { + case PARAM_INT8: + if (pval->s64val < *param->unMinValuePtr.pInt8) + { + return 1; + } + else if (pval->s64val > *param->unMaxValuePtr.pInt8) + { + return 2; + } + break; + + case PARAM_INT16: + if (pval->s64val < *param->unMinValuePtr.pInt16) + { + return 1; + } + else if (pval->s64val > *param->unMaxValuePtr.pInt16) + { + return 2; + } + break; + + case PARAM_INT32: + if (pval->s64val < *param->unMinValuePtr.pInt32) + { + return 1; + } + else if (pval->s64val > *param->unMaxValuePtr.pInt32) + { + return 2; + } + break; +#if PARAM_USE_64_BIT_LENGTH + case PARAM_INT64: + if (pval->s64val < *param->unMinValuePtr.pInt64) + { + return 1; + } + else if (pval->s64val > *param->unMaxValuePtr.pInt64) + { + return 2; + } + break; +#endif + case PARAM_UINT8: + if (pval->u64val < *param->unMinValuePtr.pUint8) + { + return 1; + } + else if (pval->u64val > *param->unMaxValuePtr.pUint8) + { + return 2; + } + break; + + case PARAM_UINT16: + if (pval->u64val < *param->unMinValuePtr.pUint16) + { + return 1; + } + else if (pval->u64val > *param->unMaxValuePtr.pUint16) + { + return 2; + } + break; + + case PARAM_UINT32: + if (pval->u64val < *param->unMinValuePtr.pUint32) + { + return 1; + } + else if (pval->u64val > *param->unMaxValuePtr.pUint32) + { + return 2; + } + break; +#if PARAM_USE_64_BIT_LENGTH + case PARAM_UINT64: + if (pval->u64val < *param->unMinValuePtr.pUint64) + { + return 1; + } + else if (pval->u64val > *param->unMaxValuePtr.pUint64) + { + return 2; + } + break; +#endif + case PARAM_FLOAT: + if (pval->fVal < *param->unMinValuePtr.pFloat) + { + return 1; + } + else if (pval->fVal > *param->unMaxValuePtr.pFloat) + { + return 2; + } + break; +#if PARAM_USE_64_BIT_LENGTH + case PARAM_DOUBLE: + if (pval->fVal < *param->unMinValuePtr.pDouble) + { + return 1; + } + else if (pval->fVal > *param->unMaxValuePtr.pDouble) + { + return 2; + } + break; +#endif +#if PARAM_USE_STRING_TYPE + case PARAM_STRING: + if (strlen(pval->str) < *param->unMinValuePtr.pStringLength) + { + return 1; + } + else if (strlen(pval->str) > *param->unMaxValuePtr.pStringLength) + { + return 2; + } + break; +#endif + default: + return -1; + } + + return 0; +} + +static int ValidateRangeByVoid(const ParamInfo_t *param, const void *pval) +{ + Value_u uValue; + + switch (param->type) + { + case PARAM_INT8: + uValue.s64val = *(PARAM_INT8_T *)pval; + break; + + case PARAM_INT16: + uValue.s64val = *(PARAM_INT16_T *)pval; + break; + + case PARAM_INT32: + uValue.s64val = *(PARAM_INT32_T *)pval; + break; +#if PARAM_USE_64_BIT_LENGTH + case PARAM_INT64: + uValue.s64val = *(PARAM_INT64_T *)pval; + break; +#endif + case PARAM_UINT8: + uValue.s64val = *(PARAM_UINT8_T *)pval; + break; + + case PARAM_UINT16: + uValue.s64val = *(PARAM_UINT16_T *)pval; + break; + + case PARAM_UINT32: + uValue.s64val = *(PARAM_UINT32_T *)pval; + break; +#if PARAM_USE_64_BIT_LENGTH + case PARAM_UINT64: + uValue.s64val = *(PARAM_UINT64_T *)pval; + break; +#endif + case PARAM_FLOAT: + uValue.fVal = *(PARAM_FLOAT_T *)pval; + break; +#if PARAM_USE_64_BIT_LENGTH + case PARAM_DOUBLE: + uValue.fVal = *(PARAM_DOUBLE_T *)pval; + break; +#endif +#if PARAM_USE_STRING_TYPE + case PARAM_STRING: + memcpy(uValue.str, pval, strlen(pval) > PARAM_STRING_MAX_LENGTH ? PARAM_STRING_MAX_LENGTH + 2 : strlen(pval) + 1); + uValue.str[PARAM_STRING_MAX_LENGTH + 2] = '\0'; + break; +#endif + default: + return -1; + } + + return ValidateRange(param, &uValue); +} + +/** + * @brief 检查参数最新值的范围并对超出范围时进行处理 * - * @attention 序列化时只对部分数据序列化,因此序列化后的数据更适合本机储存在储存芯片中,不适合跨设备传输 - * @param pBuf 序列化后的数据 - * @param[in] paramTable 需要进行序列化的参数表 - * @param[in] num 参数表元素数目 - * @param isAddKey 是否采用键值对(能向下兼容,即使删除一组参数也能正常反序列化) - * @param isUseEncoded 是否采用编码压缩(能够压缩数据,每个数值越小压缩效果越好) - * @return 序列化后的数据大小 + * @param param 参数信息 + * @param opt 超出范围的处理选项: + * @arg PARAM_NONE, 参数不变, 即不做处理 + * @arg PARAM_DEF, 参数恢复默认 + * @arg PARAM_MIN_MAX, 参数小于最小值则为最小值, 参数大于最大值则为最大值; 但对字符串类型参数该选项无效, 即不做处理 + * @return 0,正常; 1,参数小于最小值(字符串长度小于最小限制长度); 2,参数大于最大值(字符串长度大于最大限制长度); <0,错误 */ -size_t Param_Serialize(uint8_t *pBuf, const ParamInfo_t *paramTable, uint16_t num, uint8_t isAddKey, uint8_t isUseEncoded) +int Param_CheckRange(const ParamInfo_t *param, uint8_t opt) { - uint8_t *pPtr = pBuf; + int ret; - if (isAddKey) + if (param == NULL) { - for (int i = 0; i < num; i++) + return -1; // 参数验证失败 + } + + ret = ValidateRangeByVoid(param, param->unCurValuePtr.pVoid); + + if (ret != 0) + { + if (opt == PARAM_DEF) + { + ResetParamValue(param); + } + else if (opt == PARAM_MIN_MAX) { - pPtr = PackTagAndParam(pPtr, ¶mTable[i], isUseEncoded, 0); + ret == 1 ? ResetParamMinValue(param) : ResetParamMaxValue(param); } + + return ret; } - else + + return 0; +} + +/** + * @brief 设置新的参数值 + * + * @param param 参数信息 + * @param value 新的参数值 + * @param opt 超出范围的处理选项: + * @arg PARAM_NONE, 参数不变, 即不做处理 + * @arg PARAM_DEF, 参数恢复默认 + * @arg PARAM_MIN_MAX, 参数小于最小值则为最小值, 参数大于最大值则为最大值; 但对字符串类型参数该选项无效, 即不做处理 + * @return 0,正常; 1,参数小于最小值(字符串长度小于最小限制长度); 2,参数大于最大值(字符串长度大于最大限制长度); <0,错误 + */ +int Param_SetNewValue(const ParamInfo_t *param, const void *value, uint8_t opt) +{ + int ret; + + if (param == NULL) { - for (int i = 0; i < num; i++) + return -1; + } + + ret = ValidateRangeByVoid(param, value); + + if (ret != 0) + { + if (opt == PARAM_DEF) { - pPtr = PackParam(pPtr, ¶mTable[i], isUseEncoded, 0); + ResetParamValue(param); } + else if (opt == PARAM_MIN_MAX) + { + ret == 1 ? ResetParamMinValue(param) : ResetParamMaxValue(param); + } + + return ret; } +#if PARAM_USE_STRING_TYPE + if (param->type != PARAM_STRING) + { + memcpy(param->unCurValuePtr.pVoid, value, param->length); + } + else + { + strcpy(param->unCurValuePtr.pString, value); + } +#else + memcpy(param->unCurValuePtr.pVoid, value, param->length); +#endif + return 0; +} - return pPtr - pBuf; +/** + * @brief 重置参数为缺省值 + * + * @attention 无可重置权限的参数不能恢复为缺省值 + * @param param 参数信息 + * @return true 成功 + * @return false 失败 + */ +bool Param_ResetDefaultValue(const ParamInfo_t *param) +{ + return ResetParamValue(param); } /** - * @brief 将数据反序列化得到参数表信息 + * @brief 重置参数为最小值 * - * @attention 反序列化时需要定义和序列化前一样的完整参数表,才能完成解析,即函数 Param_Serialize 序列化后的数据 - * @param[in] pBuf 需要反序列化后的数据 - * @param[in] length 需要反序列化后的数据长度 - * @param[out] paramTable 反序列化得到参数表信息 - * @param[in] num 参数表元素数目 - * @param isHasKey 序列化的时候是否了采用键值对 - * @param isUseDecode 序列化的时候是否了编码压缩 - * @return 参数表元素数目 + * @attention 字符串类型参数该功能无效 + * @param param 参数信息 + * @return true 成功 + * @return false 失败 + */ +bool Param_ResetMinValue(const ParamInfo_t *param) +{ + return ResetParamMinValue(param); +} + +/** + * @brief 重置参数为最大值 + * + * @attention 字符串类型参数该功能无效 + * @param param 参数信息 + * @return true 成功 + * @return false 失败 + */ +bool Param_ResetMaxValue(const ParamInfo_t *param) +{ + return ResetParamMaxValue(param); +} + +static uint16_t ParamInfoFormStream(ParamInfo_t *param, const uint8_t *pbuf) +{ + switch (param->type) + { + case PARAM_INT8: + { + int64_t val = 0; + pbuf = UnSerializeInt(pbuf, &val, param->length); + *param->unCurValuePtr.pInt8 = (PARAM_INT8_T)val; + } + break; + + case PARAM_INT16: + { + int64_t val = 0; + pbuf = UnSerializeInt(pbuf, &val, param->length); + *param->unCurValuePtr.pInt16 = (PARAM_INT16_T)val; + } + break; + + case PARAM_INT32: + { + int64_t val = 0; + pbuf = UnSerializeInt(pbuf, &val, param->length); + *param->unCurValuePtr.pInt32 = (PARAM_INT32_T)val; + } + break; +#if PARAM_USE_64_BIT_LENGTH + case PARAM_INT64: + { + int64_t val = 0; + pbuf = UnSerializeInt(pbuf, &val, param->length); + *param->unCurValuePtr.pInt64 = (PARAM_INT64_T)val; + } + break; +#endif + case PARAM_UINT8: + { + uint64_t val = 0; + pbuf = UnSerializeUint(pbuf, &val, param->length); + *param->unCurValuePtr.pUint8 = (PARAM_UINT8_T)val; + } + break; + + case PARAM_UINT16: + { + uint64_t val = 0; + pbuf = UnSerializeUint(pbuf, &val, param->length); + *param->unCurValuePtr.pUint16 = (PARAM_UINT16_T)val; + } + break; + + case PARAM_UINT32: + { + uint64_t val = 0; + pbuf = UnSerializeUint(pbuf, &val, param->length); + *param->unCurValuePtr.pUint32= (PARAM_UINT32_T)val; + } + break; +#if PARAM_USE_64_BIT_LENGTH + case PARAM_UINT64: + { + uint64_t val = 0; + pbuf = UnSerializeUint(pbuf, &val, param->length); + *param->unCurValuePtr.pUint64 = (PARAM_UINT64_T)val; + } + break; +#endif + case PARAM_FLOAT: + pbuf = UnSerializeFloat(pbuf, param->unCurValuePtr.pFloat); + break; +#if PARAM_USE_64_BIT_LENGTH + case PARAM_DOUBLE: + pbuf = UnSerializeDouble(pbuf, param->unCurValuePtr.pDouble); + break; +#endif +#if PARAM_USE_STRING_TYPE + case PARAM_STRING: + memcpy(param->unCurValuePtr.pString, &pbuf[0], PARAM_STRING_MAX_LENGTH); + break; +#endif + default: + return 0; // 不支持的参数类型 + } + + return param->length; +} + +static uint8_t *MoveBufToBase(uint8_t *pbuf, uint32_t length) +{ + memmove(pbuf - length, pbuf, length); + return (pbuf - length); +} + +/** + * @brief 加载数据 + * + * @note 该操作会校验参数的合法性(取值范围) + * @param manager 参数表管理句柄 + * @param pfnLoadCallback 加载回调函数 + * @param pfnCheckError 参数不合法时触发回调函数 + * @return 0,成功; -1,失败 */ -uint16_t Param_Parse(uint8_t *pBuf, size_t length, ParamInfo_t *paramTable, uint16_t num, uint8_t isHasKey, uint8_t isUseDecode) +int Param_Load(ParamManager_t *manager, pfnLoad_cb pfnLoadCallback, pfnCheckError_cb pfnCheckError) { - uint8_t *pPtr = pBuf; - uint8_t buf[100]; - ParamInfo_t tParam; +#if PARAM_USE_STRING_TYPE + uint8_t buf[sizeof(ParamInfo_t) + PARAM_STRING_MAX_LENGTH]; +#else + uint8_t buf[sizeof(ParamInfo_t)]; +#endif + uint8_t *ptr = buf; - if (isHasKey) + if (manager == NULL || pfnLoadCallback == NULL) { - tParam.pCurValue = &buf[0]; + return -1; + } - while (pPtr - pBuf < length) + bool isFinish = false; + uint16_t length = 0; + uint16_t paramLength = 0; + uint16_t id = 0; + ParamInfo_t *pParamInfo; +#if PARAM_USE_KEY_VALUE + uint64_t key = 0; +#endif + + do + { + length = sizeof(buf) - (ptr - buf); + + if (pfnLoadCallback(ptr, &length, &isFinish) != 0) { - pPtr = UnPackTagAndParam(pPtr, &tParam, isUseDecode, 0); + return -2; + } + + if (isFinish || length == 0) + { + continue; + } + + length += (ptr - buf); + ptr = buf; + +#if PARAM_USE_KEY_VALUE + + while (length > PARAM_SUPPORT_NUM) + { + UnSerializeUint(ptr, &key, PARAM_SUPPORT_NUM); + +#if PARAM_SUPPORT_NUM == PARAM_SUPPORT_16 + id = (key >> 4) & 0x0F; + paramLength = key & 0x0F; +#elif PARAM_SUPPORT_NUM == PARAM_SUPPORT_256 + id = (key >> 8) & 0xFF; + paramLength = key & 0xFF; +#elif PARAM_SUPPORT_NUM == PARAM_SUPPORT_4096 + id = (key >> 12) & 0xFFF; + paramLength = key & 0xFFF; +#endif + + if (length < (paramLength + PARAM_SUPPORT_NUM)) + { + break; + } + + ptr += PARAM_SUPPORT_NUM; + length -= PARAM_SUPPORT_NUM; + + pParamInfo = (ParamInfo_t *)FindParamByID(manager, id); - for (int i = 0; i < num; i++) + if (pParamInfo == NULL) { - if (tParam.id == paramTable[i].id && tParam.type == paramTable[i].type) + ptr += paramLength; + length -= paramLength; + continue; + } + + ParamInfoFormStream(pParamInfo, ptr); + ptr += paramLength; + length -= paramLength; + + if (0 != ValidateRangeByVoid(pParamInfo, pParamInfo->unCurValuePtr.pVoid)) + { + if (pfnCheckError != NULL) { - memset(paramTable[i].pCurValue, 0, paramTable[i].length); - memcpy(paramTable[i].pCurValue, tParam.pCurValue, tParam.length); - break; + pfnCheckError(pParamInfo); } } } + +#else + + while (length >= 1) + { + pParamInfo = &manager->pParamTable[id]; + + if (length < pParamInfo->length) + { + break; + } + + ParamInfoFormStream(pParamInfo, ptr); + ptr += pParamInfo->length; + + if (0 != ValidateRangeByVoid(pParamInfo, pParamInfo->unCurValuePtr.pVoid)) + { + if (pfnCheckError != NULL) + { + pfnCheckError(pParamInfo); + } + } + + length -= pParamInfo->length; + id++; + } + +#endif + ptr = MoveBufToBase(ptr, ptr - buf); + ptr += length; + } while (!isFinish); + + return 0; +} + +static uint16_t ParamInfoToStream(uint8_t *pbuf, ParamInfo_t *param) +{ + switch (param->type) + { + case PARAM_INT8: + pbuf = SerializeInt(pbuf, *(PARAM_INT8_T *)param->unCurValuePtr.pVoid, param->length); + break; + + case PARAM_INT16: + pbuf = SerializeInt(pbuf, *(PARAM_INT16_T *)param->unCurValuePtr.pVoid, param->length); + break; + + case PARAM_INT32: + pbuf = SerializeInt(pbuf, *(PARAM_INT32_T *)param->unCurValuePtr.pVoid, param->length); + break; +#if PARAM_USE_64_BIT_LENGTH + case PARAM_INT64: + pbuf = SerializeInt(pbuf, *(PARAM_INT64_T *)param->unCurValuePtr.pVoid, param->length); + break; +#endif + case PARAM_UINT8: + pbuf = SerializeUint(pbuf, *(PARAM_UINT8_T *)param->unCurValuePtr.pVoid, param->length); + break; + + case PARAM_UINT16: + pbuf = SerializeUint(pbuf, *(PARAM_UINT16_T *)param->unCurValuePtr.pVoid, param->length); + break; + + case PARAM_UINT32: + pbuf = SerializeUint(pbuf, *(PARAM_UINT32_T *)param->unCurValuePtr.pVoid, param->length); + break; +#if PARAM_USE_64_BIT_LENGTH + case PARAM_UINT64: + pbuf = SerializeUint(pbuf, *(PARAM_UINT64_T *)param->unCurValuePtr.pVoid, param->length); + break; +#endif + case PARAM_FLOAT: + pbuf = SerializeFloat(pbuf, *(PARAM_FLOAT_T *)param->unCurValuePtr.pVoid); + break; +#if PARAM_USE_64_BIT_LENGTH + case PARAM_DOUBLE: + pbuf = SerializeDouble(pbuf, *(PARAM_DOUBLE_T *)param->unCurValuePtr.pVoid); + break; +#endif +#if PARAM_USE_STRING_TYPE + case PARAM_STRING: + memcpy(&pbuf[0], param->unCurValuePtr.pString, PARAM_STRING_MAX_LENGTH); + break; +#endif + default: + return 0; // 不支持的参数类型 } - else + + return param->length; +} + +/** + * @brief 保存数据 + * + * @note 参数在保存时会对参数校验合法性(取值范围) + * @param manager 参数表管理句柄 + * @param pfnSaveCallback 保存回调函数 + * @param pfnCheckError 参数不合法时触发回调函数 + * @return 0,成功; -1,失败 + */ +int Param_Save(ParamManager_t *manager, pfnSave_cb pfnSaveCallback, pfnCheckError_cb pfnCheckError) +{ +#if PARAM_USE_STRING_TYPE + uint8_t buf[sizeof(ParamInfo_t) + PARAM_STRING_MAX_LENGTH]; +#else + uint8_t buf[sizeof(ParamInfo_t)]; +#endif + uint8_t *ptr = buf; + uint16_t length = 0; +#if PARAM_USE_KEY_VALUE + uint64_t key = 0; +#endif + + if (manager == NULL || pfnSaveCallback == NULL) + { + return -1; + } + + for (int i = 0; i < manager->count; i++) { - for (int i = 0; i < num; i++) + ptr = buf; + length = 0; +#if PARAM_USE_KEY_VALUE +#if PARAM_SUPPORT_NUM == PARAM_SUPPORT_16 + key = (manager->pParamTable[i].id << 4) | (manager->pParamTable[i].length & 0x0F); +#elif PARAM_SUPPORT_NUM == PARAM_SUPPORT_256 + key = (manager->pParamTable[i].id << 8) | (manager->pParamTable[i].length & 0xFF); +#elif PARAM_SUPPORT_NUM == PARAM_SUPPORT_4096 + key = (manager->pParamTable[i].id << 12) | (manager->pParamTable[i].length & 0xFFF); +#endif + ptr = SerializeUint(ptr, key, PARAM_SUPPORT_NUM); + length += PARAM_SUPPORT_NUM; +#endif + if (0 != ValidateRangeByVoid(&manager->pParamTable[i], manager->pParamTable[i].unCurValuePtr.pVoid)) + { + if (pfnCheckError != NULL) + { + pfnCheckError(&manager->pParamTable[i]); + } + } + + length = ParamInfoToStream(&buf[length], &manager->pParamTable[i]); + ptr += length; + + if (pfnSaveCallback(buf, (ptr - buf), false) != 0) { - UnPackParam(pBuf, ¶mTable[i], isUseDecode, 0); + return -2; } } - return num; + if (pfnSaveCallback(buf, 0, true) != 0) + { + return -2; + } + + return 0; } + + + diff --git a/Param/src/stream.c b/Param/src/stream.c deleted file mode 100644 index c46a06153e757bd21cd0a1f725dfe43db8e0c7b7..0000000000000000000000000000000000000000 --- a/Param/src/stream.c +++ /dev/null @@ -1,719 +0,0 @@ -#include "stream.h" -#include "param_cfg.h" -#include - -typedef union -{ - uint32_t data; - float fdata; -}unFloat_t; - -typedef union -{ - uint64_t data; - double fdata; -}unDouble_t; - -static uint8_t *VarintEncoded(uint8_t *ptr, uint64_t val) -{ - while (val >= 0x80) - { - *ptr++ = (uint8_t)val | 0x80; - val >>= 7; - } - - *ptr++ = (uint8_t)val; - - return ptr; -} - -static uint8_t *VarintDecode(uint8_t *ptr, uint64_t *pVal) -{ - uint8_t offset = 0; - uint64_t result = 0; - - do - { - result |= (uint64_t)((*ptr) & ~0x80) << offset; - offset += 7; - } while (((*ptr++) & 0x80) != 0); - - *pVal = result; - - return ptr; -} - -static uint8_t *ZigzagEncoded(uint8_t *ptr, int64_t val) -{ - return VarintEncoded(ptr, (uint64_t)((val<<1)^(val>>63))); -} - -static uint8_t *ZigzagDecode(uint8_t *ptr, int64_t *pVal) -{ - uint64_t u64val; - - ptr = VarintDecode(ptr, &u64val); - *pVal = (int64_t)((u64val >> 1) ^ - (u64val&1)); - - return ptr; -} - -static uint8_t *sMemPack(uint8_t *ptr, int64_t val, uint8_t size) -{ - for (int i = 0; i < size; i++) - { - *ptr++ = val >> (i * 8); - } - - return ptr; -} - -static uint8_t *sMemUnPack(uint8_t *ptr, int64_t *pVal, uint8_t size) -{ - uint64_t result = 0; - - for (int i = 0; i < size; i++) - { - result |= ((int64_t)*ptr) << (i * 8); - ptr++; - } - - *pVal = result; - - return ptr; -} - -static uint8_t *uMemPack(uint8_t *ptr, uint64_t val, uint8_t size) -{ - for (int i = 0; i < size; i++) - { - *ptr++ = val >> (i * 8); - } - - return ptr; -} - -static uint8_t *uMemUnPack(uint8_t *ptr, uint64_t *pVal, uint8_t size) -{ - uint64_t result = 0; - - for (int i = 0; i < size; i++) - { - result |= ((uint64_t)*ptr) << (i * 8); - ptr++; - } - - *pVal = result; - - return ptr; -} - -static uint8_t *PackTag(uint8_t *pbuf, const ParamInfo_t *pParam) -{ - uint8_t *ptr = pbuf; - uint16_t tag = (pParam->id << 4) | pParam->type; - - pbuf[0] = tag & 0xFF; - pbuf[1] = (tag >> 8) & 0xFF; - ptr += 2; - - return ptr; -} - -static uint8_t *UnPackTag(uint8_t *pbuf, uint16_t *pId, uint8_t *pType) -{ - uint8_t *ptr = pbuf; - uint16_t tag = ((uint16_t)pbuf[1] << 8) | pbuf[0]; - - *pId = tag >> 4; - *pType = tag & 0x0f; - - ptr += 2; - - return ptr; -} - -static ParamInfo_t *FindTag(uint16_t id, uint8_t type, const ParamInfo_t *pParamTab, uint16_t num) -{ - ParamInfo_t *pParam = NULL; - - for (uint16_t i = 0; i < num; i++) - { - if (id == pParamTab[i].id && type == pParamTab[i].type) - { - - pParam = (ParamInfo_t *)&pParamTab[i]; - break; - } - } - - return pParam; -} - -static uint8_t *PackInt8(uint8_t *ptr, const void *pVal, uint16_t length, uint8_t isEncoded) -{ - if (isEncoded) - { - *ptr++ = (uint8_t)(*(int8_t *)pVal); - } - else - { - ptr = sMemPack(ptr, (*(int8_t *)pVal), sizeof(int8_t)); - } - - return ptr; -} - -static uint8_t *PackInt16(uint8_t *ptr, const void *pVal, uint16_t length, uint8_t isEncoded) -{ - if (isEncoded) - { - ptr = ZigzagEncoded(ptr, (*(int16_t *)pVal)); - } - else - { - ptr = sMemPack(ptr, (*(int16_t *)pVal), sizeof(int16_t)); - } - - return ptr; -} - -static uint8_t *PackInt32(uint8_t *ptr, const void *pVal, uint16_t length, uint8_t isEncoded) -{ - if (isEncoded) - { - ptr = ZigzagEncoded(ptr, (*(int32_t *)pVal)); - } - else - { - ptr = sMemPack(ptr, (*(int32_t *)pVal), sizeof(int32_t)); - } - - return ptr; -} - -static uint8_t *PackInt64(uint8_t *ptr, const void *pVal, uint16_t length, uint8_t isEncoded) -{ - if (isEncoded) - { - ptr = ZigzagEncoded(ptr, (*(int64_t *)pVal)); - } - else - { - ptr = sMemPack(ptr, (*(int64_t *)pVal), sizeof(int64_t)); - } - - return ptr; -} - -static uint8_t *PackUint8(uint8_t *ptr, const void *pVal, uint16_t length, uint8_t isEncoded) -{ - if (isEncoded) - { - *ptr++ = (*(uint8_t *)pVal); - } - else - { - ptr = uMemPack(ptr, (*(uint8_t *)pVal), sizeof(uint8_t)); - } - - return ptr; -} - -static uint8_t *PackUint16(uint8_t *ptr, const void *pVal, uint16_t length, uint8_t isEncoded) -{ - if (isEncoded) - { - ptr = VarintEncoded(ptr, (*(uint16_t *)pVal)); - } - else - { - ptr = uMemPack(ptr, (*(uint16_t *)pVal), sizeof(uint16_t)); - } - - return ptr; -} - -static uint8_t *PackUint32(uint8_t *ptr, const void *pVal, uint16_t length, uint8_t isEncoded) -{ - if (isEncoded) - { - ptr = VarintEncoded(ptr, (*(uint32_t *)pVal)); - } - else - { - ptr = uMemPack(ptr, (*(uint32_t *)pVal), sizeof(uint32_t)); - } - - return ptr; -} - -static uint8_t *PackUint64(uint8_t *ptr, const void *pVal, uint16_t length, uint8_t isEncoded) -{ - if (isEncoded) - { - ptr = VarintEncoded(ptr, (*(uint64_t *)pVal)); - } - else - { - ptr = uMemPack(ptr, (*(uint64_t *)pVal), sizeof(uint64_t)); - } - - return ptr; -} - -static uint8_t *PackFloat(uint8_t *ptr, const void *pVal, uint16_t length, uint8_t isEncoded) -{ - unFloat_t t; - - t.fdata = *(float *)pVal; - - for (int i = 0; i < 4; i++) - { - *ptr++ = t.data >> (i * 8); - } - - return ptr; -} - -static uint8_t *PackDouble(uint8_t *ptr, const void *pVal, uint16_t length, uint8_t isEncoded) -{ - unFloat_t t; - - t.fdata = *(double *)pVal; - - for (int i = 0; i < 8; i++) - { - *ptr++ = t.data >> (i * 8); - } - - return ptr; -} - -static uint8_t *PackString(uint8_t *ptr, const void *pVal, uint16_t length, uint8_t isEncoded) -{ - // if (isEncoded) - // { - // length = strlen((char *)pVal) > length ? length : strlen((char *)pVal); - // } - - for (int i = 0; i < PARAM_STRING_SIZE; i++) - { - *ptr++ = (length >> (i * 8)) & 0xff; - } - - memcpy(ptr, pVal, length); - ptr += length; - - return ptr; -} - -typedef uint8_t *(*PackFun_t)(uint8_t *ptr, const void *pVal, uint16_t length, uint8_t isEncoded); - -PackFun_t packFunTable[]={ - PackInt8, - PackInt16, - PackInt32, - PackInt64, - PackUint8, - PackUint16, - PackUint32, - PackUint64, - PackFloat, - PackDouble, - PackString -}; - -static uint8_t *PackData(uint8_t *pbuf, uint8_t type, void *pVal, uint16_t length, uint8_t isEncoded) -{ - return packFunTable[type](pbuf, pVal, length, isEncoded); -} - -uint8_t *PackParam(uint8_t *pBuf, const ParamInfo_t *pParam, uint8_t isUseEncoded, uint8_t opt) -{ - pBuf = PackData(pBuf, pParam->type, pParam->pCurValue, pParam->length, isUseEncoded); - - if (opt & PARAM_PACK_NAME) - { - uint16_t length = strlen(pParam->pszName) >= PARAM_NAME_MAX_LENGTH ? PARAM_NAME_MAX_LENGTH - 1 : strlen(pParam->pszName); - memcpy(pBuf, pParam->pszName, length + 1); - pBuf += (length + 1); - } - - if (opt & PARAM_PACK_ATTR) - { - pBuf = PackUint8(pBuf, &pParam->attr, 1, 0); - } - - if (opt & PARAM_PACK_DEF_VAL) - { - pBuf = PackData(pBuf, pParam->type, pParam->pDefValue, pParam->length, isUseEncoded); - } - - if ((opt & PARAM_PACK_MIN_VAL) && pParam->type != PARAM_STARING) - { - pBuf = PackData(pBuf, pParam->type, pParam->pMinValue, pParam->length, isUseEncoded); - } - - if ((opt & PARAM_PACK_MAX_VAL) && pParam->type != PARAM_STARING) - { - pBuf = PackData(pBuf, pParam->type, pParam->pMaxValue, pParam->length, isUseEncoded); - } - - return pBuf; -} - -uint8_t *PackTagAndParam(uint8_t *pBuf, const ParamInfo_t *pParam, uint8_t isUseEncoded, uint8_t opt) -{ - isUseEncoded = isUseEncoded > 0 ? 1 : 0; - pBuf = PackTag(pBuf, pParam); - pBuf = PackParam(pBuf, pParam, isUseEncoded, opt); - - return pBuf; -} - -uint8_t *PackTagAndOptAndParam(uint8_t *pBuf, const ParamInfo_t *pParam, uint8_t isUseEncoded, uint8_t opt) -{ - isUseEncoded = isUseEncoded > 0 ? 1 : 0; - pBuf = PackTag(pBuf, pParam); - *pBuf++ = (isUseEncoded << 7) | (opt & 0x7f); - - pBuf = PackParam(pBuf, pParam, isUseEncoded, opt); - - return pBuf; -} - -static uint8_t *UnPackInt8(uint8_t *ptr, void *pVal, uint16_t *pLength, uint8_t isDecode) -{ - int64_t s64Val; - - if (isDecode) - { - s64Val = *(int8_t *)ptr; - ptr++; - } - else - { - ptr = sMemUnPack(ptr, &s64Val, sizeof(int8_t)); - } - - if (pVal != NULL) - { - *(int8_t *)pVal = (int8_t)s64Val; - } - - *pLength = sizeof(int8_t); - - return ptr; -} - -static uint8_t *UnPackInt16(uint8_t *ptr, void *pVal, uint16_t *pLength, uint8_t isDecode) -{ - int64_t s64Val; - - if (isDecode) - { - ptr = ZigzagDecode(ptr, &s64Val); - } - else - { - ptr = sMemUnPack(ptr, &s64Val, sizeof(int16_t)); - } - - if (pVal != NULL) - { - *(int16_t *)pVal = (int16_t)s64Val; - } - - *pLength = sizeof(int16_t); - - return ptr; -} - -static uint8_t *UnPackInt32(uint8_t *ptr, void *pVal, uint16_t *pLength, uint8_t isDecode) -{ - int64_t s64Val; - - if (isDecode) - { - ptr = ZigzagDecode(ptr, &s64Val); - } - else - { - ptr = sMemUnPack(ptr, &s64Val, sizeof(int32_t)); - } - - if (pVal != NULL) - { - *(int32_t *)pVal = (int32_t)s64Val; - } - - *pLength = sizeof(int32_t); - - return ptr; -} - -static uint8_t *UnPackInt64(uint8_t *ptr, void *pVal, uint16_t *pLength, uint8_t isDecode) -{ - int64_t s64Val; - - if (isDecode) - { - ptr = ZigzagDecode(ptr, &s64Val); - } - else - { - ptr = sMemUnPack(ptr, &s64Val, sizeof(int64_t)); - } - - if (pVal != NULL) - { - *(int64_t *)pVal = (int64_t)s64Val; - } - - *pLength = sizeof(int64_t); - - return ptr; -} - - - -static uint8_t *UnPackUint8(uint8_t *ptr, void *pVal, uint16_t *pLength, uint8_t isDecode) -{ - uint64_t u64Val; - - if (isDecode) - { - u64Val = *(uint8_t *)ptr; - ptr++; - } - else - { - ptr = uMemUnPack(ptr, &u64Val, sizeof(uint8_t)); - } - - if (pVal != NULL) - { - *(uint8_t *)pVal = (uint8_t)u64Val; - } - - *pLength = sizeof(uint8_t); - - return ptr; -} - -static uint8_t *UnPackUint16(uint8_t *ptr, void *pVal, uint16_t *pLength, uint8_t isDecode) -{ - uint64_t u64Val; - - if (isDecode) - { - ptr = VarintDecode(ptr, &u64Val); - } - else - { - ptr = uMemUnPack(ptr, &u64Val, sizeof(uint16_t)); - } - - if (pVal != NULL) - { - *(uint16_t *)pVal = (uint16_t)u64Val; - } - - *pLength = sizeof(uint16_t); - - return ptr; -} - -static uint8_t *UnPackUint32(uint8_t *ptr, void *pVal, uint16_t *pLength, uint8_t isDecode) -{ - uint64_t u64Val; - - if (isDecode) - { - ptr = VarintDecode(ptr, &u64Val); - } - else - { - ptr = uMemUnPack(ptr, &u64Val, sizeof(uint32_t)); - } - - if (pVal != NULL) - { - *(uint32_t *)pVal = (uint32_t)u64Val; - } - - *pLength = sizeof(uint32_t); - - return ptr; -} - -static uint8_t *UnPackUint64(uint8_t *ptr, void *pVal, uint16_t *pLength, uint8_t isDecode) -{ - uint64_t u64Val; - - if (isDecode) - { - ptr = VarintDecode(ptr, &u64Val); - } - else - { - ptr = uMemUnPack(ptr, &u64Val, sizeof(uint64_t)); - } - - if (pVal != NULL) - { - *(uint64_t *)pVal = (uint64_t)u64Val; - } - - *pLength = sizeof(uint64_t); - - return ptr; -} - -static uint8_t *UnPackFloat(uint8_t *ptr, void *pVal, uint16_t *pLength, uint8_t isDecode) -{ - unFloat_t t; - t.data = 0; - - for (int i = 0; i < 4; i++) - { - t.data |= ((uint32_t)(*ptr) << (i * 8)); - ptr++; - } - - if (pVal != NULL) - { - *(float *)pVal = t.fdata; - } - - *pLength = 4; - - return ptr; -} - -static uint8_t *UnPackDouble(uint8_t *ptr, void *pVal, uint16_t *pLength, uint8_t isDecode) -{ - unFloat_t t; - t.data = 0; - - for (int i = 0; i < 8; i++) - { - t.data |= ((uint64_t)(*ptr) << (i * 8)); - ptr++; - } - - if (pVal != NULL) - { - *(double *)pVal = t.fdata; - } - - *pLength = 8; - - return ptr; -} - -static uint8_t *UnPackString(uint8_t *ptr, void *pVal, uint16_t *pLength, uint8_t isDecode) -{ - uint16_t length = 0; - - for (int i = 0; i < PARAM_STRING_SIZE; i++) - { - length |= ((uint16_t)*ptr) << (i * 8); - ptr++; - } - - // if (isDecode) - { - *pLength = length; - } - - if (pVal != NULL) - { - memcpy(pVal, ptr, length); - } - - ptr += length; - return ptr; -} - -typedef uint8_t *(*UnPackFun_t)(uint8_t *ptr, void *pVal, uint16_t *pLength, uint8_t isDecode); - -UnPackFun_t unpackFunTable[]={ - UnPackInt8, - UnPackInt16, - UnPackInt32, - UnPackInt64, - UnPackUint8, - UnPackUint16, - UnPackUint32, - UnPackUint64, - UnPackFloat, - UnPackDouble, - UnPackString -}; - -static uint8_t *UnPackData(uint8_t *pbuf, uint8_t type, void *pVal, uint16_t *pLength, uint8_t isDecode) -{ - return unpackFunTable[type](pbuf, pVal, pLength, isDecode); -} - -uint8_t *UnPackParam(uint8_t *pBuf, ParamInfo_t *pParam, uint8_t isUseDecode, uint8_t opt) -{ - uint16_t length; - pBuf = UnPackData(pBuf, pParam->type, pParam->pCurValue, &pParam->length, isUseDecode); - - if (opt & PARAM_PACK_NAME) - { - length = strlen(pBuf) >= PARAM_NAME_MAX_LENGTH ? PARAM_NAME_MAX_LENGTH - 1 : strlen(pBuf); - memcpy(pParam->pszName, pBuf, length + 1); - pBuf[length] = '\0'; - pBuf += (length + 1); - } - - if (opt & PARAM_PACK_ATTR) - { - pBuf = UnPackUint8(pBuf, &pParam->attr, &length, 0); - } - - if (opt & PARAM_PACK_DEF_VAL) - { - pBuf = UnPackData(pBuf, pParam->type, pParam->pDefValue, &length, isUseDecode); - } - - if ((opt & PARAM_PACK_MIN_VAL) && pParam->type != PARAM_STARING) - { - pBuf = UnPackData(pBuf, pParam->type, pParam->pMinValue, &length, isUseDecode); - } - - if ((opt & PARAM_PACK_MAX_VAL) && pParam->type != PARAM_STARING) - { - pBuf = UnPackData(pBuf, pParam->type, pParam->pMaxValue, &length, isUseDecode); - } - - return pBuf; -} - -uint8_t *UnPackTagAndParam(uint8_t *pBuf, ParamInfo_t *pParam, uint8_t isUseDecode, uint8_t opt) -{ - pBuf = UnPackTag(pBuf, &pParam->id, &pParam->type); - pBuf = UnPackParam(pBuf, pParam, isUseDecode, opt); - - return pBuf; -} - -uint8_t *UnPackTagAndOptAndParam(uint8_t *pBuf, ParamInfo_t *pParam) -{ - uint8_t isUseDecode; - uint8_t opt; - - pBuf = UnPackTag(pBuf, &pParam->id, &pParam->type); - - isUseDecode = (*pBuf >> 7) & 0x01; - opt = (*pBuf & 0x7f); - pBuf++; - - pBuf = UnPackParam(pBuf, pParam, isUseDecode, opt); - - return pBuf; -} diff --git a/README.md b/README.md index be79ee272be2308083a95d92246910fd4ebca8e4..88d20ee2d382dbb6fe9560bd56024531102c3e77 100644 --- a/README.md +++ b/README.md @@ -1,81 +1,180 @@ # 轻量级参数管理框架(C语言) ## 介绍 -1. 采用表驱动方式统一管理所有参数,包括缺省值、最小值和最大值等 -2. 采用宏定义快速注册和添加参数进行管理 +1. 采用表驱动方式统一管理所有参数,包括缺省值、最小值和最大值等 -3. 支持基本类型参数和字符串参数 + > - 支持定义普通参数,无缺省值、最小值和最大值限制 + > - 支持定义普通参数,有缺省值,但无最小值和最大值限制 + > - 支持定义普通参数,有缺省值,最小值和最大值限制 + > +2. 采用宏定义快速对参数进行定义、注册和管理 +3. 支持基本类型参数和字符串参数 +4. 支持序列化和反序列化操作,可在本地储存设备保存/读取二进制数据 -4. 支持两种方式序列化和反序列化操作,便于选择在本地保存二进制数据或者跨设备通信使用 - > - 其中本地化序列化方式又可以选择“键值对”或者“值”保存,“键值对”方式更有利于向下兼容,即使迭代中删除数据也能正常获取; - > - 本地化序列化又可以采用“编码”压缩的方式,最大限度压缩数据,因此采用“编码”时如果参数数值不同,序列化后的数据长度也有可能不同 - > - 跨设备序列化数据默认采用“键值对”和“编码”压缩的方式,同时增加了其他便于解析的信息,方便其他设备使用同样的代码进行反序列化 + > - 支持键值对的方式储存,即使后期版本迭代对参数表删除/插入数据时也能向下兼容 + > - 支持非键值对的方式储存,适合小容量的储存设备,序列化后的数据内容少,但是后期版本迭代对参数表删除或插入数据时不能向下兼容,只有通过在参数表后添加参数才能向下兼容 + > - 通过多次读写储存设备分别加载参数和保存参数,更兼容小内存的平台使用(多次调用回调函数处理) + > - 支持在数据加载或保存时当参数当前值不合法(超出范围)触发错误处理回调函数,有上层应用程序决定如何处理(可以恢复默认值) + > +5. 支持功能配置裁剪 + + > - 根据不同的平台,可以对部分功能裁剪,或者修改配置适用于不同容量的芯片开发 + > - 键值对的方式储存:向下兼容较好 + > - 可以选择只支持基本类型的参数储存功能,如字符串类型参数和64位长度的参数可裁剪 + > ## 软件架构 +## 使用说明 + 定义参数表 ```c -PARAM_DEFINE (test, PARAM_INT16, 10, -100, 100); -PARAM_DEFINE (test_2, PARAM_UINT16, 20, 0, 100); -PARAM_DEFINE (test_3, PARAM_DOUBLE, 3.15, -10, 10); -PARAM_DEFINE_STR (test_str, 10, "abcdef"); -PARAM_DEFINE (test_4, PARAM_INT8, 8, -10, 10); -PARAM_DEFINE (test_5, PARAM_UINT32, 620, 500, 10000); -PARAM_DEFINE (test_6, PARAM_UINT8, 4, 5, 100); -PARAM_DEFINE (test_7, PARAM_INT64, 5, -542, 5450); + +PARAM_DEFINE_DAT (g_test, PARAM_INT16, 10); +PARAM_DEFINE_DAT_DEF (g_test_2, PARAM_UINT16, 20); +PARAM_DEFINE_DAT_RANGE (g_test_3, PARAM_DOUBLE, 3.15, -10, 10); +PARAM_DEFINE_STR_RANGE (g_test_str, 10, "abcdef", 5, 10); +PARAM_DEFINE_DAT_RANGE (g_test_4, PARAM_INT8, 8, -10, 10); +PARAM_DEFINE_DAT_RANGE (g_test_5, PARAM_UINT32, 620, 500, 10000); +PARAM_DEFINE_DAT_RANGE (g_test_6, PARAM_UINT8, 45, 5, 100); +PARAM_DEFINE_DAT_RANGE (g_test_7, PARAM_INT64, 5, -542, 5450); ParamInfo_t sg_ParamTable[] = { - PARAM_REG(1, test, PARAM_INT16, PARAM_ATTR_ALL), - PARAM_REG(2, test_2, PARAM_UINT16, PARAM_ATTR_READ), - PARAM_REG(3, test_3, PARAM_DOUBLE, PARAM_ATTR_READ | PARAM_ATTR_WRITE), - PARAM_STR_REG(4, test_str, PARAM_ATTR_READ | PARAM_ATTR_WRITE), - PARAM_REG(5, test_4, PARAM_INT8, PARAM_ATTR_READ), - PARAM_REG(6, test_5, PARAM_UINT32, PARAM_ATTR_READ), - PARAM_REG(7, test_6, PARAM_UINT8, PARAM_ATTR_READ), - PARAM_REG(8, test_7, PARAM_INT64, PARAM_ATTR_WRITE), + PARAM_ITEM_DAT(1, g_test, PARAM_ATTR_WR), + PARAM_ITEM_DAT_DEF(2, g_test_2, PARAM_ATTR_WR), + PARAM_ITEM_DAT_RANGE(3, g_test_3, PARAM_ATTR_WR), + PARAM_ITEM_STR_RANGE(4, g_test_str, PARAM_ATTR_WR), + PARAM_ITEM_DAT_RANGE(5, g_test_4, PARAM_ATTR_WR), + PARAM_ITEM_DAT_RANGE(6, g_test_5, PARAM_ATTR_WR), + PARAM_ITEM_DAT_RANGE(7, g_test_6, PARAM_ATTR_WR), + PARAM_ITEM_DAT_RANGE(8, g_test_7, PARAM_ATTR_READ), // 只读 }; + ``` -Demo 的结果展示(具体编译demo后使用) -```c -Init: - id name type length attr val def min max - 1 test int16_t 2 wr 10 10 -100 100 - 2 test_2 uint16_t 2 r 20 20 0 100 - 3 test_3 double 8 wr 3.150000 3.150000 -10.000000 10.000000 - 4 test_str string 10 wr abcdef abcdef - 5 test_4 int8_t 1 r 8 8 -10 10 - 6 test_5 uint32_t 4 r 620 620 500 10000 - 7 test_6 uint8_t 1 r 4 4 5 100 - 8 test_7 int64_t 8 w 5 0 5 0 +通过宏去操作参数示例片段代码 -"普通序列化": [37] -> 0a 00 14 00 9a 99 49 40 9a 99 49 40 0a 61 62 63 64 65 66 00 00 00 00 08 6c 02 00 00 04 05 00 00 00 00 00 00 00 -"编码序列化": [26] -> 14 14 9a 99 49 40 9a 99 49 40 0a 61 62 63 64 65 66 00 00 00 00 08 ec 04 04 0a -"增加键值序列化": [53] -> 11 00 0a 00 25 00 14 00 39 00 9a 99 49 40 9a 99 49 40 4a 00 0a 61 62 63 64 65 66 00 00 00 00 50 00 08 66 00 6c 02 00 00 74 00 04 83 00 05 00 00 00 00 00 00 00 -"增加键值并编码序列化": [42] -> 11 00 14 25 00 14 39 00 9a 99 49 40 9a 99 49 40 4a 00 0a 61 62 63 64 65 66 00 00 00 00 50 00 08 66 00 ec 04 74 00 04 83 00 0a +```c +// 首先需要在头文件声明 +PARAM_EXTERN_DAT(g_test, PARAM_INT16); +PARAM_EXTERN_DAT(g_test_2, PARAM_UINT16); +PARAM_EXTERN_DAT(g_test_3, PARAM_DOUBLE); +PARAM_EXTERN_STR(g_test_str, 10); +PARAM_EXTERN_DAT(g_test_4, PARAM_INT8); +PARAM_EXTERN_DAT(g_test_5, PARAM_UINT32); +PARAM_EXTERN_DAT(g_test_6, PARAM_UINT8); +PARAM_EXTERN_DAT(g_test_7, PARAM_INT64); + + +//函数中使用 +int main() +{ +//方法一: + // 对参数g_test_6设置新的值50,如果超出限定范围则不处理 + PARAM_DAT_SET_NEW_VALUE(g_test_6, 50, PARAM_NONE); + + // 对参数g_test_6设置新的值50,如果超出限定范围则重置为默认值 + PARAM_DAT_SET_NEW_VALUE(g_test_6, 50, PARAM_DEF); + + // 对参数g_test_6设置新的值150,如果超出限定范围则参数小于最小值则为最小值, 参数大于最大值则为最大值 + PARAM_DAT_SET_NEW_VALUE(g_test_6, 150, PARAM_MIN_MAX); + + +//方法二: + // 对参数g_test_6设置新的值50,如果超出限定范围则不处理 + g_test_6 = 50; + PARAM_DAT_CHECK_RANGE(g_test_6, PARAM_NONE); + + // 对参数g_test_6设置新的值50,如果超出限定范围则重置为默认值 + g_test_6 = 50; + PARAM_DAT_CHECK_RANGE(g_test_6, PARAM_DEF); + + // 对参数g_test_6设置新的值150,如果超出限定范围则参数小于最小值则为最小值, 参数大于最大值则为最大值 + g_test_6 = 150; + PARAM_DAT_CHECK_RANGE(g_test_6, PARAM_MIN_MAX); +} +``` +通过函数去操作参数示例片段代码 -"跨设备的序列化(携带基础信息)": [50] -> 11 00 80 14 25 00 80 14 39 00 80 9a 99 49 40 9a 99 49 40 4a 00 80 0a 61 62 63 64 65 66 00 00 00 00 50 00 80 08 66 00 80 ec 04 74 00 80 04 83 00 80 0a +```c +//函数中使用 +int main() +{ + PARAM_UINT16_T tmp; + +//方法一: + // 对参数g_test_6设置新的值50,如果超出限定范围则不处理 + tmp = 50; + Param_SetNewValue(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), &tmp, PARAM_NONE); + + // 对参数g_test_6设置新的值50,如果超出限定范围则重置为默认值 + tmp = 50; + Param_SetNewValue(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), &tmp, PARAM_DEF); + + // 对参数g_test_6设置新的值150,如果超出限定范围则参数小于最小值则为最小值, 参数大于最大值则为最大值 + tmp = 150; + Param_SetNewValue(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), &tmp, PARAM_MIN_MAX); + + +//方法二: + // 对参数g_test_6设置新的值50,如果超出限定范围则不处理 + g_test_6 = 50; + Param_CheckRange(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), PARAM_NONE); + + // 对参数g_test_6设置新的值50,如果超出限定范围则重置为默认值 + g_test_6 = 50; + Param_CheckRange(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), PARAM_DEF); + + // 对参数g_test_6设置新的值150,如果超出限定范围则参数小于最小值则为最小值, 参数大于最大值则为最大值 + g_test_6 = 150; + Param_CheckRange(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), PARAM_MIN_MAX); +} +``` -"跨设备的序列化(携带所有信息)": [174] -> 11 00 ff 14 74 65 73 74 00 ff 14 c7 01 c8 01 25 00 ff 14 74 65 73 74 5f 32 00 01 14 00 64 39 00 ff 9a 99 49 40 9a 99 49 40 74 65 73 74 5f 33 00 03 9a 99 49 40 9a 99 49 40 00 00 20 c1 00 00 20 c1 00 00 20 41 00 00 20 41 4a 00 ff 0a 61 62 63 64 65 66 00 00 00 00 74 65 73 74 5f 73 74 72 00 03 0a 61 62 63 64 65 66 00 08 f6 0a 50 00 ff 08 74 65 73 74 5f 34 00 01 08 f6 0a 66 00 ff ec 04 74 65 73 74 5f 35 00 01 ec 04 f4 03 90 4e 74 00 ff 04 74 65 73 74 5f 36 00 01 04 05 64 83 00 ff 0a 74 65 73 74 5f 37 00 02 0a bb 08 94 55 +序列化 Demo 的结果展示 + +```base +# 配置最多支持 15 个参数时加载参数时分多次读取/保存操作打印日志 +load param: + read: [21] -> 12 0a 00 22 14 00 38 33 33 33 33 33 33 09 40 4a 61 62 63 64 65 + read: [21] -> 66 00 00 00 00 51 08 64 6c 02 00 00 71 2d 88 05 00 00 00 00 00 +save param: + save: [3] -> 12 0a 00 + save: [3] -> 22 14 00 + save: [9] -> 38 33 33 33 33 33 33 09 40 + save: [11] -> 4a 61 62 63 64 65 66 00 00 00 00 + save: [2] -> 51 08 + save: [5] -> 64 6c 02 00 00 + save: [2] -> 71 2d + save: [9] -> 88 05 00 00 00 00 00 00 00 + +# 配置最多支持 15 个参数时的序列化内容及长度 +"键值对序列化": [44] -> 12 0a 00 22 14 00 38 33 33 33 33 33 33 09 40 4a 61 62 63 64 65 66 00 00 00 00 51 08 64 6c 02 00 00 71 2d 88 05 00 00 00 00 00 00 00 +"序列化": [36] -> 50 00 14 00 33 33 33 33 33 33 09 40 67 5f 74 65 73 74 5f 36 00 00 00 6c 02 00 00 2d 05 00 00 00 00 00 00 00 + +# 配置最多支持 256 个参数时的序列化内容及长度 +"键值对序列化": [52] -> 02 01 0a 00 02 02 14 00 08 03 33 33 33 33 33 33 09 40 0a 04 61 62 63 64 65 66 00 00 00 00 01 05 08 04 06 6c 02 00 00 01 07 2d 08 08 05 00 00 00 00 00 00 00 +"序列化": [36] -> 50 00 14 00 33 33 33 33 33 33 09 40 67 5f 74 65 73 74 5f 36 00 00 00 6c 02 00 00 2d 05 00 00 00 00 00 00 00 + +# 配置最多支持 4096 个参数时的序列化内容及长度 +"键值对序列化": [60] -> 02 10 00 0a 00 02 20 00 14 00 08 30 00 33 33 33 33 33 33 09 40 0a 40 00 61 62 63 64 65 66 00 00 00 00 01 50 00 08 04 60 00 6c 02 00 00 01 70 00 2d 08 80 00 05 00 00 00 00 00 00 00 +"序列化": [36] -> 50 00 14 00 33 33 33 33 33 33 09 40 67 5f 74 65 73 74 5f 36 00 00 00 6c 02 00 00 2d 05 00 00 00 00 00 00 00 ``` -## 使用说明 -1. 通过函数 Param_ModifyById、Param_ModifyByName 限制修改参数 -2. 调用函数 Param_Serialize 对参数序列化, 保存至储存芯片中 -3. 从储存芯片读取数据后,调用 Param_Parse 反序列化得到参数,同时进行参数范围校验 - ## demo样式 + 博客: [轻量级参数管理框架(C语言)](https://blog.csdn.net/qq_24130227/article/details/129233836?spm=1001.2014.3001.5501) ## 关于作者 -1. CSDN 博客 [大橙子疯](https://blog.csdn.net/qq_24130227?spm=1010.2135.3001.5343) -2. 联系邮箱 const_zpc@163.com -3. 了解更多可关注微信公众号 -![大橙子疯嵌入式](微信公众号.jpg) \ No newline at end of file +1. CSDN 博客 [大橙子疯](https://blog.csdn.net/qq_24130227?spm=1010.2135.3001.5343) +2. 联系邮箱 const_zpc@163.com +3. 了解更多可关注微信公众号 + +![大橙子疯嵌入式](微信公众号.jpg) diff --git a/test/makefile b/test/makefile new file mode 100644 index 0000000000000000000000000000000000000000..2c67998246dcd1e879154330ab8199cc205f4175 --- /dev/null +++ b/test/makefile @@ -0,0 +1,22 @@ +CURR_DIR_PATH=$(shell pwd) + +CURR_DIR_PATH="C:\Users\const\Desktop\param\param\test" + +GCC:=gcc +INC+=-I${CURR_DIR_PATH}/../Param/inc +INC+=-I${CURR_DIR_PATH}/unity +INC+=-I${CURR_DIR_PATH}/ + +SRC+=${CURR_DIR_PATH}/param_test.c +SRC+=${CURR_DIR_PATH}/unity/unity.c +SRC+=${CURR_DIR_PATH}/../Param/src/param.c + +AIM_NAME:=param_test + +.PHONY:all +all: + ${GCC} ${INC} ${SRC} -o ${CURR_DIR_PATH}/${AIM_NAME} -std=c99 + +.PHONY:clean +clean: + rm -rf ${CURR_DIR_PATH}/${AIM_NAME} \ No newline at end of file diff --git a/test/param_test.c b/test/param_test.c new file mode 100644 index 0000000000000000000000000000000000000000..17a2801bd9af10ddb81dbdaf13bfc191d3cc5fc8 --- /dev/null +++ b/test/param_test.c @@ -0,0 +1,490 @@ +#include +#include +#include +#include "unity.h" +#include "param.h" + +PARAM_DEFINE_DAT (g_test_1, PARAM_INT16, 10); +PARAM_DEFINE_DAT_DEF (g_test_2, PARAM_UINT16, 20); +PARAM_DEFINE_DAT_RANGE (g_test_float, PARAM_FLOAT, 3.15, -10, 10); +#if PARAM_USE_64_BIT_LENGTH +PARAM_DEFINE_DAT_RANGE (g_test_double, PARAM_DOUBLE, 3.15, -10, 10); +#endif +#if PARAM_USE_STRING_TYPE +PARAM_DEFINE_STR_RANGE (g_test_str, 10, "abcdef", 5); +#endif +PARAM_DEFINE_DAT_RANGE (g_test_s8, PARAM_INT8, 10, -10, 15); +PARAM_DEFINE_DAT_RANGE (g_test_s16, PARAM_INT16, 100, -100, 3000); +PARAM_DEFINE_DAT_RANGE (g_test_s32, PARAM_INT32, 1000, -900, 10000); +#if PARAM_USE_64_BIT_LENGTH +PARAM_DEFINE_DAT_RANGE (g_test_s64, PARAM_INT64, 8000, -100, 1000000); +#endif +PARAM_DEFINE_DAT_RANGE (g_test_u8, PARAM_UINT8, 10, 5, 15); +PARAM_DEFINE_DAT_RANGE (g_test_u16, PARAM_UINT16, 100, 100, 3000); +PARAM_DEFINE_DAT_RANGE (g_test_u32, PARAM_UINT32, 1000, 900, 10000); +#if PARAM_USE_64_BIT_LENGTH +PARAM_DEFINE_DAT_RANGE (g_test_u64, PARAM_UINT64, 8000, 100, 1000000); +#endif + + +ParamInfo_t sg_ParamTable[] = { + PARAM_ITEM_DAT(1, g_test_1, PARAM_ATTR_WR), + PARAM_ITEM_DAT_DEF(2, g_test_2, PARAM_ATTR_WR), + PARAM_ITEM_DAT_RANGE(3, g_test_float, PARAM_ATTR_READ), +#if PARAM_USE_64_BIT_LENGTH + PARAM_ITEM_DAT_RANGE(4, g_test_double, PARAM_ATTR_WR), +#endif +#if PARAM_USE_STRING_TYPE + PARAM_ITEM_STR_RANGE(5, g_test_str, PARAM_ATTR_WR), +#endif + PARAM_ITEM_DAT_RANGE(6, g_test_s8, PARAM_ATTR_WR), + PARAM_ITEM_DAT_RANGE(7, g_test_s16, PARAM_ATTR_WR), + PARAM_ITEM_DAT_RANGE(8, g_test_s32, PARAM_ATTR_WR), +#if PARAM_USE_64_BIT_LENGTH + PARAM_ITEM_DAT_RANGE(9, g_test_s64, PARAM_ATTR_WR), +#endif + PARAM_ITEM_DAT_RANGE(10, g_test_u8, PARAM_ATTR_WR), + PARAM_ITEM_DAT_RANGE(11, g_test_u16, PARAM_ATTR_WR), + PARAM_ITEM_DAT_RANGE(12, g_test_u32, PARAM_ATTR_NONE), +#if PARAM_USE_64_BIT_LENGTH + PARAM_ITEM_DAT_RANGE(13, g_test_u64, PARAM_ATTR_WR), +#endif +}; + +static ParamManager_t sg_tParamManager; + +PARAM_EXTERN_DAT(g_test_1, PARAM_INT16); +PARAM_EXTERN_DAT(g_test_2, PARAM_UINT16); +PARAM_EXTERN_DAT(g_test_float, PARAM_FLOAT); +PARAM_EXTERN_DAT(g_test_double, PARAM_DOUBLE); +PARAM_EXTERN_STR(g_test_str, 10); +PARAM_EXTERN_DAT(g_test_s8, PARAM_INT8); +PARAM_EXTERN_DAT(g_test_s16, PARAM_INT16); +PARAM_EXTERN_DAT(g_test_s32, PARAM_INT32); +PARAM_EXTERN_DAT(g_test_s64, PARAM_INT64); +PARAM_EXTERN_DAT(g_test_u8, PARAM_UINT8); +PARAM_EXTERN_DAT(g_test_u16, PARAM_UINT16); +PARAM_EXTERN_DAT(g_test_u32, PARAM_UINT32); +PARAM_EXTERN_DAT(g_test_u64, PARAM_UINT64); + +void setUp(void) +{ + // Set up any necessary initialization before each test +} + +void tearDown(void) +{ + // Clean up any resources after each test +} + +void test_ParamInit(void) +{ + Param_Init(&sg_tParamManager, sg_ParamTable, PARAM_TABLE_SIZE(sg_ParamTable)); + + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable, sg_ParamTable); + TEST_ASSERT_EQUAL_UINT(sg_tParamManager.count, PARAM_TABLE_SIZE(sg_ParamTable)); + + TEST_ASSERT_EQUAL_UINT(sg_tParamManager.pParamTable[0].id, 1); + TEST_ASSERT_EQUAL_UINT(sg_tParamManager.pParamTable[0].length, 2); + TEST_ASSERT_EQUAL_UINT(sg_tParamManager.pParamTable[0].type, PARAM_INT16); + TEST_ASSERT_EQUAL_HEX8(sg_tParamManager.pParamTable[0].attr, PARAM_ATTR_WR); + TEST_ASSERT_EQUAL_STRING(sg_tParamManager.pParamTable[0].pszName, "g_test_1"); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[0].unCurValuePtr.pVoid , &PARAM_DAT_CUR_VALUE(g_test_1)); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[0].unDefValuePtr.pVoid , NULL); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[0].unMinValuePtr.pVoid , NULL); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[0].unMaxValuePtr.pVoid , NULL); + + TEST_ASSERT_EQUAL_UINT(sg_tParamManager.pParamTable[1].id, 2); + TEST_ASSERT_EQUAL_UINT(sg_tParamManager.pParamTable[1].length, 2); + TEST_ASSERT_EQUAL_UINT(sg_tParamManager.pParamTable[1].type, PARAM_UINT16); + TEST_ASSERT_EQUAL_HEX8(sg_tParamManager.pParamTable[1].attr, PARAM_ATTR_WR | PARAM_ATTR_RESET); + TEST_ASSERT_EQUAL_STRING(sg_tParamManager.pParamTable[1].pszName, "g_test_2"); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[1].unCurValuePtr.pVoid , &PARAM_DAT_CUR_VALUE(g_test_2)); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[1].unDefValuePtr.pVoid , &PARAM_DAT_DEF_VALUE(g_test_2)); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[1].unMinValuePtr.pVoid , NULL); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[1].unMaxValuePtr.pVoid , NULL); + + TEST_ASSERT_EQUAL_UINT(sg_tParamManager.pParamTable[2].id, 3); + TEST_ASSERT_EQUAL_UINT(sg_tParamManager.pParamTable[2].length, 4); + TEST_ASSERT_EQUAL_UINT(sg_tParamManager.pParamTable[2].type, PARAM_FLOAT); + TEST_ASSERT_EQUAL_HEX8(sg_tParamManager.pParamTable[2].attr, PARAM_ATTR_READ | PARAM_ATTR_RESET | PARAM_ATTR_RANGE); + TEST_ASSERT_EQUAL_STRING(sg_tParamManager.pParamTable[2].pszName, "g_test_float"); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[2].unCurValuePtr.pVoid , &PARAM_DAT_CUR_VALUE(g_test_float)); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[2].unDefValuePtr.pVoid , &PARAM_DAT_DEF_VALUE(g_test_float)); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[2].unMinValuePtr.pVoid , &PARAM_DAT_MIN_VALUE(g_test_float)); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[2].unMaxValuePtr.pVoid , &PARAM_DAT_MAX_VALUE(g_test_float)); + +#if PARAM_USE_STRING_TYPE +#if PARAM_USE_64_BIT_LENGTH + TEST_ASSERT_EQUAL_UINT(sg_tParamManager.pParamTable[4].id, 5); + TEST_ASSERT_EQUAL_UINT(sg_tParamManager.pParamTable[4].length, 10); + TEST_ASSERT_EQUAL_UINT(sg_tParamManager.pParamTable[4].type, PARAM_STRING); + TEST_ASSERT_EQUAL_HEX8(sg_tParamManager.pParamTable[4].attr, PARAM_ATTR_WR | PARAM_ATTR_RESET | PARAM_ATTR_RANGE); + TEST_ASSERT_EQUAL_STRING(sg_tParamManager.pParamTable[4].pszName, "g_test_str"); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[4].unCurValuePtr.pVoid , PARAM_STR_CUR_VALUE(g_test_str)); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[4].unDefValuePtr.pVoid , PARAM_STR_DEF_VALUE(g_test_str)); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[4].unMinValuePtr.pVoid , &PARAM_STR_MIN_LENGTH(g_test_str)); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[4].unMaxValuePtr.pVoid , &PARAM_STR_MAX_LENGTH(g_test_str)); +#else + TEST_ASSERT_EQUAL_UINT(sg_tParamManager.pParamTable[3].id, 5); + TEST_ASSERT_EQUAL_UINT(sg_tParamManager.pParamTable[3].length, 10); + TEST_ASSERT_EQUAL_UINT(sg_tParamManager.pParamTable[3].type, PARAM_STRING); + TEST_ASSERT_EQUAL_HEX8(sg_tParamManager.pParamTable[3].attr, PARAM_ATTR_WR | PARAM_ATTR_RESET | PARAM_ATTR_RANGE); + TEST_ASSERT_EQUAL_STRING(sg_tParamManager.pParamTable[3].pszName, "g_test_str"); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[3].unCurValuePtr.pVoid , PARAM_STR_CUR_VALUE(g_test_str)); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[3].unDefValuePtr.pVoid , PARAM_STR_DEF_VALUE(g_test_str)); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[3].unMinValuePtr.pVoid , &PARAM_STR_MIN_LENGTH(g_test_str)); + TEST_ASSERT_EQUAL_PTR(sg_tParamManager.pParamTable[3].unMaxValuePtr.pVoid , &PARAM_STR_MAX_LENGTH(g_test_str)); +#endif + +#endif +} + +void test_ResetParam(void) +{ + g_test_1 = 80; + g_test_2 = 50; + g_test_float = 1; +#if PARAM_USE_STRING_TYPE + sprintf(g_test_str, "ABCDFS"); +#endif + Param_ResetParam(&sg_tParamManager); + + TEST_ASSERT_EQUAL_INT(g_test_1, 80); + TEST_ASSERT_EQUAL_UINT(g_test_2, PARAM_DAT_DEF_VALUE(g_test_2)); + TEST_ASSERT_EQUAL_FLOAT(g_test_float, PARAM_DAT_DEF_VALUE(g_test_float)); +#if PARAM_USE_STRING_TYPE + TEST_ASSERT_EQUAL_STRING(g_test_str, PARAM_STR_DEF_VALUE(g_test_str)); +#endif +} + + + +// 储存空间定义 +static uint8_t sg_buf[500]; +static uint32_t sg_length = 0; + +// 从储存空间读取数据 +int OnLoadCallback(uint8_t *pBuf, uint16_t *len, bool *pisFinish) +{ + uint16_t needReadLen = *len; + static uint32_t s_offset = 0; + + if (sg_length == s_offset) + { + *len = 0; + s_offset = 0; + *pisFinish = true; + return 0; + } + else + { + *pisFinish = false; + } + + if (sg_length - s_offset < needReadLen) + { + needReadLen = sg_length - s_offset; + } + + memcpy(pBuf, &sg_buf[s_offset], needReadLen); + *len = needReadLen; + s_offset += needReadLen; + + return 0; +} + +// 写数据至储存空间 +int OnSaveCallback(const uint8_t *pBuf, uint16_t len, bool isFinish) +{ + static uint32_t s_offset = 0; + + if (isFinish) + { + s_offset = 0; + return 0; + } + + memcpy(&sg_buf[s_offset], pBuf, len); + s_offset += len; + sg_length = s_offset; + + return 0; +} + +int OnCheckErrorResetHandle(const ParamInfo_t *pParamInfo) +{ + Param_ResetDefaultValue(pParamInfo); + return 0; +} + +void test_SaveAndLoadParam(void) +{ + g_test_1 = 80; + g_test_2 = 50; + g_test_float = -20; +#if PARAM_USE_STRING_TYPE + sprintf(g_test_str, "12a"); +#endif + Param_Save(&sg_tParamManager, OnSaveCallback, NULL); + TEST_ASSERT_EQUAL_INT(g_test_1, 80); + TEST_ASSERT_EQUAL_UINT(g_test_2, 50); + TEST_ASSERT_EQUAL_FLOAT(g_test_float, -20); +#if PARAM_USE_STRING_TYPE + TEST_ASSERT_EQUAL_STRING(g_test_str, "12a"); +#endif + Param_Save(&sg_tParamManager, OnSaveCallback, OnCheckErrorResetHandle); + + TEST_ASSERT_EQUAL_INT(g_test_1, 80); + TEST_ASSERT_EQUAL_UINT(g_test_2, 50); + TEST_ASSERT_EQUAL_FLOAT(g_test_float, PARAM_DAT_DEF_VALUE(g_test_float)); +#if PARAM_USE_STRING_TYPE + TEST_ASSERT_EQUAL_STRING(g_test_str, PARAM_STR_DEF_VALUE(g_test_str)); +#endif + g_test_1 = 60; + g_test_2 = 40; + g_test_float = -20; +#if PARAM_USE_64_BIT_LENGTH + g_test_double = 5.36; +#endif +#if PARAM_USE_STRING_TYPE + sprintf(g_test_str, "12a123"); +#endif + g_test_s8 = 20; + g_test_s16 = 1000; + + Param_Load(&sg_tParamManager, OnLoadCallback, OnCheckErrorResetHandle); + + TEST_ASSERT_EQUAL_INT(g_test_1, 80); + TEST_ASSERT_EQUAL_UINT(g_test_2, 50); + TEST_ASSERT_EQUAL_FLOAT(g_test_float, PARAM_DAT_DEF_VALUE(g_test_float)); +#if PARAM_USE_STRING_TYPE + TEST_ASSERT_EQUAL_STRING(g_test_str, PARAM_STR_DEF_VALUE(g_test_str)); +#endif + TEST_ASSERT_EQUAL_INT(PARAM_DAT_DEF_VALUE(g_test_s8), g_test_s8); + TEST_ASSERT_EQUAL_INT(PARAM_DAT_DEF_VALUE(g_test_s16), g_test_s16); + TEST_ASSERT_EQUAL_INT(PARAM_DAT_DEF_VALUE(g_test_u16), g_test_u16); + TEST_ASSERT_EQUAL_INT(PARAM_DAT_DEF_VALUE(g_test_u32), g_test_u32); +} + +void test_IterateParam(void) +{ + size_t idx = 0; + ParamInfo_t *paramInfo; + size_t cnt = 0; + + do + { + paramInfo = Param_IterateList(&sg_tParamManager, &idx); + + if (paramInfo != NULL) + { + cnt++; + } + + } while (paramInfo != NULL); + + TEST_ASSERT_EQUAL_UINT((PARAM_TABLE_SIZE(sg_ParamTable) - 1), cnt); +} + + +void test_FindParam(void) +{ + const ParamInfo_t *paramInfo; +#if PARAM_USE_64_BIT_LENGTH + paramInfo = Param_FindParamByName(&sg_tParamManager, "g_test_double"); + TEST_ASSERT_EQUAL_PTR(&sg_ParamTable[3], paramInfo); +#endif + paramInfo = Param_FindParamByID(&sg_tParamManager, 3); + TEST_ASSERT_EQUAL_PTR(&sg_ParamTable[2], paramInfo); + + paramInfo = Param_FindParamByParamPtr(&sg_tParamManager, &g_test_float); + TEST_ASSERT_EQUAL_PTR(&sg_ParamTable[2], paramInfo); + + paramInfo = Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u32); + TEST_ASSERT_EQUAL_PTR(NULL, paramInfo); +} + +void test_CheckRange(void) +{ + g_test_u16 = 60; + TEST_ASSERT_EQUAL_INT(1, Param_CheckRange(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), PARAM_NONE)); + g_test_u16 = 120; + TEST_ASSERT_EQUAL_INT(0, Param_CheckRange(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), PARAM_NONE)); + g_test_u16 = 4000; + TEST_ASSERT_EQUAL_INT(2, Param_CheckRange(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), PARAM_NONE)); + + g_test_u16 = 60; + TEST_ASSERT_EQUAL_INT(1, Param_CheckRange(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), PARAM_DEF)); + TEST_ASSERT_EQUAL_UINT(100, PARAM_DAT_CUR_VALUE(g_test_u16)); + g_test_u16 = 4000; + TEST_ASSERT_EQUAL_INT(2, Param_CheckRange(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), PARAM_DEF)); + TEST_ASSERT_EQUAL_UINT(100, PARAM_DAT_CUR_VALUE(g_test_u16)); + + g_test_u16 = 60; + TEST_ASSERT_EQUAL_INT(1, Param_CheckRange(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), PARAM_MIN_MAX)); + TEST_ASSERT_EQUAL_UINT(100, PARAM_DAT_CUR_VALUE(g_test_u16)); + g_test_u16 = 4000; + TEST_ASSERT_EQUAL_INT(2, Param_CheckRange(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), PARAM_MIN_MAX)); + TEST_ASSERT_EQUAL_UINT(3000, PARAM_DAT_CUR_VALUE(g_test_u16)); + +#if PARAM_USE_STRING_TYPE + snprintf(g_test_str, sizeof(g_test_str), "ABCDEF"); + TEST_ASSERT_EQUAL_INT(0, Param_CheckRange(Param_FindParamByParamPtr(&sg_tParamManager, g_test_str), PARAM_NONE)); + TEST_ASSERT_EQUAL_STRING("ABCDEF", g_test_str); + snprintf(g_test_str, sizeof(g_test_str), "AB"); + TEST_ASSERT_EQUAL_INT(1, Param_CheckRange(Param_FindParamByParamPtr(&sg_tParamManager, g_test_str), PARAM_MIN_MAX)); + TEST_ASSERT_EQUAL_STRING("AB", g_test_str); + snprintf(g_test_str, sizeof(g_test_str), "abcdefg123456"); + TEST_ASSERT_EQUAL_INT(0, Param_CheckRange(Param_FindParamByParamPtr(&sg_tParamManager, g_test_str), PARAM_MIN_MAX)); + TEST_ASSERT_EQUAL_STRING("abcdefg12", g_test_str); + snprintf(g_test_str, sizeof(g_test_str), "AB"); + TEST_ASSERT_EQUAL_INT(1, Param_CheckRange(Param_FindParamByParamPtr(&sg_tParamManager, g_test_str), PARAM_DEF)); + TEST_ASSERT_EQUAL_STRING("abcdef", g_test_str); +#endif +} + +void test_CheckRangeMacroDefine(void) +{ + g_test_u16 = 60; + TEST_ASSERT_EQUAL_INT(1, PARAM_DAT_CHECK_RANGE(g_test_u16, PARAM_NONE)); + g_test_u16 = 120; + TEST_ASSERT_EQUAL_INT(0, PARAM_DAT_CHECK_RANGE(g_test_u16, PARAM_NONE)); + g_test_u16 = 4000; + TEST_ASSERT_EQUAL_INT(2, PARAM_DAT_CHECK_RANGE(g_test_u16, PARAM_NONE)); + + g_test_u16 = 60; + TEST_ASSERT_EQUAL_INT(1, PARAM_DAT_CHECK_RANGE(g_test_u16, PARAM_DEF)); + TEST_ASSERT_EQUAL_UINT(100, PARAM_DAT_CUR_VALUE(g_test_u16)); + g_test_u16 = 4000; + TEST_ASSERT_EQUAL_INT(2, PARAM_DAT_CHECK_RANGE(g_test_u16, PARAM_DEF)); + TEST_ASSERT_EQUAL_UINT(100, PARAM_DAT_CUR_VALUE(g_test_u16)); + + g_test_u16 = 60; + TEST_ASSERT_EQUAL_INT(1, PARAM_DAT_CHECK_RANGE(g_test_u16, PARAM_MIN_MAX)); + TEST_ASSERT_EQUAL_UINT(100, PARAM_DAT_CUR_VALUE(g_test_u16)); + g_test_u16 = 4000; + TEST_ASSERT_EQUAL_INT(2, PARAM_DAT_CHECK_RANGE(g_test_u16, PARAM_MIN_MAX)); + TEST_ASSERT_EQUAL_UINT(3000, PARAM_DAT_CUR_VALUE(g_test_u16)); + +#if PARAM_USE_STRING_TYPE + snprintf(g_test_str, sizeof(g_test_str), "ABCDEF"); + TEST_ASSERT_EQUAL_INT(0, PARAM_STR_CHECK_RANGE(g_test_str, PARAM_NONE)); + TEST_ASSERT_EQUAL_STRING("ABCDEF", g_test_str); + snprintf(g_test_str, sizeof(g_test_str), "AB"); + TEST_ASSERT_EQUAL_INT(1, PARAM_STR_CHECK_RANGE(g_test_str, PARAM_MIN_MAX)); + TEST_ASSERT_EQUAL_STRING("AB", g_test_str); + snprintf(g_test_str, sizeof(g_test_str), "abcdefg123456"); + TEST_ASSERT_EQUAL_INT(0, PARAM_STR_CHECK_RANGE(g_test_str, PARAM_MIN_MAX)); + TEST_ASSERT_EQUAL_STRING("abcdefg12", g_test_str); + snprintf(g_test_str, sizeof(g_test_str), "AB"); + TEST_ASSERT_EQUAL_INT(1, PARAM_STR_CHECK_RANGE(g_test_str, PARAM_DEF)); + TEST_ASSERT_EQUAL_STRING("abcdef", g_test_str); +#endif +} + +void test_SetNewValue(void) +{ + PARAM_UINT16_T tmp = 60; + tmp = 60; + TEST_ASSERT_EQUAL_INT(1, Param_SetNewValue(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), &tmp, PARAM_NONE)); + tmp = 120; + TEST_ASSERT_EQUAL_INT(0, Param_SetNewValue(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), &tmp, PARAM_NONE)); + tmp = 4000; + TEST_ASSERT_EQUAL_INT(2, Param_SetNewValue(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), &tmp, PARAM_NONE)); + + tmp = 60; + TEST_ASSERT_EQUAL_INT(1, Param_SetNewValue(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), &tmp, PARAM_DEF)); + TEST_ASSERT_EQUAL_UINT(100, PARAM_DAT_CUR_VALUE(g_test_u16)); + tmp = 4000; + TEST_ASSERT_EQUAL_INT(2, Param_SetNewValue(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), &tmp, PARAM_DEF)); + TEST_ASSERT_EQUAL_UINT(100, PARAM_DAT_CUR_VALUE(g_test_u16)); + + tmp = 60; + TEST_ASSERT_EQUAL_INT(1, Param_SetNewValue(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), &tmp, PARAM_MIN_MAX)); + TEST_ASSERT_EQUAL_UINT(100, PARAM_DAT_CUR_VALUE(g_test_u16)); + tmp = 4000; + TEST_ASSERT_EQUAL_INT(2, Param_SetNewValue(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16), &tmp, PARAM_MIN_MAX)); + TEST_ASSERT_EQUAL_UINT(3000, PARAM_DAT_CUR_VALUE(g_test_u16)); + +#if PARAM_USE_STRING_TYPE + TEST_ASSERT_EQUAL_INT(0, Param_SetNewValue(Param_FindParamByParamPtr(&sg_tParamManager, g_test_str), "ABCDEF", PARAM_NONE)); + TEST_ASSERT_EQUAL_STRING("ABCDEF", g_test_str); + TEST_ASSERT_EQUAL_INT(1, Param_SetNewValue(Param_FindParamByParamPtr(&sg_tParamManager, g_test_str), "AB", PARAM_MIN_MAX)); + TEST_ASSERT_EQUAL_STRING("ABCDEF", g_test_str); + TEST_ASSERT_EQUAL_INT(2, Param_SetNewValue(Param_FindParamByParamPtr(&sg_tParamManager, g_test_str), "abcdefg123456", PARAM_MIN_MAX)); + TEST_ASSERT_EQUAL_STRING("ABCDEF", g_test_str); + TEST_ASSERT_EQUAL_INT(2, Param_SetNewValue(Param_FindParamByParamPtr(&sg_tParamManager, g_test_str), "abcdefg123456", PARAM_DEF)); + TEST_ASSERT_EQUAL_STRING("abcdef", g_test_str); +#endif +} + +void test_SetNewValueMacroDefine(void) +{ + PARAM_UINT16_T tmp = 60; + tmp = 60; + TEST_ASSERT_EQUAL_INT(1, PARAM_DAT_SET_NEW_VALUE(g_test_u16, tmp, PARAM_NONE)); + tmp = 120; + TEST_ASSERT_EQUAL_INT(0, PARAM_DAT_SET_NEW_VALUE(g_test_u16, tmp, PARAM_NONE)); + tmp = 4000; + TEST_ASSERT_EQUAL_INT(2, PARAM_DAT_SET_NEW_VALUE(g_test_u16, tmp, PARAM_NONE)); + + tmp = 60; + TEST_ASSERT_EQUAL_INT(1, PARAM_DAT_SET_NEW_VALUE(g_test_u16, tmp, PARAM_DEF)); + TEST_ASSERT_EQUAL_UINT(100, PARAM_DAT_CUR_VALUE(g_test_u16)); + tmp = 4000; + TEST_ASSERT_EQUAL_INT(2, PARAM_DAT_SET_NEW_VALUE(g_test_u16, tmp, PARAM_DEF)); + TEST_ASSERT_EQUAL_UINT(100, PARAM_DAT_CUR_VALUE(g_test_u16)); + + tmp = 60; + TEST_ASSERT_EQUAL_INT(1, PARAM_DAT_SET_NEW_VALUE(g_test_u16, tmp, PARAM_MIN_MAX)); + TEST_ASSERT_EQUAL_UINT(100, PARAM_DAT_CUR_VALUE(g_test_u16)); + tmp = 4000; + TEST_ASSERT_EQUAL_INT(2, PARAM_DAT_SET_NEW_VALUE(g_test_u16, tmp, PARAM_MIN_MAX)); + TEST_ASSERT_EQUAL_UINT(3000, PARAM_DAT_CUR_VALUE(g_test_u16)); + +#if PARAM_USE_STRING_TYPE + TEST_ASSERT_EQUAL_INT(0, PARAM_STR_SET_NEW_VALUE(g_test_str, "ABCDEF", PARAM_NONE)); + TEST_ASSERT_EQUAL_STRING("ABCDEF", g_test_str); + TEST_ASSERT_EQUAL_INT(1, PARAM_STR_SET_NEW_VALUE(g_test_str, "AB", PARAM_MIN_MAX)); + TEST_ASSERT_EQUAL_STRING("ABCDEF", g_test_str); + TEST_ASSERT_EQUAL_INT(2, PARAM_STR_SET_NEW_VALUE(g_test_str, "abcdefg123456", PARAM_MIN_MAX)); + TEST_ASSERT_EQUAL_STRING("ABCDEF", g_test_str); + TEST_ASSERT_EQUAL_INT(2, PARAM_STR_SET_NEW_VALUE(g_test_str, "abcdefg123456", PARAM_DEF)); + TEST_ASSERT_EQUAL_STRING("abcdef", g_test_str); +#endif +} + +void test_ResetValue(void) +{ + g_test_u16 = 500; + + TEST_ASSERT_TRUE(Param_ResetDefaultValue(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16))); + TEST_ASSERT_EQUAL_UINT(100, g_test_u16); + + TEST_ASSERT_TRUE(Param_ResetMinValue(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16))); + TEST_ASSERT_EQUAL_UINT(100, g_test_u16); + + TEST_ASSERT_TRUE(Param_ResetMaxValue(Param_FindParamByParamPtr(&sg_tParamManager, &g_test_u16))); + TEST_ASSERT_EQUAL_UINT(3000, g_test_u16); +} + +// Run the test suite +int main(void) +{ + UNITY_BEGIN(); + RUN_TEST(test_ParamInit); + RUN_TEST(test_ResetParam); + RUN_TEST(test_SaveAndLoadParam); + RUN_TEST(test_IterateParam); + RUN_TEST(test_FindParam); + RUN_TEST(test_CheckRange); + RUN_TEST(test_CheckRangeMacroDefine); + RUN_TEST(test_SetNewValue); + RUN_TEST(test_SetNewValueMacroDefine); + RUN_TEST(test_ResetValue); + + UNITY_END(); + + return 0; +} \ No newline at end of file diff --git a/test/unity/unity.c b/test/unity/unity.c new file mode 100644 index 0000000000000000000000000000000000000000..3e4bc04d6985a9bae5f6b8b09dffb724cc811764 --- /dev/null +++ b/test/unity/unity.c @@ -0,0 +1,2466 @@ +/* ========================================================================= + Unity Project - A Test Framework for C + Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +============================================================================ */ + +#include "unity.h" + +#ifndef UNITY_PROGMEM +#define UNITY_PROGMEM +#endif + +/* If omitted from header, declare overrideable prototypes here so they're ready for use */ +#ifdef UNITY_OMIT_OUTPUT_CHAR_HEADER_DECLARATION +void UNITY_OUTPUT_CHAR(int); +#endif + +/* Helpful macros for us to use here in Assert functions */ +#define UNITY_FAIL_AND_BAIL do { Unity.CurrentTestFailed = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } while (0) +#define UNITY_IGNORE_AND_BAIL do { Unity.CurrentTestIgnored = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } while (0) +#define RETURN_IF_FAIL_OR_IGNORE do { if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) { TEST_ABORT(); } } while (0) + +struct UNITY_STORAGE_T Unity; + +#ifdef UNITY_OUTPUT_COLOR +const char UNITY_PROGMEM UnityStrOk[] = "\033[42mOK\033[0m"; +const char UNITY_PROGMEM UnityStrPass[] = "\033[42mPASS\033[0m"; +const char UNITY_PROGMEM UnityStrFail[] = "\033[41mFAIL\033[0m"; +const char UNITY_PROGMEM UnityStrIgnore[] = "\033[43mIGNORE\033[0m"; +#else +const char UNITY_PROGMEM UnityStrOk[] = "OK"; +const char UNITY_PROGMEM UnityStrPass[] = "PASS"; +const char UNITY_PROGMEM UnityStrFail[] = "FAIL"; +const char UNITY_PROGMEM UnityStrIgnore[] = "IGNORE"; +#endif +static const char UNITY_PROGMEM UnityStrNull[] = "NULL"; +static const char UNITY_PROGMEM UnityStrSpacer[] = ". "; +static const char UNITY_PROGMEM UnityStrExpected[] = " Expected "; +static const char UNITY_PROGMEM UnityStrWas[] = " Was "; +static const char UNITY_PROGMEM UnityStrGt[] = " to be greater than "; +static const char UNITY_PROGMEM UnityStrLt[] = " to be less than "; +static const char UNITY_PROGMEM UnityStrOrEqual[] = "or equal to "; +static const char UNITY_PROGMEM UnityStrNotEqual[] = " to be not equal to "; +static const char UNITY_PROGMEM UnityStrElement[] = " Element "; +static const char UNITY_PROGMEM UnityStrByte[] = " Byte "; +static const char UNITY_PROGMEM UnityStrMemory[] = " Memory Mismatch."; +static const char UNITY_PROGMEM UnityStrDelta[] = " Values Not Within Delta "; +static const char UNITY_PROGMEM UnityStrPointless[] = " You Asked Me To Compare Nothing, Which Was Pointless."; +static const char UNITY_PROGMEM UnityStrNullPointerForExpected[] = " Expected pointer to be NULL"; +static const char UNITY_PROGMEM UnityStrNullPointerForActual[] = " Actual pointer was NULL"; +#ifndef UNITY_EXCLUDE_FLOAT +static const char UNITY_PROGMEM UnityStrNot[] = "Not "; +static const char UNITY_PROGMEM UnityStrInf[] = "Infinity"; +static const char UNITY_PROGMEM UnityStrNegInf[] = "Negative Infinity"; +static const char UNITY_PROGMEM UnityStrNaN[] = "NaN"; +static const char UNITY_PROGMEM UnityStrDet[] = "Determinate"; +static const char UNITY_PROGMEM UnityStrInvalidFloatTrait[] = "Invalid Float Trait"; +#endif +const char UNITY_PROGMEM UnityStrErrShorthand[] = "Unity Shorthand Support Disabled"; +const char UNITY_PROGMEM UnityStrErrFloat[] = "Unity Floating Point Disabled"; +const char UNITY_PROGMEM UnityStrErrDouble[] = "Unity Double Precision Disabled"; +const char UNITY_PROGMEM UnityStrErr64[] = "Unity 64-bit Support Disabled"; +static const char UNITY_PROGMEM UnityStrBreaker[] = "-----------------------"; +static const char UNITY_PROGMEM UnityStrResultsTests[] = " Tests "; +static const char UNITY_PROGMEM UnityStrResultsFailures[] = " Failures "; +static const char UNITY_PROGMEM UnityStrResultsIgnored[] = " Ignored "; +#ifndef UNITY_EXCLUDE_DETAILS +static const char UNITY_PROGMEM UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " "; +static const char UNITY_PROGMEM UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " "; +#endif +/*----------------------------------------------- + * Pretty Printers & Test Result Output Handlers + *-----------------------------------------------*/ + +/*-----------------------------------------------*/ +/* Local helper function to print characters. */ +static void UnityPrintChar(const char* pch) +{ + /* printable characters plus CR & LF are printed */ + if ((*pch <= 126) && (*pch >= 32)) + { + UNITY_OUTPUT_CHAR(*pch); + } + /* write escaped carriage returns */ + else if (*pch == 13) + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('r'); + } + /* write escaped line feeds */ + else if (*pch == 10) + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('n'); + } + /* unprintable characters are shown as codes */ + else + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('x'); + UnityPrintNumberHex((UNITY_UINT)*pch, 2); + } +} + +/*-----------------------------------------------*/ +/* Local helper function to print ANSI escape strings e.g. "\033[42m". */ +#ifdef UNITY_OUTPUT_COLOR +static UNITY_UINT UnityPrintAnsiEscapeString(const char* string) +{ + const char* pch = string; + UNITY_UINT count = 0; + + while (*pch && (*pch != 'm')) + { + UNITY_OUTPUT_CHAR(*pch); + pch++; + count++; + } + UNITY_OUTPUT_CHAR('m'); + count++; + + return count; +} +#endif + +/*-----------------------------------------------*/ +void UnityPrint(const char* string) +{ + const char* pch = string; + + if (pch != NULL) + { + while (*pch) + { +#ifdef UNITY_OUTPUT_COLOR + /* print ANSI escape code */ + if ((*pch == 27) && (*(pch + 1) == '[')) + { + pch += UnityPrintAnsiEscapeString(pch); + continue; + } +#endif + UnityPrintChar(pch); + pch++; + } + } +} +/*-----------------------------------------------*/ +void UnityPrintLen(const char* string, const UNITY_UINT32 length) +{ + const char* pch = string; + + if (pch != NULL) + { + while (*pch && ((UNITY_UINT32)(pch - string) < length)) + { + /* printable characters plus CR & LF are printed */ + if ((*pch <= 126) && (*pch >= 32)) + { + UNITY_OUTPUT_CHAR(*pch); + } + /* write escaped carriage returns */ + else if (*pch == 13) + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('r'); + } + /* write escaped line feeds */ + else if (*pch == 10) + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('n'); + } + /* unprintable characters are shown as codes */ + else + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('x'); + UnityPrintNumberHex((UNITY_UINT)*pch, 2); + } + pch++; + } + } +} + +/*-----------------------------------------------*/ +void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style) +{ + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + { + if (style == UNITY_DISPLAY_STYLE_CHAR) + { + /* printable characters plus CR & LF are printed */ + UNITY_OUTPUT_CHAR('\''); + if ((number <= 126) && (number >= 32)) + { + UNITY_OUTPUT_CHAR((int)number); + } + /* write escaped carriage returns */ + else if (number == 13) + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('r'); + } + /* write escaped line feeds */ + else if (number == 10) + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('n'); + } + /* unprintable characters are shown as codes */ + else + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('x'); + UnityPrintNumberHex((UNITY_UINT)number, 2); + } + UNITY_OUTPUT_CHAR('\''); + } + else + { + UnityPrintNumber(number); + } + } + else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT) + { + UnityPrintNumberUnsigned((UNITY_UINT)number); + } + else + { + UNITY_OUTPUT_CHAR('0'); + UNITY_OUTPUT_CHAR('x'); + UnityPrintNumberHex((UNITY_UINT)number, (char)((style & 0xF) * 2)); + } +} + +/*-----------------------------------------------*/ +void UnityPrintNumber(const UNITY_INT number_to_print) +{ + UNITY_UINT number = (UNITY_UINT)number_to_print; + + if (number_to_print < 0) + { + /* A negative number, including MIN negative */ + UNITY_OUTPUT_CHAR('-'); + number = (~number) + 1; + } + UnityPrintNumberUnsigned(number); +} + +/*----------------------------------------------- + * basically do an itoa using as little ram as possible */ +void UnityPrintNumberUnsigned(const UNITY_UINT number) +{ + UNITY_UINT divisor = 1; + + /* figure out initial divisor */ + while (number / divisor > 9) + { + divisor *= 10; + } + + /* now mod and print, then divide divisor */ + do + { + UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10))); + divisor /= 10; + } while (divisor > 0); +} + +/*-----------------------------------------------*/ +void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print) +{ + int nibble; + char nibbles = nibbles_to_print; + + if ((unsigned)nibbles > UNITY_MAX_NIBBLES) + { + nibbles = UNITY_MAX_NIBBLES; + } + + while (nibbles > 0) + { + nibbles--; + nibble = (int)(number >> (nibbles * 4)) & 0x0F; + if (nibble <= 9) + { + UNITY_OUTPUT_CHAR((char)('0' + nibble)); + } + else + { + UNITY_OUTPUT_CHAR((char)('A' - 10 + nibble)); + } + } +} + +/*-----------------------------------------------*/ +void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number) +{ + UNITY_UINT current_bit = (UNITY_UINT)1 << (UNITY_INT_WIDTH - 1); + UNITY_INT32 i; + + for (i = 0; i < UNITY_INT_WIDTH; i++) + { + if (current_bit & mask) + { + if (current_bit & number) + { + UNITY_OUTPUT_CHAR('1'); + } + else + { + UNITY_OUTPUT_CHAR('0'); + } + } + else + { + UNITY_OUTPUT_CHAR('X'); + } + current_bit = current_bit >> 1; + } +} + +/*-----------------------------------------------*/ +#ifndef UNITY_EXCLUDE_FLOAT_PRINT +/* + * This function prints a floating-point value in a format similar to + * printf("%.7g") on a single-precision machine or printf("%.9g") on a + * double-precision machine. The 7th digit won't always be totally correct + * in single-precision operation (for that level of accuracy, a more + * complicated algorithm would be needed). + */ +void UnityPrintFloat(const UNITY_DOUBLE input_number) +{ +#ifdef UNITY_INCLUDE_DOUBLE + static const int sig_digits = 9; + static const UNITY_INT32 min_scaled = 100000000; + static const UNITY_INT32 max_scaled = 1000000000; +#else + static const int sig_digits = 7; + static const UNITY_INT32 min_scaled = 1000000; + static const UNITY_INT32 max_scaled = 10000000; +#endif + + UNITY_DOUBLE number = input_number; + + /* print minus sign (does not handle negative zero) */ + if (number < 0.0f) + { + UNITY_OUTPUT_CHAR('-'); + number = -number; + } + + /* handle zero, NaN, and +/- infinity */ + if (number == 0.0f) + { + UnityPrint("0"); + } + else if (isnan(number)) + { + UnityPrint("nan"); + } + else if (isinf(number)) + { + UnityPrint("inf"); + } + else + { + UNITY_INT32 n_int = 0; + UNITY_INT32 n; + int exponent = 0; + int decimals; + int digits; + char buf[16] = {0}; + + /* + * Scale up or down by powers of 10. To minimize rounding error, + * start with a factor/divisor of 10^10, which is the largest + * power of 10 that can be represented exactly. Finally, compute + * (exactly) the remaining power of 10 and perform one more + * multiplication or division. + */ + if (number < 1.0f) + { + UNITY_DOUBLE factor = 1.0f; + + while (number < (UNITY_DOUBLE)max_scaled / 1e10f) { number *= 1e10f; exponent -= 10; } + while (number * factor < (UNITY_DOUBLE)min_scaled) { factor *= 10.0f; exponent--; } + + number *= factor; + } + else if (number > (UNITY_DOUBLE)max_scaled) + { + UNITY_DOUBLE divisor = 1.0f; + + while (number > (UNITY_DOUBLE)min_scaled * 1e10f) { number /= 1e10f; exponent += 10; } + while (number / divisor > (UNITY_DOUBLE)max_scaled) { divisor *= 10.0f; exponent++; } + + number /= divisor; + } + else + { + /* + * In this range, we can split off the integer part before + * doing any multiplications. This reduces rounding error by + * freeing up significant bits in the fractional part. + */ + UNITY_DOUBLE factor = 1.0f; + n_int = (UNITY_INT32)number; + number -= (UNITY_DOUBLE)n_int; + + while (n_int < min_scaled) { n_int *= 10; factor *= 10.0f; exponent--; } + + number *= factor; + } + + /* round to nearest integer */ + n = ((UNITY_INT32)(number + number) + 1) / 2; + +#ifndef UNITY_ROUND_TIES_AWAY_FROM_ZERO + /* round to even if exactly between two integers */ + if ((n & 1) && (((UNITY_DOUBLE)n - number) == 0.5f)) + n--; +#endif + + n += n_int; + + if (n >= max_scaled) + { + n = min_scaled; + exponent++; + } + + /* determine where to place decimal point */ + decimals = ((exponent <= 0) && (exponent >= -(sig_digits + 3))) ? (-exponent) : (sig_digits - 1); + exponent += decimals; + + /* truncate trailing zeroes after decimal point */ + while ((decimals > 0) && ((n % 10) == 0)) + { + n /= 10; + decimals--; + } + + /* build up buffer in reverse order */ + digits = 0; + while ((n != 0) || (digits <= decimals)) + { + buf[digits++] = (char)('0' + n % 10); + n /= 10; + } + + /* print out buffer (backwards) */ + while (digits > 0) + { + if (digits == decimals) + { + UNITY_OUTPUT_CHAR('.'); + } + UNITY_OUTPUT_CHAR(buf[--digits]); + } + + /* print exponent if needed */ + if (exponent != 0) + { + UNITY_OUTPUT_CHAR('e'); + + if (exponent < 0) + { + UNITY_OUTPUT_CHAR('-'); + exponent = -exponent; + } + else + { + UNITY_OUTPUT_CHAR('+'); + } + + digits = 0; + while ((exponent != 0) || (digits < 2)) + { + buf[digits++] = (char)('0' + exponent % 10); + exponent /= 10; + } + while (digits > 0) + { + UNITY_OUTPUT_CHAR(buf[--digits]); + } + } + } +} +#endif /* ! UNITY_EXCLUDE_FLOAT_PRINT */ + +/*-----------------------------------------------*/ +static void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line) +{ +#ifdef UNITY_OUTPUT_FOR_ECLIPSE + UNITY_OUTPUT_CHAR('('); + UnityPrint(file); + UNITY_OUTPUT_CHAR(':'); + UnityPrintNumber((UNITY_INT)line); + UNITY_OUTPUT_CHAR(')'); + UNITY_OUTPUT_CHAR(' '); + UnityPrint(Unity.CurrentTestName); + UNITY_OUTPUT_CHAR(':'); +#else +#ifdef UNITY_OUTPUT_FOR_IAR_WORKBENCH + UnityPrint("'); + UnityPrint(Unity.CurrentTestName); + UnityPrint(" "); +#else +#ifdef UNITY_OUTPUT_FOR_QT_CREATOR + UnityPrint("file://"); + UnityPrint(file); + UNITY_OUTPUT_CHAR(':'); + UnityPrintNumber((UNITY_INT)line); + UNITY_OUTPUT_CHAR(' '); + UnityPrint(Unity.CurrentTestName); + UNITY_OUTPUT_CHAR(':'); +#else + UnityPrint(file); + UNITY_OUTPUT_CHAR(':'); + UnityPrintNumber((UNITY_INT)line); + UNITY_OUTPUT_CHAR(':'); + UnityPrint(Unity.CurrentTestName); + UNITY_OUTPUT_CHAR(':'); +#endif +#endif +#endif +} + +/*-----------------------------------------------*/ +static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line) +{ + UnityTestResultsBegin(Unity.TestFile, line); + UnityPrint(UnityStrFail); + UNITY_OUTPUT_CHAR(':'); +} + +/*-----------------------------------------------*/ +void UnityConcludeTest(void) +{ + if (Unity.CurrentTestIgnored) + { + Unity.TestIgnores++; + } + else if (!Unity.CurrentTestFailed) + { + UnityTestResultsBegin(Unity.TestFile, Unity.CurrentTestLineNumber); + UnityPrint(UnityStrPass); + } + else + { + Unity.TestFailures++; + } + + Unity.CurrentTestFailed = 0; + Unity.CurrentTestIgnored = 0; + UNITY_PRINT_EXEC_TIME(); + UNITY_PRINT_EOL(); + UNITY_FLUSH_CALL(); +} + +/*-----------------------------------------------*/ +static void UnityAddMsgIfSpecified(const char* msg) +{ +#ifdef UNITY_PRINT_TEST_CONTEXT + UnityPrint(UnityStrSpacer); + UNITY_PRINT_TEST_CONTEXT(); +#endif +#ifndef UNITY_EXCLUDE_DETAILS + if (Unity.CurrentDetail1) + { + UnityPrint(UnityStrSpacer); + UnityPrint(UnityStrDetail1Name); + UnityPrint(Unity.CurrentDetail1); + if (Unity.CurrentDetail2) + { + UnityPrint(UnityStrDetail2Name); + UnityPrint(Unity.CurrentDetail2); + } + } +#endif + if (msg) + { + UnityPrint(UnityStrSpacer); + UnityPrint(msg); + } +} + +/*-----------------------------------------------*/ +static void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual) +{ + UnityPrint(UnityStrExpected); + if (expected != NULL) + { + UNITY_OUTPUT_CHAR('\''); + UnityPrint(expected); + UNITY_OUTPUT_CHAR('\''); + } + else + { + UnityPrint(UnityStrNull); + } + UnityPrint(UnityStrWas); + if (actual != NULL) + { + UNITY_OUTPUT_CHAR('\''); + UnityPrint(actual); + UNITY_OUTPUT_CHAR('\''); + } + else + { + UnityPrint(UnityStrNull); + } +} + +/*-----------------------------------------------*/ +static void UnityPrintExpectedAndActualStringsLen(const char* expected, + const char* actual, + const UNITY_UINT32 length) +{ + UnityPrint(UnityStrExpected); + if (expected != NULL) + { + UNITY_OUTPUT_CHAR('\''); + UnityPrintLen(expected, length); + UNITY_OUTPUT_CHAR('\''); + } + else + { + UnityPrint(UnityStrNull); + } + UnityPrint(UnityStrWas); + if (actual != NULL) + { + UNITY_OUTPUT_CHAR('\''); + UnityPrintLen(actual, length); + UNITY_OUTPUT_CHAR('\''); + } + else + { + UnityPrint(UnityStrNull); + } +} + +/*----------------------------------------------- + * Assertion & Control Helpers + *-----------------------------------------------*/ + +/*-----------------------------------------------*/ +static int UnityIsOneArrayNull(UNITY_INTERNAL_PTR expected, + UNITY_INTERNAL_PTR actual, + const UNITY_LINE_TYPE lineNumber, + const char* msg) +{ + /* Both are NULL or same pointer */ + if (expected == actual) { return 0; } + + /* print and return true if just expected is NULL */ + if (expected == NULL) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrNullPointerForExpected); + UnityAddMsgIfSpecified(msg); + return 1; + } + + /* print and return true if just actual is NULL */ + if (actual == NULL) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrNullPointerForActual); + UnityAddMsgIfSpecified(msg); + return 1; + } + + return 0; /* return false if neither is NULL */ +} + +/*----------------------------------------------- + * Assertion Functions + *-----------------------------------------------*/ + +/*-----------------------------------------------*/ +void UnityAssertBits(const UNITY_INT mask, + const UNITY_INT expected, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + RETURN_IF_FAIL_OR_IGNORE; + + if ((mask & expected) != (mask & actual)) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintMask((UNITY_UINT)mask, (UNITY_UINT)expected); + UnityPrint(UnityStrWas); + UnityPrintMask((UNITY_UINT)mask, (UNITY_UINT)actual); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertEqualNumber(const UNITY_INT expected, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style) +{ + RETURN_IF_FAIL_OR_IGNORE; + + if (expected != actual) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintNumberByStyle(expected, style); + UnityPrint(UnityStrWas); + UnityPrintNumberByStyle(actual, style); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, + const UNITY_INT actual, + const UNITY_COMPARISON_T compare, + const char *msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style) +{ + int failed = 0; + RETURN_IF_FAIL_OR_IGNORE; + + if ((threshold == actual) && (compare & UNITY_EQUAL_TO)) { return; } + if ((threshold == actual)) { failed = 1; } + + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + { + if ((actual > threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } + if ((actual < threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } + } + else /* UINT or HEX */ + { + if (((UNITY_UINT)actual > (UNITY_UINT)threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } + if (((UNITY_UINT)actual < (UNITY_UINT)threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } + } + + if (failed) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintNumberByStyle(actual, style); + if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); } + if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); } + if (compare & UNITY_EQUAL_TO) { UnityPrint(UnityStrOrEqual); } + if (compare == UNITY_NOT_EQUAL) { UnityPrint(UnityStrNotEqual); } + UnityPrintNumberByStyle(threshold, style); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +#define UnityPrintPointlessAndBail() \ +do { \ + UnityTestResultsFailBegin(lineNumber); \ + UnityPrint(UnityStrPointless); \ + UnityAddMsgIfSpecified(msg); \ + UNITY_FAIL_AND_BAIL; \ +} while (0) + +/*-----------------------------------------------*/ +void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, + UNITY_INTERNAL_PTR actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style, + const UNITY_FLAGS_T flags) +{ + UNITY_UINT32 elements = num_elements; + unsigned int length = style & 0xF; + unsigned int increment = 0; + + RETURN_IF_FAIL_OR_IGNORE; + + if (num_elements == 0) + { +#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY + UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg); +#else + UnityPrintPointlessAndBail(); +#endif + } + + if (expected == actual) + { + return; /* Both are NULL or same pointer */ + } + + if (UnityIsOneArrayNull(expected, actual, lineNumber, msg)) + { + UNITY_FAIL_AND_BAIL; + } + + while ((elements > 0) && (elements--)) + { + UNITY_INT expect_val; + UNITY_INT actual_val; + + switch (length) + { + case 1: + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)actual; + if (style & (UNITY_DISPLAY_RANGE_UINT | UNITY_DISPLAY_RANGE_HEX)) + { + expect_val &= 0x000000FF; + actual_val &= 0x000000FF; + } + increment = sizeof(UNITY_INT8); + break; + + case 2: + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)actual; + if (style & (UNITY_DISPLAY_RANGE_UINT | UNITY_DISPLAY_RANGE_HEX)) + { + expect_val &= 0x0000FFFF; + actual_val &= 0x0000FFFF; + } + increment = sizeof(UNITY_INT16); + break; + +#ifdef UNITY_SUPPORT_64 + case 8: + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)actual; + increment = sizeof(UNITY_INT64); + break; +#endif + + default: /* default is length 4 bytes */ + case 4: + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; +#ifdef UNITY_SUPPORT_64 + if (style & (UNITY_DISPLAY_RANGE_UINT | UNITY_DISPLAY_RANGE_HEX)) + { + expect_val &= 0x00000000FFFFFFFF; + actual_val &= 0x00000000FFFFFFFF; + } +#endif + increment = sizeof(UNITY_INT32); + length = 4; + break; + } + + if (expect_val != actual_val) + { + if ((style & UNITY_DISPLAY_RANGE_UINT) && (length < (UNITY_INT_WIDTH / 8))) + { /* For UINT, remove sign extension (padding 1's) from signed type casts above */ + UNITY_INT mask = 1; + mask = (mask << 8 * length) - 1; + expect_val &= mask; + actual_val &= mask; + } + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrElement); + UnityPrintNumberUnsigned(num_elements - elements - 1); + UnityPrint(UnityStrExpected); + UnityPrintNumberByStyle(expect_val, style); + UnityPrint(UnityStrWas); + UnityPrintNumberByStyle(actual_val, style); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } + /* Walk through array by incrementing the pointers */ + if (flags == UNITY_ARRAY_TO_ARRAY) + { + expected = (UNITY_INTERNAL_PTR)((const char*)expected + increment); + } + actual = (UNITY_INTERNAL_PTR)((const char*)actual + increment); + } +} + +/*-----------------------------------------------*/ +#ifndef UNITY_EXCLUDE_FLOAT +/* Wrap this define in a function with variable types as float or double */ +#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \ + if (isinf(expected) && isinf(actual) && (((expected) < 0) == ((actual) < 0))) return 1; \ + if (UNITY_NAN_CHECK) return 1; \ + (diff) = (actual) - (expected); \ + if ((diff) < 0) (diff) = -(diff); \ + if ((delta) < 0) (delta) = -(delta); \ + return !(isnan(diff) || isinf(diff) || ((diff) > (delta))) + /* This first part of this condition will catch any NaN or Infinite values */ +#ifndef UNITY_NAN_NOT_EQUAL_NAN + #define UNITY_NAN_CHECK isnan(expected) && isnan(actual) +#else + #define UNITY_NAN_CHECK 0 +#endif + +#ifndef UNITY_EXCLUDE_FLOAT_PRINT + #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \ + do { \ + UnityPrint(UnityStrExpected); \ + UnityPrintFloat(expected); \ + UnityPrint(UnityStrWas); \ + UnityPrintFloat(actual); \ + } while (0) +#else + #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \ + UnityPrint(UnityStrDelta) +#endif /* UNITY_EXCLUDE_FLOAT_PRINT */ + +/*-----------------------------------------------*/ +static int UnityFloatsWithin(UNITY_FLOAT delta, UNITY_FLOAT expected, UNITY_FLOAT actual) +{ + UNITY_FLOAT diff; + UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff); +} + +/*-----------------------------------------------*/ +void UnityAssertWithinFloatArray(const UNITY_FLOAT delta, + UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected, + UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags) +{ + UNITY_UINT32 elements = num_elements; + UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* ptr_expected = expected; + UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* ptr_actual = actual; + UNITY_FLOAT in_delta = delta; + UNITY_FLOAT current_element_delta = delta; + + RETURN_IF_FAIL_OR_IGNORE; + + if (elements == 0) + { +#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY + UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg); +#else + UnityPrintPointlessAndBail(); +#endif + } + + if (isinf(in_delta)) + { + return; /* Arrays will be force equal with infinite delta */ + } + + if (isnan(in_delta)) + { + /* Delta must be correct number */ + UnityPrintPointlessAndBail(); + } + + if (expected == actual) + { + return; /* Both are NULL or same pointer */ + } + + if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg)) + { + UNITY_FAIL_AND_BAIL; + } + + /* fix delta sign if need */ + if (in_delta < 0) + { + in_delta = -in_delta; + } + + while (elements--) + { + current_element_delta = *ptr_expected * UNITY_FLOAT_PRECISION; + + if (current_element_delta < 0) + { + /* fix delta sign for correct calculations */ + current_element_delta = -current_element_delta; + } + + if (!UnityFloatsWithin(in_delta + current_element_delta, *ptr_expected, *ptr_actual)) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrElement); + UnityPrintNumberUnsigned(num_elements - elements - 1); + UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT((UNITY_DOUBLE)*ptr_expected, (UNITY_DOUBLE)*ptr_actual); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } + if (flags == UNITY_ARRAY_TO_ARRAY) + { + ptr_expected++; + } + ptr_actual++; + } +} + +/*-----------------------------------------------*/ +void UnityAssertFloatsWithin(const UNITY_FLOAT delta, + const UNITY_FLOAT expected, + const UNITY_FLOAT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + RETURN_IF_FAIL_OR_IGNORE; + + + if (!UnityFloatsWithin(delta, expected, actual)) + { + UnityTestResultsFailBegin(lineNumber); + UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT((UNITY_DOUBLE)expected, (UNITY_DOUBLE)actual); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertFloatsNotWithin(const UNITY_FLOAT delta, + const UNITY_FLOAT expected, + const UNITY_FLOAT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + RETURN_IF_FAIL_OR_IGNORE; + + if (UnityFloatsWithin(delta, expected, actual)) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintFloat((UNITY_DOUBLE)expected); + UnityPrint(UnityStrNotEqual); + UnityPrintFloat((UNITY_DOUBLE)actual); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertGreaterOrLessFloat(const UNITY_FLOAT threshold, + const UNITY_FLOAT actual, + const UNITY_COMPARISON_T compare, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + int failed; + + RETURN_IF_FAIL_OR_IGNORE; + + failed = 0; + + /* Checking for "not success" rather than failure to get the right result for NaN */ + if (!(actual < threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } + if (!(actual > threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } + + if ((compare & UNITY_EQUAL_TO) && UnityFloatsWithin(threshold * UNITY_FLOAT_PRECISION, threshold, actual)) { failed = 0; } + + if (failed) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintFloat(actual); + if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); } + if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); } + if (compare & UNITY_EQUAL_TO) { UnityPrint(UnityStrOrEqual); } + UnityPrintFloat(threshold); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertFloatSpecial(const UNITY_FLOAT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLOAT_TRAIT_T style) +{ + const char* trait_names[] = {UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet}; + UNITY_INT should_be_trait = ((UNITY_INT)style & 1); + UNITY_INT is_trait = !should_be_trait; + UNITY_INT trait_index = (UNITY_INT)(style >> 1); + + RETURN_IF_FAIL_OR_IGNORE; + + switch (style) + { + case UNITY_FLOAT_IS_INF: + case UNITY_FLOAT_IS_NOT_INF: + is_trait = isinf(actual) && (actual > 0); + break; + case UNITY_FLOAT_IS_NEG_INF: + case UNITY_FLOAT_IS_NOT_NEG_INF: + is_trait = isinf(actual) && (actual < 0); + break; + + case UNITY_FLOAT_IS_NAN: + case UNITY_FLOAT_IS_NOT_NAN: + is_trait = isnan(actual) ? 1 : 0; + break; + + case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */ + case UNITY_FLOAT_IS_NOT_DET: + is_trait = !isinf(actual) && !isnan(actual); + break; + + default: /* including UNITY_FLOAT_INVALID_TRAIT */ + trait_index = 0; + trait_names[0] = UnityStrInvalidFloatTrait; + break; + } + + if (is_trait != should_be_trait) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + if (!should_be_trait) + { + UnityPrint(UnityStrNot); + } + UnityPrint(trait_names[trait_index]); + UnityPrint(UnityStrWas); +#ifndef UNITY_EXCLUDE_FLOAT_PRINT + UnityPrintFloat((UNITY_DOUBLE)actual); +#else + if (should_be_trait) + { + UnityPrint(UnityStrNot); + } + UnityPrint(trait_names[trait_index]); +#endif + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +#endif /* not UNITY_EXCLUDE_FLOAT */ + +/*-----------------------------------------------*/ +#ifndef UNITY_EXCLUDE_DOUBLE +static int UnityDoublesWithin(UNITY_DOUBLE delta, UNITY_DOUBLE expected, UNITY_DOUBLE actual) +{ + UNITY_DOUBLE diff; + UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff); +} + +/*-----------------------------------------------*/ +void UnityAssertWithinDoubleArray(const UNITY_DOUBLE delta, + UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expected, + UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags) +{ + UNITY_UINT32 elements = num_elements; + UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* ptr_expected = expected; + UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* ptr_actual = actual; + UNITY_DOUBLE in_delta = delta; + UNITY_DOUBLE current_element_delta = delta; + + RETURN_IF_FAIL_OR_IGNORE; + + if (elements == 0) + { +#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY + UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg); +#else + UnityPrintPointlessAndBail(); +#endif + } + + if (isinf(in_delta)) + { + return; /* Arrays will be force equal with infinite delta */ + } + + if (isnan(in_delta)) + { + /* Delta must be correct number */ + UnityPrintPointlessAndBail(); + } + + if (expected == actual) + { + return; /* Both are NULL or same pointer */ + } + + if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg)) + { + UNITY_FAIL_AND_BAIL; + } + + /* fix delta sign if need */ + if (in_delta < 0) + { + in_delta = -in_delta; + } + + while (elements--) + { + current_element_delta = *ptr_expected * UNITY_DOUBLE_PRECISION; + + if (current_element_delta < 0) + { + /* fix delta sign for correct calculations */ + current_element_delta = -current_element_delta; + } + + if (!UnityDoublesWithin(in_delta + current_element_delta, *ptr_expected, *ptr_actual)) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrElement); + UnityPrintNumberUnsigned(num_elements - elements - 1); + UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(*ptr_expected, *ptr_actual); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } + if (flags == UNITY_ARRAY_TO_ARRAY) + { + ptr_expected++; + } + ptr_actual++; + } +} + +/*-----------------------------------------------*/ +void UnityAssertDoublesWithin(const UNITY_DOUBLE delta, + const UNITY_DOUBLE expected, + const UNITY_DOUBLE actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + RETURN_IF_FAIL_OR_IGNORE; + + if (!UnityDoublesWithin(delta, expected, actual)) + { + UnityTestResultsFailBegin(lineNumber); + UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertDoublesNotWithin(const UNITY_DOUBLE delta, + const UNITY_DOUBLE expected, + const UNITY_DOUBLE actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + RETURN_IF_FAIL_OR_IGNORE; + + if (UnityDoublesWithin(delta, expected, actual)) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintFloat((UNITY_DOUBLE)expected); + UnityPrint(UnityStrNotEqual); + UnityPrintFloat((UNITY_DOUBLE)actual); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertGreaterOrLessDouble(const UNITY_DOUBLE threshold, + const UNITY_DOUBLE actual, + const UNITY_COMPARISON_T compare, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + int failed; + + RETURN_IF_FAIL_OR_IGNORE; + + failed = 0; + + /* Checking for "not success" rather than failure to get the right result for NaN */ + if (!(actual < threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } + if (!(actual > threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } + + if ((compare & UNITY_EQUAL_TO) && UnityDoublesWithin(threshold * UNITY_DOUBLE_PRECISION, threshold, actual)) { failed = 0; } + + if (failed) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintFloat(actual); + if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); } + if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); } + if (compare & UNITY_EQUAL_TO) { UnityPrint(UnityStrOrEqual); } + UnityPrintFloat(threshold); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLOAT_TRAIT_T style) +{ + const char* trait_names[] = {UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet}; + UNITY_INT should_be_trait = ((UNITY_INT)style & 1); + UNITY_INT is_trait = !should_be_trait; + UNITY_INT trait_index = (UNITY_INT)(style >> 1); + + RETURN_IF_FAIL_OR_IGNORE; + + switch (style) + { + case UNITY_FLOAT_IS_INF: + case UNITY_FLOAT_IS_NOT_INF: + is_trait = isinf(actual) && (actual > 0); + break; + case UNITY_FLOAT_IS_NEG_INF: + case UNITY_FLOAT_IS_NOT_NEG_INF: + is_trait = isinf(actual) && (actual < 0); + break; + + case UNITY_FLOAT_IS_NAN: + case UNITY_FLOAT_IS_NOT_NAN: + is_trait = isnan(actual) ? 1 : 0; + break; + + case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */ + case UNITY_FLOAT_IS_NOT_DET: + is_trait = !isinf(actual) && !isnan(actual); + break; + + default: /* including UNITY_FLOAT_INVALID_TRAIT */ + trait_index = 0; + trait_names[0] = UnityStrInvalidFloatTrait; + break; + } + + if (is_trait != should_be_trait) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + if (!should_be_trait) + { + UnityPrint(UnityStrNot); + } + UnityPrint(trait_names[trait_index]); + UnityPrint(UnityStrWas); +#ifndef UNITY_EXCLUDE_FLOAT_PRINT + UnityPrintFloat(actual); +#else + if (should_be_trait) + { + UnityPrint(UnityStrNot); + } + UnityPrint(trait_names[trait_index]); +#endif + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +#endif /* not UNITY_EXCLUDE_DOUBLE */ + +/*-----------------------------------------------*/ +void UnityAssertNumbersWithin(const UNITY_UINT delta, + const UNITY_INT expected, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style) +{ + RETURN_IF_FAIL_OR_IGNORE; + + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + { + if (actual > expected) + { + Unity.CurrentTestFailed = (((UNITY_UINT)actual - (UNITY_UINT)expected) > delta); + } + else + { + Unity.CurrentTestFailed = (((UNITY_UINT)expected - (UNITY_UINT)actual) > delta); + } + } + else + { + if ((UNITY_UINT)actual > (UNITY_UINT)expected) + { + Unity.CurrentTestFailed = (((UNITY_UINT)actual - (UNITY_UINT)expected) > delta); + } + else + { + Unity.CurrentTestFailed = (((UNITY_UINT)expected - (UNITY_UINT)actual) > delta); + } + } + + if (Unity.CurrentTestFailed) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrDelta); + UnityPrintNumberByStyle((UNITY_INT)delta, style); + UnityPrint(UnityStrExpected); + UnityPrintNumberByStyle(expected, style); + UnityPrint(UnityStrWas); + UnityPrintNumberByStyle(actual, style); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, + UNITY_INTERNAL_PTR expected, + UNITY_INTERNAL_PTR actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style, + const UNITY_FLAGS_T flags) +{ + UNITY_UINT32 elements = num_elements; + unsigned int length = style & 0xF; + unsigned int increment = 0; + + RETURN_IF_FAIL_OR_IGNORE; + + if (num_elements == 0) + { +#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY + UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg); +#else + UnityPrintPointlessAndBail(); +#endif + } + + if (expected == actual) + { + return; /* Both are NULL or same pointer */ + } + + if (UnityIsOneArrayNull(expected, actual, lineNumber, msg)) + { + UNITY_FAIL_AND_BAIL; + } + + while ((elements > 0) && (elements--)) + { + UNITY_INT expect_val; + UNITY_INT actual_val; + + switch (length) + { + case 1: + /* fixing problems with signed overflow on unsigned numbers */ + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + { + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)actual; + increment = sizeof(UNITY_INT8); + } + else + { + expect_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT8*)expected; + actual_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT8*)actual; + increment = sizeof(UNITY_UINT8); + } + break; + + case 2: + /* fixing problems with signed overflow on unsigned numbers */ + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + { + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)actual; + increment = sizeof(UNITY_INT16); + } + else + { + expect_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT16*)expected; + actual_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT16*)actual; + increment = sizeof(UNITY_UINT16); + } + break; + +#ifdef UNITY_SUPPORT_64 + case 8: + /* fixing problems with signed overflow on unsigned numbers */ + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + { + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)actual; + increment = sizeof(UNITY_INT64); + } + else + { + expect_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT64*)expected; + actual_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT64*)actual; + increment = sizeof(UNITY_UINT64); + } + break; +#endif + + default: /* default is length 4 bytes */ + case 4: + /* fixing problems with signed overflow on unsigned numbers */ + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + { + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; + increment = sizeof(UNITY_INT32); + } + else + { + expect_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT32*)expected; + actual_val = (UNITY_INT)*(UNITY_PTR_ATTRIBUTE const UNITY_UINT32*)actual; + increment = sizeof(UNITY_UINT32); + } + length = 4; + break; + } + + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + { + if (actual_val > expect_val) + { + Unity.CurrentTestFailed = (((UNITY_UINT)actual_val - (UNITY_UINT)expect_val) > delta); + } + else + { + Unity.CurrentTestFailed = (((UNITY_UINT)expect_val - (UNITY_UINT)actual_val) > delta); + } + } + else + { + if ((UNITY_UINT)actual_val > (UNITY_UINT)expect_val) + { + Unity.CurrentTestFailed = (((UNITY_UINT)actual_val - (UNITY_UINT)expect_val) > delta); + } + else + { + Unity.CurrentTestFailed = (((UNITY_UINT)expect_val - (UNITY_UINT)actual_val) > delta); + } + } + + if (Unity.CurrentTestFailed) + { + if ((style & UNITY_DISPLAY_RANGE_UINT) && (length < (UNITY_INT_WIDTH / 8))) + { /* For UINT, remove sign extension (padding 1's) from signed type casts above */ + UNITY_INT mask = 1; + mask = (mask << 8 * length) - 1; + expect_val &= mask; + actual_val &= mask; + } + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrDelta); + UnityPrintNumberByStyle((UNITY_INT)delta, style); + UnityPrint(UnityStrElement); + UnityPrintNumberUnsigned(num_elements - elements - 1); + UnityPrint(UnityStrExpected); + UnityPrintNumberByStyle(expect_val, style); + UnityPrint(UnityStrWas); + UnityPrintNumberByStyle(actual_val, style); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } + /* Walk through array by incrementing the pointers */ + if (flags == UNITY_ARRAY_TO_ARRAY) + { + expected = (UNITY_INTERNAL_PTR)((const char*)expected + increment); + } + actual = (UNITY_INTERNAL_PTR)((const char*)actual + increment); + } +} + +/*-----------------------------------------------*/ +void UnityAssertEqualString(const char* expected, + const char* actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + UNITY_UINT32 i; + + RETURN_IF_FAIL_OR_IGNORE; + + /* if both pointers not null compare the strings */ + if (expected && actual) + { + for (i = 0; expected[i] || actual[i]; i++) + { + if (expected[i] != actual[i]) + { + Unity.CurrentTestFailed = 1; + break; + } + } + } + else + { /* handle case of one pointers being null (if both null, test should pass) */ + if (expected != actual) + { + Unity.CurrentTestFailed = 1; + } + } + + if (Unity.CurrentTestFailed) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrintExpectedAndActualStrings(expected, actual); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertEqualStringLen(const char* expected, + const char* actual, + const UNITY_UINT32 length, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + UNITY_UINT32 i; + + RETURN_IF_FAIL_OR_IGNORE; + + /* if both pointers not null compare the strings */ + if (expected && actual) + { + for (i = 0; (i < length) && (expected[i] || actual[i]); i++) + { + if (expected[i] != actual[i]) + { + Unity.CurrentTestFailed = 1; + break; + } + } + } + else + { /* handle case of one pointers being null (if both null, test should pass) */ + if (expected != actual) + { + Unity.CurrentTestFailed = 1; + } + } + + if (Unity.CurrentTestFailed) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrintExpectedAndActualStringsLen(expected, actual, length); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertEqualStringArray(UNITY_INTERNAL_PTR expected, + const char** actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags) +{ + UNITY_UINT32 i = 0; + UNITY_UINT32 j = 0; + const char* expd = NULL; + const char* act = NULL; + + RETURN_IF_FAIL_OR_IGNORE; + + /* if no elements, it's an error */ + if (num_elements == 0) + { +#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY + UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg); +#else + UnityPrintPointlessAndBail(); +#endif + } + + if ((const void*)expected == (const void*)actual) + { + return; /* Both are NULL or same pointer */ + } + + if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg)) + { + UNITY_FAIL_AND_BAIL; + } + + if (flags != UNITY_ARRAY_TO_ARRAY) + { + expd = (const char*)expected; + } + + do + { + act = actual[j]; + if (flags == UNITY_ARRAY_TO_ARRAY) + { + expd = ((const char* const*)expected)[j]; + } + + /* if both pointers not null compare the strings */ + if (expd && act) + { + for (i = 0; expd[i] || act[i]; i++) + { + if (expd[i] != act[i]) + { + Unity.CurrentTestFailed = 1; + break; + } + } + } + else + { /* handle case of one pointers being null (if both null, test should pass) */ + if (expd != act) + { + Unity.CurrentTestFailed = 1; + } + } + + if (Unity.CurrentTestFailed) + { + UnityTestResultsFailBegin(lineNumber); + if (num_elements > 1) + { + UnityPrint(UnityStrElement); + UnityPrintNumberUnsigned(j); + } + UnityPrintExpectedAndActualStrings(expd, act); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } + } while (++j < num_elements); +} + +/*-----------------------------------------------*/ +void UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected, + UNITY_INTERNAL_PTR actual, + const UNITY_UINT32 length, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags) +{ + UNITY_PTR_ATTRIBUTE const unsigned char* ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected; + UNITY_PTR_ATTRIBUTE const unsigned char* ptr_act = (UNITY_PTR_ATTRIBUTE const unsigned char*)actual; + UNITY_UINT32 elements = num_elements; + UNITY_UINT32 bytes; + + RETURN_IF_FAIL_OR_IGNORE; + + if (elements == 0) + { +#ifdef UNITY_COMPARE_PTRS_ON_ZERO_ARRAY + UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, lineNumber, msg); +#else + UnityPrintPointlessAndBail(); +#endif + } + if (length == 0) + { + UnityPrintPointlessAndBail(); + } + + if (expected == actual) + { + return; /* Both are NULL or same pointer */ + } + + if (UnityIsOneArrayNull(expected, actual, lineNumber, msg)) + { + UNITY_FAIL_AND_BAIL; + } + + while (elements--) + { + bytes = length; + while (bytes--) + { + if (*ptr_exp != *ptr_act) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrMemory); + if (num_elements > 1) + { + UnityPrint(UnityStrElement); + UnityPrintNumberUnsigned(num_elements - elements - 1); + } + UnityPrint(UnityStrByte); + UnityPrintNumberUnsigned(length - bytes - 1); + UnityPrint(UnityStrExpected); + UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8); + UnityPrint(UnityStrWas); + UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } + ptr_exp++; + ptr_act++; + } + if (flags == UNITY_ARRAY_TO_VAL) + { + ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected; + } + } +} + +/*-----------------------------------------------*/ + +static union +{ + UNITY_INT8 i8; + UNITY_INT16 i16; + UNITY_INT32 i32; +#ifdef UNITY_SUPPORT_64 + UNITY_INT64 i64; +#endif +#ifndef UNITY_EXCLUDE_FLOAT + float f; +#endif +#ifndef UNITY_EXCLUDE_DOUBLE + double d; +#endif +} UnityQuickCompare; + +UNITY_INTERNAL_PTR UnityNumToPtr(const UNITY_INT num, const UNITY_UINT8 size) +{ + switch(size) + { + case 1: + UnityQuickCompare.i8 = (UNITY_INT8)num; + return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i8); + + case 2: + UnityQuickCompare.i16 = (UNITY_INT16)num; + return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i16); + +#ifdef UNITY_SUPPORT_64 + case 8: + UnityQuickCompare.i64 = (UNITY_INT64)num; + return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i64); +#endif + + default: /* 4 bytes */ + UnityQuickCompare.i32 = (UNITY_INT32)num; + return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i32); + } +} + +#ifndef UNITY_EXCLUDE_FLOAT +/*-----------------------------------------------*/ +UNITY_INTERNAL_PTR UnityFloatToPtr(const float num) +{ + UnityQuickCompare.f = num; + return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.f); +} +#endif + +#ifndef UNITY_EXCLUDE_DOUBLE +/*-----------------------------------------------*/ +UNITY_INTERNAL_PTR UnityDoubleToPtr(const double num) +{ + UnityQuickCompare.d = num; + return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.d); +} +#endif + +#ifdef UNITY_INCLUDE_PRINT_FORMATTED + +/*----------------------------------------------- + * printf length modifier helpers + *-----------------------------------------------*/ + +enum UnityLengthModifier { + UNITY_LENGTH_MODIFIER_NONE, + UNITY_LENGTH_MODIFIER_LONG_LONG, + UNITY_LENGTH_MODIFIER_LONG, +}; + +#define UNITY_EXTRACT_ARG(NUMBER_T, NUMBER, LENGTH_MOD, VA, ARG_T) \ +do { \ + switch (LENGTH_MOD) \ + { \ + case UNITY_LENGTH_MODIFIER_LONG_LONG: \ + { \ + NUMBER = (NUMBER_T)va_arg(VA, long long ARG_T); \ + break; \ + } \ + case UNITY_LENGTH_MODIFIER_LONG: \ + { \ + NUMBER = (NUMBER_T)va_arg(VA, long ARG_T); \ + break; \ + } \ + case UNITY_LENGTH_MODIFIER_NONE: \ + default: \ + { \ + NUMBER = (NUMBER_T)va_arg(VA, ARG_T); \ + break; \ + } \ + } \ +} while (0) + +static enum UnityLengthModifier UnityLengthModifierGet(const char *pch, int *length) +{ + enum UnityLengthModifier length_mod; + switch (pch[0]) + { + case 'l': + { + if (pch[1] == 'l') + { + *length = 2; + length_mod = UNITY_LENGTH_MODIFIER_LONG_LONG; + } + else + { + *length = 1; + length_mod = UNITY_LENGTH_MODIFIER_LONG; + } + break; + } + case 'h': + { + // short and char are converted to int + length_mod = UNITY_LENGTH_MODIFIER_NONE; + if (pch[1] == 'h') + { + *length = 2; + } + else + { + *length = 1; + } + break; + } + case 'j': + case 'z': + case 't': + case 'L': + { + // Not supported, but should gobble up the length specifier anyway + length_mod = UNITY_LENGTH_MODIFIER_NONE; + *length = 1; + break; + } + default: + { + length_mod = UNITY_LENGTH_MODIFIER_NONE; + *length = 0; + } + } + return length_mod; +} + +/*----------------------------------------------- + * printf helper function + *-----------------------------------------------*/ +static void UnityPrintFVA(const char* format, va_list va) +{ + const char* pch = format; + if (pch != NULL) + { + while (*pch) + { + /* format identification character */ + if (*pch == '%') + { + pch++; + + if (pch != NULL) + { + int length_mod_size; + enum UnityLengthModifier length_mod = UnityLengthModifierGet(pch, &length_mod_size); + pch += length_mod_size; + + switch (*pch) + { + case 'd': + case 'i': + { + UNITY_INT number; + UNITY_EXTRACT_ARG(UNITY_INT, number, length_mod, va, int); + UnityPrintNumber((UNITY_INT)number); + break; + } +#ifndef UNITY_EXCLUDE_FLOAT_PRINT + case 'f': + case 'g': + { + const double number = va_arg(va, double); + UnityPrintFloat((UNITY_DOUBLE)number); + break; + } +#endif + case 'u': + { + UNITY_UINT number; + UNITY_EXTRACT_ARG(UNITY_UINT, number, length_mod, va, unsigned int); + UnityPrintNumberUnsigned(number); + break; + } + case 'b': + { + UNITY_UINT number; + UNITY_EXTRACT_ARG(UNITY_UINT, number, length_mod, va, unsigned int); + const UNITY_UINT mask = (UNITY_UINT)0 - (UNITY_UINT)1; + UNITY_OUTPUT_CHAR('0'); + UNITY_OUTPUT_CHAR('b'); + UnityPrintMask(mask, number); + break; + } + case 'x': + case 'X': + { + UNITY_UINT number; + UNITY_EXTRACT_ARG(UNITY_UINT, number, length_mod, va, unsigned int); + UNITY_OUTPUT_CHAR('0'); + UNITY_OUTPUT_CHAR('x'); + UnityPrintNumberHex(number, 8); + break; + } + case 'p': + { + const unsigned int number = va_arg(va, unsigned int); + UNITY_OUTPUT_CHAR('0'); + UNITY_OUTPUT_CHAR('x'); + UnityPrintNumberHex((UNITY_UINT)number, 8); + break; + } + case 'c': + { + const int ch = va_arg(va, int); + UnityPrintChar((const char *)&ch); + break; + } + case 's': + { + const char * string = va_arg(va, const char *); + UnityPrint(string); + break; + } + case '%': + { + UnityPrintChar(pch); + break; + } + default: + { + /* print the unknown format character */ + UNITY_OUTPUT_CHAR('%'); + UnityPrintChar(pch); + break; + } + } + } + } +#ifdef UNITY_OUTPUT_COLOR + /* print ANSI escape code */ + else if ((*pch == 27) && (*(pch + 1) == '[')) + { + pch += UnityPrintAnsiEscapeString(pch); + continue; + } +#endif + else if (*pch == '\n') + { + UNITY_PRINT_EOL(); + } + else + { + UnityPrintChar(pch); + } + + pch++; + } + } +} + +void UnityPrintF(const UNITY_LINE_TYPE line, const char* format, ...) +{ + UnityTestResultsBegin(Unity.TestFile, line); + UnityPrint("INFO"); + if(format != NULL) + { + UnityPrint(": "); + va_list va; + va_start(va, format); + UnityPrintFVA(format, va); + va_end(va); + } + UNITY_PRINT_EOL(); +} +#endif /* ! UNITY_INCLUDE_PRINT_FORMATTED */ + + +/*----------------------------------------------- + * Control Functions + *-----------------------------------------------*/ + +/*-----------------------------------------------*/ +void UnityFail(const char* msg, const UNITY_LINE_TYPE line) +{ + RETURN_IF_FAIL_OR_IGNORE; + + UnityTestResultsBegin(Unity.TestFile, line); + UnityPrint(UnityStrFail); + if (msg != NULL) + { + UNITY_OUTPUT_CHAR(':'); + +#ifdef UNITY_PRINT_TEST_CONTEXT + UNITY_PRINT_TEST_CONTEXT(); +#endif +#ifndef UNITY_EXCLUDE_DETAILS + if (Unity.CurrentDetail1) + { + UnityPrint(UnityStrDetail1Name); + UnityPrint(Unity.CurrentDetail1); + if (Unity.CurrentDetail2) + { + UnityPrint(UnityStrDetail2Name); + UnityPrint(Unity.CurrentDetail2); + } + UnityPrint(UnityStrSpacer); + } +#endif + if (msg[0] != ' ') + { + UNITY_OUTPUT_CHAR(' '); + } + UnityPrint(msg); + } + + UNITY_FAIL_AND_BAIL; +} + +/*-----------------------------------------------*/ +void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line) +{ + RETURN_IF_FAIL_OR_IGNORE; + + UnityTestResultsBegin(Unity.TestFile, line); + UnityPrint(UnityStrIgnore); + if (msg != NULL) + { + UNITY_OUTPUT_CHAR(':'); + UNITY_OUTPUT_CHAR(' '); + UnityPrint(msg); + } + UNITY_IGNORE_AND_BAIL; +} + +/*-----------------------------------------------*/ +void UnityMessage(const char* msg, const UNITY_LINE_TYPE line) +{ + UnityTestResultsBegin(Unity.TestFile, line); + UnityPrint("INFO"); + if (msg != NULL) + { + UNITY_OUTPUT_CHAR(':'); + UNITY_OUTPUT_CHAR(' '); + UnityPrint(msg); + } + UNITY_PRINT_EOL(); +} + +/*-----------------------------------------------*/ +/* If we have not defined our own test runner, then include our default test runner to make life easier */ +#ifndef UNITY_SKIP_DEFAULT_RUNNER +void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum) +{ + Unity.CurrentTestName = FuncName; + Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum; + Unity.NumberOfTests++; + UNITY_CLR_DETAILS(); + UNITY_EXEC_TIME_START(); + if (TEST_PROTECT()) + { + setUp(); + Func(); + } + if (TEST_PROTECT()) + { + tearDown(); + } + UNITY_EXEC_TIME_STOP(); + UnityConcludeTest(); +} +#endif + +/*-----------------------------------------------*/ +void UnitySetTestFile(const char* filename) +{ + Unity.TestFile = filename; +} + +/*-----------------------------------------------*/ +void UnityBegin(const char* filename) +{ + Unity.TestFile = filename; + Unity.CurrentTestName = NULL; + Unity.CurrentTestLineNumber = 0; + Unity.NumberOfTests = 0; + Unity.TestFailures = 0; + Unity.TestIgnores = 0; + Unity.CurrentTestFailed = 0; + Unity.CurrentTestIgnored = 0; + + UNITY_CLR_DETAILS(); + UNITY_OUTPUT_START(); +} + +/*-----------------------------------------------*/ +int UnityEnd(void) +{ + UNITY_PRINT_EOL(); + UnityPrint(UnityStrBreaker); + UNITY_PRINT_EOL(); + UnityPrintNumber((UNITY_INT)(Unity.NumberOfTests)); + UnityPrint(UnityStrResultsTests); + UnityPrintNumber((UNITY_INT)(Unity.TestFailures)); + UnityPrint(UnityStrResultsFailures); + UnityPrintNumber((UNITY_INT)(Unity.TestIgnores)); + UnityPrint(UnityStrResultsIgnored); + UNITY_PRINT_EOL(); + if (Unity.TestFailures == 0U) + { + UnityPrint(UnityStrOk); + } + else + { + UnityPrint(UnityStrFail); +#ifdef UNITY_DIFFERENTIATE_FINAL_FAIL + UNITY_OUTPUT_CHAR('E'); UNITY_OUTPUT_CHAR('D'); +#endif + } + UNITY_PRINT_EOL(); + UNITY_FLUSH_CALL(); + UNITY_OUTPUT_COMPLETE(); + return (int)(Unity.TestFailures); +} + +/*----------------------------------------------- + * Command Line Argument Support + *-----------------------------------------------*/ +#ifdef UNITY_USE_COMMAND_LINE_ARGS + +char* UnityOptionIncludeNamed = NULL; +char* UnityOptionExcludeNamed = NULL; +int UnityVerbosity = 1; + +/*-----------------------------------------------*/ +int UnityParseOptions(int argc, char** argv) +{ + int i; + UnityOptionIncludeNamed = NULL; + UnityOptionExcludeNamed = NULL; + + for (i = 1; i < argc; i++) + { + if (argv[i][0] == '-') + { + switch (argv[i][1]) + { + case 'l': /* list tests */ + return -1; + case 'n': /* include tests with name including this string */ + case 'f': /* an alias for -n */ + if (argv[i][2] == '=') + { + UnityOptionIncludeNamed = &argv[i][3]; + } + else if (++i < argc) + { + UnityOptionIncludeNamed = argv[i]; + } + else + { + UnityPrint("ERROR: No Test String to Include Matches For"); + UNITY_PRINT_EOL(); + return 1; + } + break; + case 'q': /* quiet */ + UnityVerbosity = 0; + break; + case 'v': /* verbose */ + UnityVerbosity = 2; + break; + case 'x': /* exclude tests with name including this string */ + if (argv[i][2] == '=') + { + UnityOptionExcludeNamed = &argv[i][3]; + } + else if (++i < argc) + { + UnityOptionExcludeNamed = argv[i]; + } + else + { + UnityPrint("ERROR: No Test String to Exclude Matches For"); + UNITY_PRINT_EOL(); + return 1; + } + break; + default: + UnityPrint("ERROR: Unknown Option "); + UNITY_OUTPUT_CHAR(argv[i][1]); + UNITY_PRINT_EOL(); + return 1; + } + } + } + + return 0; +} + +/*-----------------------------------------------*/ +int IsStringInBiggerString(const char* longstring, const char* shortstring) +{ + const char* lptr = longstring; + const char* sptr = shortstring; + const char* lnext = lptr; + + if (*sptr == '*') + { + return 1; + } + + while (*lptr) + { + lnext = lptr + 1; + + /* If they current bytes match, go on to the next bytes */ + while (*lptr && *sptr && (*lptr == *sptr)) + { + lptr++; + sptr++; + + /* We're done if we match the entire string or up to a wildcard */ + if (*sptr == '*') + return 1; + if (*sptr == ',') + return 1; + if (*sptr == '"') + return 1; + if (*sptr == '\'') + return 1; + if (*sptr == ':') + return 2; + if (*sptr == 0) + return 1; + } + + /* Otherwise we start in the long pointer 1 character further and try again */ + lptr = lnext; + sptr = shortstring; + } + + return 0; +} + +/*-----------------------------------------------*/ +int UnityStringArgumentMatches(const char* str) +{ + int retval; + const char* ptr1; + const char* ptr2; + const char* ptrf; + + /* Go through the options and get the substrings for matching one at a time */ + ptr1 = str; + while (ptr1[0] != 0) + { + if ((ptr1[0] == '"') || (ptr1[0] == '\'')) + { + ptr1++; + } + + /* look for the start of the next partial */ + ptr2 = ptr1; + ptrf = 0; + do + { + ptr2++; + if ((ptr2[0] == ':') && (ptr2[1] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ',')) + { + ptrf = &ptr2[1]; + } + } while ((ptr2[0] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ',')); + + while ((ptr2[0] != 0) && ((ptr2[0] == ':') || (ptr2[0] == '\'') || (ptr2[0] == '"') || (ptr2[0] == ','))) + { + ptr2++; + } + + /* done if complete filename match */ + retval = IsStringInBiggerString(Unity.TestFile, ptr1); + if (retval == 1) + { + return retval; + } + + /* done if testname match after filename partial match */ + if ((retval == 2) && (ptrf != 0)) + { + if (IsStringInBiggerString(Unity.CurrentTestName, ptrf)) + { + return 1; + } + } + + /* done if complete testname match */ + if (IsStringInBiggerString(Unity.CurrentTestName, ptr1) == 1) + { + return 1; + } + + ptr1 = ptr2; + } + + /* we couldn't find a match for any substrings */ + return 0; +} + +/*-----------------------------------------------*/ +int UnityTestMatches(void) +{ + /* Check if this test name matches the included test pattern */ + int retval; + if (UnityOptionIncludeNamed) + { + retval = UnityStringArgumentMatches(UnityOptionIncludeNamed); + } + else + { + retval = 1; + } + + /* Check if this test name matches the excluded test pattern */ + if (UnityOptionExcludeNamed) + { + if (UnityStringArgumentMatches(UnityOptionExcludeNamed)) + { + retval = 0; + } + } + + return retval; +} + +#endif /* UNITY_USE_COMMAND_LINE_ARGS */ +/*-----------------------------------------------*/ diff --git a/test/unity/unity.h b/test/unity/unity.h new file mode 100644 index 0000000000000000000000000000000000000000..e321a1dae83a7336d119b589d26c075f9d9c624a --- /dev/null +++ b/test/unity/unity.h @@ -0,0 +1,687 @@ +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#ifndef UNITY_FRAMEWORK_H +#define UNITY_FRAMEWORK_H +#define UNITY + +#define UNITY_VERSION_MAJOR 2 +#define UNITY_VERSION_MINOR 5 +#define UNITY_VERSION_BUILD 4 +#define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD) + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "unity_internals.h" + +/*------------------------------------------------------- + * Test Setup / Teardown + *-------------------------------------------------------*/ + +/* These functions are intended to be called before and after each test. + * If using unity directly, these will need to be provided for each test + * executable built. If you are using the test runner generator and/or + * Ceedling, these are optional. */ +void setUp(void); +void tearDown(void); + +/* These functions are intended to be called at the beginning and end of an + * entire test suite. suiteTearDown() is passed the number of tests that + * failed, and its return value becomes the exit code of main(). If using + * Unity directly, you're in charge of calling these if they are desired. + * If using Ceedling or the test runner generator, these will be called + * automatically if they exist. */ +void suiteSetUp(void); +int suiteTearDown(int num_failures); + +/*------------------------------------------------------- + * Test Reset and Verify + *-------------------------------------------------------*/ + +/* These functions are intended to be called before during tests in order + * to support complex test loops, etc. Both are NOT built into Unity. Instead + * the test runner generator will create them. resetTest will run teardown and + * setup again, verifying any end-of-test needs between. verifyTest will only + * run the verification. */ +void resetTest(void); +void verifyTest(void); + +/*------------------------------------------------------- + * Configuration Options + *------------------------------------------------------- + * All options described below should be passed as a compiler flag to all files using Unity. If you must add #defines, place them BEFORE the #include above. + + * Integers/longs/pointers + * - Unity attempts to automatically discover your integer sizes + * - define UNITY_EXCLUDE_STDINT_H to stop attempting to look in + * - define UNITY_EXCLUDE_LIMITS_H to stop attempting to look in + * - If you cannot use the automatic methods above, you can force Unity by using these options: + * - define UNITY_SUPPORT_64 + * - set UNITY_INT_WIDTH + * - set UNITY_LONG_WIDTH + * - set UNITY_POINTER_WIDTH + + * Floats + * - define UNITY_EXCLUDE_FLOAT to disallow floating point comparisons + * - define UNITY_FLOAT_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_FLOAT + * - define UNITY_FLOAT_TYPE to specify doubles instead of single precision floats + * - define UNITY_INCLUDE_DOUBLE to allow double floating point comparisons + * - define UNITY_EXCLUDE_DOUBLE to disallow double floating point comparisons (default) + * - define UNITY_DOUBLE_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_DOUBLE + * - define UNITY_DOUBLE_TYPE to specify something other than double + * - define UNITY_EXCLUDE_FLOAT_PRINT to trim binary size, won't print floating point values in errors + + * Output + * - by default, Unity prints to standard out with putchar. define UNITY_OUTPUT_CHAR(a) with a different function if desired + * - define UNITY_DIFFERENTIATE_FINAL_FAIL to print FAILED (vs. FAIL) at test end summary - for automated search for failure + + * Optimization + * - by default, line numbers are stored in unsigned shorts. Define UNITY_LINE_TYPE with a different type if your files are huge + * - by default, test and failure counters are unsigned shorts. Define UNITY_COUNTER_TYPE with a different type if you want to save space or have more than 65535 Tests. + + * Test Cases + * - define UNITY_SUPPORT_TEST_CASES to include the TEST_CASE macro, though really it's mostly about the runner generator script + + * Parameterized Tests + * - you'll want to create a define of TEST_CASE(...) and/or TEST_RANGE(...) which basically evaluates to nothing + + * Tests with Arguments + * - you'll want to define UNITY_USE_COMMAND_LINE_ARGS if you have the test runner passing arguments to Unity + + *------------------------------------------------------- + * Basic Fail and Ignore + *-------------------------------------------------------*/ + +#define TEST_FAIL_MESSAGE(message) UNITY_TEST_FAIL(__LINE__, (message)) +#define TEST_FAIL() UNITY_TEST_FAIL(__LINE__, NULL) +#define TEST_IGNORE_MESSAGE(message) UNITY_TEST_IGNORE(__LINE__, (message)) +#define TEST_IGNORE() UNITY_TEST_IGNORE(__LINE__, NULL) +#define TEST_MESSAGE(message) UnityMessage((message), __LINE__) +#define TEST_ONLY() +#ifdef UNITY_INCLUDE_PRINT_FORMATTED +#define TEST_PRINTF(message, ...) UnityPrintF(__LINE__, (message), __VA_ARGS__) +#endif + +/* It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails. + * This method allows you to abort a test immediately with a PASS state, ignoring the remainder of the test. */ +#define TEST_PASS() TEST_ABORT() +#define TEST_PASS_MESSAGE(message) do { UnityMessage((message), __LINE__); TEST_ABORT(); } while (0) + +/* This macro does nothing, but it is useful for build tools (like Ceedling) to make use of this to figure out + * which files should be linked to in order to perform a test. Use it like TEST_FILE("sandwiches.c") */ +#define TEST_FILE(a) + +/*------------------------------------------------------- + * Test Asserts (simple) + *-------------------------------------------------------*/ + +/* Boolean */ +#define TEST_ASSERT(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expression Evaluated To FALSE") +#define TEST_ASSERT_TRUE(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expected TRUE Was FALSE") +#define TEST_ASSERT_UNLESS(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expression Evaluated To TRUE") +#define TEST_ASSERT_FALSE(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expected FALSE Was TRUE") +#define TEST_ASSERT_NULL(pointer) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, " Expected NULL") +#define TEST_ASSERT_NOT_NULL(pointer) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, " Expected Non-NULL") +#define TEST_ASSERT_EMPTY(pointer) UNITY_TEST_ASSERT_EMPTY( (pointer), __LINE__, " Expected Empty") +#define TEST_ASSERT_NOT_EMPTY(pointer) UNITY_TEST_ASSERT_NOT_EMPTY((pointer), __LINE__, " Expected Non-Empty") + +/* Integers (of all sizes) */ +#define TEST_ASSERT_EQUAL_INT(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT8((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_size_t(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX8(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX16(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX32(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX64(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_CHAR(expected, actual) UNITY_TEST_ASSERT_EQUAL_CHAR((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_BITS(mask, expected, actual) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_BITS_HIGH(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT)(-1), (actual), __LINE__, NULL) +#define TEST_ASSERT_BITS_LOW(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT)(0), (actual), __LINE__, NULL) +#define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT)1 << (bit)), (UNITY_UINT)(-1), (actual), __LINE__, NULL) +#define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT)1 << (bit)), (UNITY_UINT)(0), (actual), __LINE__, NULL) + +/* Integer Not Equal To (of all sizes) */ +#define TEST_ASSERT_NOT_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_CHAR((threshold), (actual), __LINE__, NULL) + +/* Integer Greater Than/ Less Than (of all sizes) */ +#define TEST_ASSERT_GREATER_THAN(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_size_t(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_CHAR(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_CHAR((threshold), (actual), __LINE__, NULL) + +#define TEST_ASSERT_LESS_THAN(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_size_t(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_CHAR(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_CHAR((threshold), (actual), __LINE__, NULL) + +#define TEST_ASSERT_GREATER_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, NULL) + +#define TEST_ASSERT_LESS_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, NULL) + +/* Integer Ranges (of all sizes) */ +#define TEST_ASSERT_INT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_INT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT8_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_INT16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT16_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_INT32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT32_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_INT64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT64_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_UINT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_UINT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT8_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_UINT16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT16_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_UINT32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT32_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_UINT64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT64_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_size_t_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_HEX_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_HEX8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX8_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_HEX16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX16_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_HEX32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_HEX64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_CHAR_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_CHAR_WITHIN((delta), (expected), (actual), __LINE__, NULL) + +/* Integer Array Ranges (of all sizes) */ +#define TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_INT8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_size_t_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_HEX_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_HEX32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_CHAR_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) + + +/* Structs and Strings */ +#define TEST_ASSERT_EQUAL_PTR(expected, actual) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_STRING(expected, actual) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len) UNITY_TEST_ASSERT_EQUAL_STRING_LEN((expected), (actual), (len), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_MEMORY(expected, actual, len) UNITY_TEST_ASSERT_EQUAL_MEMORY((expected), (actual), (len), __LINE__, NULL) + +/* Arrays */ +#define TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_size_t_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_CHAR_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_CHAR_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) + +/* Arrays Compared To Single Value */ +#define TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_INT16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT16((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT32((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT64((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_UINT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_UINT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT8((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_size_t(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_HEX(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_HEX32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX64((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_STRING(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_MEMORY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_CHAR(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_CHAR((expected), (actual), (num_elements), __LINE__, NULL) + +/* Floating Point (If Enabled) */ +#define TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_FLOAT_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_NOT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_FLOAT(expected, actual) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_FLOAT(expected, actual) UNITY_TEST_ASSERT_NOT_EQUAL_FLOAT((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_FLOAT_ARRAY_WITHIN((delta), (expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_FLOAT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_FLOAT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_FLOAT(threshold, actual) UNITY_TEST_ASSERT_LESS_THAN_FLOAT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_FLOAT(threshold, actual) UNITY_TEST_ASSERT_LESS_OR_EQUAL_FLOAT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_IS_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_INF((actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_IS_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF((actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_IS_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NAN((actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_IS_DETERMINATE(actual) UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE((actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_IS_NOT_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF((actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF((actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN((actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE((actual), __LINE__, NULL) + +/* Double (If Enabled) */ +#define TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_NOT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_DOUBLE_NOT_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_DOUBLE(expected, actual) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_DOUBLE(expected, actual) UNITY_TEST_ASSERT_NOT_EQUAL_DOUBLE((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_DOUBLE_ARRAY_WITHIN((delta), (expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_LESS_THAN_DOUBLE((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_LESS_OR_EQUAL_DOUBLE((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_IS_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_INF((actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_IS_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF((actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_IS_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NAN((actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE((actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_IS_NOT_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF((actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF((actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN((actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, NULL) + +/* Shorthand */ +#ifdef UNITY_SHORTHAND_AS_OLD +#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal") +#endif +#ifdef UNITY_SHORTHAND_AS_INT +#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif +#ifdef UNITY_SHORTHAND_AS_MEM +#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_MEMORY((&expected), (&actual), sizeof(expected), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif +#ifdef UNITY_SHORTHAND_AS_RAW +#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) == (actual)), __LINE__, " Expected Equal") +#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal") +#endif +#ifdef UNITY_SHORTHAND_AS_NONE +#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif + +/*------------------------------------------------------- + * Test Asserts (with additional messages) + *-------------------------------------------------------*/ + +/* Boolean */ +#define TEST_ASSERT_MESSAGE(condition, message) UNITY_TEST_ASSERT( (condition), __LINE__, (message)) +#define TEST_ASSERT_TRUE_MESSAGE(condition, message) UNITY_TEST_ASSERT( (condition), __LINE__, (message)) +#define TEST_ASSERT_UNLESS_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, (message)) +#define TEST_ASSERT_FALSE_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, (message)) +#define TEST_ASSERT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, (message)) +#define TEST_ASSERT_NOT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, (message)) +#define TEST_ASSERT_EMPTY_MESSAGE(pointer, message) UNITY_TEST_ASSERT_EMPTY( (pointer), __LINE__, (message)) +#define TEST_ASSERT_NOT_EMPTY_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NOT_EMPTY((pointer), __LINE__, (message)) + +/* Integers (of all sizes) */ +#define TEST_ASSERT_EQUAL_INT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_INT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT8((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_INT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_INT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_INT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_size_t_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_BITS_MESSAGE(mask, expected, actual, message) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_BITS_HIGH_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(-1), (actual), __LINE__, (message)) +#define TEST_ASSERT_BITS_LOW_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(0), (actual), __LINE__, (message)) +#define TEST_ASSERT_BIT_HIGH_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, (message)) +#define TEST_ASSERT_BIT_LOW_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_CHAR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_CHAR((expected), (actual), __LINE__, (message)) + +/* Integer Not Equal To (of all sizes) */ +#define TEST_ASSERT_NOT_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_CHAR((threshold), (actual), __LINE__, (message)) + + +/* Integer Greater Than/ Less Than (of all sizes) */ +#define TEST_ASSERT_GREATER_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_CHAR((threshold), (actual), __LINE__, (message)) + +#define TEST_ASSERT_LESS_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_CHAR((threshold), (actual), __LINE__, (message)) + +#define TEST_ASSERT_GREATER_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, (message)) + +#define TEST_ASSERT_LESS_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, (message)) + +/* Integer Ranges (of all sizes) */ +#define TEST_ASSERT_INT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_INT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT8_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_INT16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT16_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_INT32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT32_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_INT64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT64_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_UINT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_UINT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT8_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_UINT16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT16_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_UINT32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT32_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_UINT64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT64_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_size_t_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_HEX_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_HEX8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX8_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_HEX16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX16_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_HEX32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_HEX64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_CHAR_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_CHAR_WITHIN((delta), (expected), (actual), __LINE__, (message)) + +/* Integer Array Ranges (of all sizes) */ +#define TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_INT32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_UINT32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_size_t_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_HEX_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) + + +/* Structs and Strings */ +#define TEST_ASSERT_EQUAL_PTR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(expected, actual, len, message) UNITY_TEST_ASSERT_EQUAL_STRING_LEN((expected), (actual), (len), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_MEMORY_MESSAGE(expected, actual, len, message) UNITY_TEST_ASSERT_EQUAL_MEMORY((expected), (actual), (len), __LINE__, (message)) + +/* Arrays */ +#define TEST_ASSERT_EQUAL_INT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_INT8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_INT16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_INT32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_INT64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_size_t_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_PTR_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_STRING_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_MEMORY_ARRAY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_CHAR_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_CHAR_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) + +/* Arrays Compared To Single Value*/ +#define TEST_ASSERT_EACH_EQUAL_INT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_INT8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_INT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT16((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_INT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT32((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_INT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT64((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_UINT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_UINT8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT8((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_UINT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_UINT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_UINT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_size_t_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_HEX_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_HEX8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_HEX16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_HEX32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_HEX64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX64((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_PTR_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_STRING_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_MEMORY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_CHAR_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_CHAR((expected), (actual), (num_elements), __LINE__, (message)) + +/* Floating Point (If Enabled) */ +#define TEST_ASSERT_FLOAT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_FLOAT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_FLOAT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_FLOAT((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_FLOAT_ARRAY_WITHIN((delta), (expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_FLOAT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_FLOAT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_FLOAT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_FLOAT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_THAN_FLOAT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_OR_EQUAL_FLOAT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_INF((actual), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF((actual), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NAN((actual), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_IS_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE((actual), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_IS_NOT_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF((actual), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_IS_NOT_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF((actual), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN((actual), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE((actual), __LINE__, (message)) + +/* Double (If Enabled) */ +#define TEST_ASSERT_DOUBLE_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_DOUBLE_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_DOUBLE_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_DOUBLE((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_DOUBLE_ARRAY_WITHIN((delta), (expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_DOUBLE_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_DOUBLE_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_THAN_DOUBLE((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_OR_EQUAL_DOUBLE((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_INF((actual), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF((actual), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NAN((actual), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_IS_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE((actual), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_IS_NOT_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF((actual), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF((actual), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN((actual), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, (message)) + +/* Shorthand */ +#ifdef UNITY_SHORTHAND_AS_OLD +#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, (message)) +#endif +#ifdef UNITY_SHORTHAND_AS_INT +#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, message) +#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif +#ifdef UNITY_SHORTHAND_AS_MEM +#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_MEMORY((&expected), (&actual), sizeof(expected), __LINE__, message) +#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif +#ifdef UNITY_SHORTHAND_AS_RAW +#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) == (actual)), __LINE__, message) +#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, message) +#endif +#ifdef UNITY_SHORTHAND_AS_NONE +#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif + +/* end of UNITY_FRAMEWORK_H */ +#ifdef __cplusplus +} +#endif +#endif diff --git a/test/unity/unity_internals.h b/test/unity/unity_internals.h new file mode 100644 index 0000000000000000000000000000000000000000..98e298fcc04cd6f1917c8991f9c60cfbc0a2301f --- /dev/null +++ b/test/unity/unity_internals.h @@ -0,0 +1,1145 @@ +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#ifndef UNITY_INTERNALS_H +#define UNITY_INTERNALS_H + +#ifdef UNITY_INCLUDE_CONFIG_H +#include "unity_config.h" +#endif + +#ifndef UNITY_EXCLUDE_SETJMP_H +#include +#endif + +#ifndef UNITY_EXCLUDE_MATH_H +#include +#endif + +#ifndef UNITY_EXCLUDE_STDDEF_H +#include +#endif + +#ifdef UNITY_INCLUDE_PRINT_FORMATTED +#include +#endif + +/* Unity Attempts to Auto-Detect Integer Types + * Attempt 1: UINT_MAX, ULONG_MAX in , or default to 32 bits + * Attempt 2: UINTPTR_MAX in , or default to same size as long + * The user may override any of these derived constants: + * UNITY_INT_WIDTH, UNITY_LONG_WIDTH, UNITY_POINTER_WIDTH */ +#ifndef UNITY_EXCLUDE_STDINT_H +#include +#endif + +#ifndef UNITY_EXCLUDE_LIMITS_H +#include +#endif + +#if defined(__GNUC__) || defined(__clang__) + #define UNITY_FUNCTION_ATTR(a) __attribute__((a)) +#else + #define UNITY_FUNCTION_ATTR(a) /* ignore */ +#endif + +#ifndef UNITY_NORETURN + #if defined(__cplusplus) + #if __cplusplus >= 201103L + #define UNITY_NORETURN [[ noreturn ]] + #endif + #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + #if defined(_WIN32) && defined(_MSC_VER) + /* We are using MSVC compiler on Windows platform. */ + /* Not all Windows SDKs supports , but compiler can support C11: */ + /* https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-support-arriving-in-msvc/ */ + /* Not sure, that Mingw compilers has Windows SDK headers at all. */ + #include + #endif + + /* Using Windows SDK predefined macro for detecting supported SDK with MSVC compiler. */ + /* Mingw GCC should work without that fixes. */ + /* Based on: */ + /* https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170 */ + /* NTDDI_WIN10_FE is equal to Windows 10 SDK 2104 */ + #if defined(_MSC_VER) && ((!defined(NTDDI_WIN10_FE)) || WDK_NTDDI_VERSION < NTDDI_WIN10_FE) + /* Based on tests and: */ + /* https://docs.microsoft.com/en-us/cpp/c-language/noreturn?view=msvc-170 */ + /* https://en.cppreference.com/w/c/language/_Noreturn */ + #define UNITY_NORETURN _Noreturn + #else /* Using newer Windows SDK or not MSVC compiler */ + #include + #define UNITY_NORETURN noreturn + #endif + #endif +#endif +#ifndef UNITY_NORETURN + #define UNITY_NORETURN UNITY_FUNCTION_ATTR(__noreturn__) +#endif + +/*------------------------------------------------------- + * Guess Widths If Not Specified + *-------------------------------------------------------*/ + +/* Determine the size of an int, if not already specified. + * We cannot use sizeof(int), because it is not yet defined + * at this stage in the translation of the C program. + * Also sizeof(int) does return the size in addressable units on all platforms, + * which may not necessarily be the size in bytes. + * Therefore, infer it from UINT_MAX if possible. */ +#ifndef UNITY_INT_WIDTH + #ifdef UINT_MAX + #if (UINT_MAX == 0xFFFF) + #define UNITY_INT_WIDTH (16) + #elif (UINT_MAX == 0xFFFFFFFF) + #define UNITY_INT_WIDTH (32) + #elif (UINT_MAX == 0xFFFFFFFFFFFFFFFF) + #define UNITY_INT_WIDTH (64) + #endif + #else /* Set to default */ + #define UNITY_INT_WIDTH (32) + #endif /* UINT_MAX */ +#endif + +/* Determine the size of a long, if not already specified. */ +#ifndef UNITY_LONG_WIDTH + #ifdef ULONG_MAX + #if (ULONG_MAX == 0xFFFF) + #define UNITY_LONG_WIDTH (16) + #elif (ULONG_MAX == 0xFFFFFFFF) + #define UNITY_LONG_WIDTH (32) + #elif (ULONG_MAX == 0xFFFFFFFFFFFFFFFF) + #define UNITY_LONG_WIDTH (64) + #endif + #else /* Set to default */ + #define UNITY_LONG_WIDTH (32) + #endif /* ULONG_MAX */ +#endif + +/* Determine the size of a pointer, if not already specified. */ +#ifndef UNITY_POINTER_WIDTH + #ifdef UINTPTR_MAX + #if (UINTPTR_MAX <= 0xFFFF) + #define UNITY_POINTER_WIDTH (16) + #elif (UINTPTR_MAX <= 0xFFFFFFFF) + #define UNITY_POINTER_WIDTH (32) + #elif (UINTPTR_MAX <= 0xFFFFFFFFFFFFFFFF) + #define UNITY_POINTER_WIDTH (64) + #endif + #else /* Set to default */ + #define UNITY_POINTER_WIDTH UNITY_LONG_WIDTH + #endif /* UINTPTR_MAX */ +#endif + +/*------------------------------------------------------- + * Int Support (Define types based on detected sizes) + *-------------------------------------------------------*/ + +#if (UNITY_INT_WIDTH == 32) + typedef unsigned char UNITY_UINT8; + typedef unsigned short UNITY_UINT16; + typedef unsigned int UNITY_UINT32; + typedef signed char UNITY_INT8; + typedef signed short UNITY_INT16; + typedef signed int UNITY_INT32; +#elif (UNITY_INT_WIDTH == 16) + typedef unsigned char UNITY_UINT8; + typedef unsigned int UNITY_UINT16; + typedef unsigned long UNITY_UINT32; + typedef signed char UNITY_INT8; + typedef signed int UNITY_INT16; + typedef signed long UNITY_INT32; +#else + #error Invalid UNITY_INT_WIDTH specified! (16 or 32 are supported) +#endif + +/*------------------------------------------------------- + * 64-bit Support + *-------------------------------------------------------*/ + +/* Auto-detect 64 Bit Support */ +#ifndef UNITY_SUPPORT_64 + #if UNITY_LONG_WIDTH == 64 || UNITY_POINTER_WIDTH == 64 + #define UNITY_SUPPORT_64 + #endif +#endif + +/* 64-Bit Support Dependent Configuration */ +#ifndef UNITY_SUPPORT_64 + /* No 64-bit Support */ + typedef UNITY_UINT32 UNITY_UINT; + typedef UNITY_INT32 UNITY_INT; + #define UNITY_MAX_NIBBLES (8) /* Maximum number of nibbles in a UNITY_(U)INT */ +#else + /* 64-bit Support */ + #if (UNITY_LONG_WIDTH == 32) + typedef unsigned long long UNITY_UINT64; + typedef signed long long UNITY_INT64; + #elif (UNITY_LONG_WIDTH == 64) + typedef unsigned long UNITY_UINT64; + typedef signed long UNITY_INT64; + #else + #error Invalid UNITY_LONG_WIDTH specified! (32 or 64 are supported) + #endif + typedef UNITY_UINT64 UNITY_UINT; + typedef UNITY_INT64 UNITY_INT; + #define UNITY_MAX_NIBBLES (16) /* Maximum number of nibbles in a UNITY_(U)INT */ +#endif + +/*------------------------------------------------------- + * Pointer Support + *-------------------------------------------------------*/ + +#if (UNITY_POINTER_WIDTH == 32) + #define UNITY_PTR_TO_INT UNITY_INT32 + #define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX32 +#elif (UNITY_POINTER_WIDTH == 64) + #define UNITY_PTR_TO_INT UNITY_INT64 + #define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX64 +#elif (UNITY_POINTER_WIDTH == 16) + #define UNITY_PTR_TO_INT UNITY_INT16 + #define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX16 +#else + #error Invalid UNITY_POINTER_WIDTH specified! (16, 32 or 64 are supported) +#endif + +#ifndef UNITY_PTR_ATTRIBUTE + #define UNITY_PTR_ATTRIBUTE +#endif + +#ifndef UNITY_INTERNAL_PTR + #define UNITY_INTERNAL_PTR UNITY_PTR_ATTRIBUTE const void* +#endif + +/* optionally define UNITY_COMPARE_PTRS_ON_ZERO_ARRAY */ + +/*------------------------------------------------------- + * Float Support + *-------------------------------------------------------*/ + +#ifdef UNITY_EXCLUDE_FLOAT + +/* No Floating Point Support */ +#ifndef UNITY_EXCLUDE_DOUBLE +#define UNITY_EXCLUDE_DOUBLE /* Remove double when excluding float support */ +#endif +#ifndef UNITY_EXCLUDE_FLOAT_PRINT +#define UNITY_EXCLUDE_FLOAT_PRINT +#endif + +#else + +/* Floating Point Support */ +#ifndef UNITY_FLOAT_PRECISION +#define UNITY_FLOAT_PRECISION (0.00001f) +#endif +#ifndef UNITY_FLOAT_TYPE +#define UNITY_FLOAT_TYPE float +#endif +typedef UNITY_FLOAT_TYPE UNITY_FLOAT; + +/* isinf & isnan macros should be provided by math.h */ +#ifndef isinf +/* The value of Inf - Inf is NaN */ +#define isinf(n) (isnan((n) - (n)) && !isnan(n)) +#endif + +#ifndef isnan +/* NaN is the only floating point value that does NOT equal itself. + * Therefore if n != n, then it is NaN. */ +#define isnan(n) ((n != n) ? 1 : 0) +#endif + +#endif + +/*------------------------------------------------------- + * Double Float Support + *-------------------------------------------------------*/ + +/* unlike float, we DON'T include by default */ +#if defined(UNITY_EXCLUDE_DOUBLE) || !defined(UNITY_INCLUDE_DOUBLE) + + /* No Floating Point Support */ + #ifndef UNITY_EXCLUDE_DOUBLE + #define UNITY_EXCLUDE_DOUBLE + #else + #undef UNITY_INCLUDE_DOUBLE + #endif + + #ifndef UNITY_EXCLUDE_FLOAT + #ifndef UNITY_DOUBLE_TYPE + #define UNITY_DOUBLE_TYPE double + #endif + typedef UNITY_FLOAT UNITY_DOUBLE; + /* For parameter in UnityPrintFloat(UNITY_DOUBLE), which aliases to double or float */ + #endif + +#else + + /* Double Floating Point Support */ + #ifndef UNITY_DOUBLE_PRECISION + #define UNITY_DOUBLE_PRECISION (1e-12) + #endif + + #ifndef UNITY_DOUBLE_TYPE + #define UNITY_DOUBLE_TYPE double + #endif + typedef UNITY_DOUBLE_TYPE UNITY_DOUBLE; + +#endif + +/*------------------------------------------------------- + * Output Method: stdout (DEFAULT) + *-------------------------------------------------------*/ +#ifndef UNITY_OUTPUT_CHAR + /* Default to using putchar, which is defined in stdio.h */ + #include + #define UNITY_OUTPUT_CHAR(a) (void)putchar(a) +#else + /* If defined as something else, make sure we declare it here so it's ready for use */ + #ifdef UNITY_OUTPUT_CHAR_HEADER_DECLARATION + extern void UNITY_OUTPUT_CHAR_HEADER_DECLARATION; + #endif +#endif + +#ifndef UNITY_OUTPUT_FLUSH + #ifdef UNITY_USE_FLUSH_STDOUT + /* We want to use the stdout flush utility */ + #include + #define UNITY_OUTPUT_FLUSH() (void)fflush(stdout) + #else + /* We've specified nothing, therefore flush should just be ignored */ + #define UNITY_OUTPUT_FLUSH() (void)0 + #endif +#else + /* If defined as something else, make sure we declare it here so it's ready for use */ + #ifdef UNITY_OUTPUT_FLUSH_HEADER_DECLARATION + extern void UNITY_OUTPUT_FLUSH_HEADER_DECLARATION; + #endif +#endif + +#ifndef UNITY_OUTPUT_FLUSH +#define UNITY_FLUSH_CALL() +#else +#define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH() +#endif + +#ifndef UNITY_PRINT_EOL +#define UNITY_PRINT_EOL() UNITY_OUTPUT_CHAR('\n') +#endif + +#ifndef UNITY_OUTPUT_START +#define UNITY_OUTPUT_START() +#endif + +#ifndef UNITY_OUTPUT_COMPLETE +#define UNITY_OUTPUT_COMPLETE() +#endif + +#ifdef UNITY_INCLUDE_EXEC_TIME + #if !defined(UNITY_EXEC_TIME_START) && \ + !defined(UNITY_EXEC_TIME_STOP) && \ + !defined(UNITY_PRINT_EXEC_TIME) && \ + !defined(UNITY_TIME_TYPE) + /* If none any of these macros are defined then try to provide a default implementation */ + + #if defined(UNITY_CLOCK_MS) + /* This is a simple way to get a default implementation on platforms that support getting a millisecond counter */ + #define UNITY_TIME_TYPE UNITY_UINT + #define UNITY_EXEC_TIME_START() Unity.CurrentTestStartTime = UNITY_CLOCK_MS() + #define UNITY_EXEC_TIME_STOP() Unity.CurrentTestStopTime = UNITY_CLOCK_MS() + #define UNITY_PRINT_EXEC_TIME() { \ + UNITY_UINT execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime); \ + UnityPrint(" ("); \ + UnityPrintNumberUnsigned(execTimeMs); \ + UnityPrint(" ms)"); \ + } + #elif defined(_WIN32) + #include + #define UNITY_TIME_TYPE clock_t + #define UNITY_GET_TIME(t) t = (clock_t)((clock() * 1000) / CLOCKS_PER_SEC) + #define UNITY_EXEC_TIME_START() UNITY_GET_TIME(Unity.CurrentTestStartTime) + #define UNITY_EXEC_TIME_STOP() UNITY_GET_TIME(Unity.CurrentTestStopTime) + #define UNITY_PRINT_EXEC_TIME() { \ + UNITY_UINT execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime); \ + UnityPrint(" ("); \ + UnityPrintNumberUnsigned(execTimeMs); \ + UnityPrint(" ms)"); \ + } + #elif defined(__unix__) || defined(__APPLE__) + #include + #define UNITY_TIME_TYPE struct timespec + #define UNITY_GET_TIME(t) clock_gettime(CLOCK_MONOTONIC, &t) + #define UNITY_EXEC_TIME_START() UNITY_GET_TIME(Unity.CurrentTestStartTime) + #define UNITY_EXEC_TIME_STOP() UNITY_GET_TIME(Unity.CurrentTestStopTime) + #define UNITY_PRINT_EXEC_TIME() { \ + UNITY_UINT execTimeMs = ((Unity.CurrentTestStopTime.tv_sec - Unity.CurrentTestStartTime.tv_sec) * 1000L); \ + execTimeMs += ((Unity.CurrentTestStopTime.tv_nsec - Unity.CurrentTestStartTime.tv_nsec) / 1000000L); \ + UnityPrint(" ("); \ + UnityPrintNumberUnsigned(execTimeMs); \ + UnityPrint(" ms)"); \ + } + #endif + #endif +#endif + +#ifndef UNITY_EXEC_TIME_START +#define UNITY_EXEC_TIME_START() do { /* nothing*/ } while (0) +#endif + +#ifndef UNITY_EXEC_TIME_STOP +#define UNITY_EXEC_TIME_STOP() do { /* nothing*/ } while (0) +#endif + +#ifndef UNITY_TIME_TYPE +#define UNITY_TIME_TYPE UNITY_UINT +#endif + +#ifndef UNITY_PRINT_EXEC_TIME +#define UNITY_PRINT_EXEC_TIME() do { /* nothing*/ } while (0) +#endif + +/*------------------------------------------------------- + * Footprint + *-------------------------------------------------------*/ + +#ifndef UNITY_LINE_TYPE +#define UNITY_LINE_TYPE UNITY_UINT +#endif + +#ifndef UNITY_COUNTER_TYPE +#define UNITY_COUNTER_TYPE UNITY_UINT +#endif + +/*------------------------------------------------------- + * Internal Structs Needed + *-------------------------------------------------------*/ + +typedef void (*UnityTestFunction)(void); + +#define UNITY_DISPLAY_RANGE_INT (0x10) +#define UNITY_DISPLAY_RANGE_UINT (0x20) +#define UNITY_DISPLAY_RANGE_HEX (0x40) +#define UNITY_DISPLAY_RANGE_CHAR (0x80) + +typedef enum +{ + UNITY_DISPLAY_STYLE_INT = (UNITY_INT_WIDTH / 8) + UNITY_DISPLAY_RANGE_INT, + UNITY_DISPLAY_STYLE_INT8 = 1 + UNITY_DISPLAY_RANGE_INT, + UNITY_DISPLAY_STYLE_INT16 = 2 + UNITY_DISPLAY_RANGE_INT, + UNITY_DISPLAY_STYLE_INT32 = 4 + UNITY_DISPLAY_RANGE_INT, +#ifdef UNITY_SUPPORT_64 + UNITY_DISPLAY_STYLE_INT64 = 8 + UNITY_DISPLAY_RANGE_INT, +#endif + + UNITY_DISPLAY_STYLE_UINT = (UNITY_INT_WIDTH / 8) + UNITY_DISPLAY_RANGE_UINT, + UNITY_DISPLAY_STYLE_UINT8 = 1 + UNITY_DISPLAY_RANGE_UINT, + UNITY_DISPLAY_STYLE_UINT16 = 2 + UNITY_DISPLAY_RANGE_UINT, + UNITY_DISPLAY_STYLE_UINT32 = 4 + UNITY_DISPLAY_RANGE_UINT, +#ifdef UNITY_SUPPORT_64 + UNITY_DISPLAY_STYLE_UINT64 = 8 + UNITY_DISPLAY_RANGE_UINT, +#endif + + UNITY_DISPLAY_STYLE_HEX8 = 1 + UNITY_DISPLAY_RANGE_HEX, + UNITY_DISPLAY_STYLE_HEX16 = 2 + UNITY_DISPLAY_RANGE_HEX, + UNITY_DISPLAY_STYLE_HEX32 = 4 + UNITY_DISPLAY_RANGE_HEX, +#ifdef UNITY_SUPPORT_64 + UNITY_DISPLAY_STYLE_HEX64 = 8 + UNITY_DISPLAY_RANGE_HEX, +#endif + + UNITY_DISPLAY_STYLE_CHAR = 1 + UNITY_DISPLAY_RANGE_CHAR + UNITY_DISPLAY_RANGE_INT, + + UNITY_DISPLAY_STYLE_UNKNOWN +} UNITY_DISPLAY_STYLE_T; + +typedef enum +{ + UNITY_WITHIN = 0x0, + UNITY_EQUAL_TO = 0x1, + UNITY_GREATER_THAN = 0x2, + UNITY_GREATER_OR_EQUAL = 0x2 + UNITY_EQUAL_TO, + UNITY_SMALLER_THAN = 0x4, + UNITY_SMALLER_OR_EQUAL = 0x4 + UNITY_EQUAL_TO, + UNITY_NOT_EQUAL = 0x0, + UNITY_UNKNOWN +} UNITY_COMPARISON_T; + +#ifndef UNITY_EXCLUDE_FLOAT +typedef enum UNITY_FLOAT_TRAIT +{ + UNITY_FLOAT_IS_NOT_INF = 0, + UNITY_FLOAT_IS_INF, + UNITY_FLOAT_IS_NOT_NEG_INF, + UNITY_FLOAT_IS_NEG_INF, + UNITY_FLOAT_IS_NOT_NAN, + UNITY_FLOAT_IS_NAN, + UNITY_FLOAT_IS_NOT_DET, + UNITY_FLOAT_IS_DET, + UNITY_FLOAT_INVALID_TRAIT +} UNITY_FLOAT_TRAIT_T; +#endif + +typedef enum +{ + UNITY_ARRAY_TO_VAL = 0, + UNITY_ARRAY_TO_ARRAY, + UNITY_ARRAY_UNKNOWN +} UNITY_FLAGS_T; + +struct UNITY_STORAGE_T +{ + const char* TestFile; + const char* CurrentTestName; +#ifndef UNITY_EXCLUDE_DETAILS + const char* CurrentDetail1; + const char* CurrentDetail2; +#endif + UNITY_LINE_TYPE CurrentTestLineNumber; + UNITY_COUNTER_TYPE NumberOfTests; + UNITY_COUNTER_TYPE TestFailures; + UNITY_COUNTER_TYPE TestIgnores; + UNITY_COUNTER_TYPE CurrentTestFailed; + UNITY_COUNTER_TYPE CurrentTestIgnored; +#ifdef UNITY_INCLUDE_EXEC_TIME + UNITY_TIME_TYPE CurrentTestStartTime; + UNITY_TIME_TYPE CurrentTestStopTime; +#endif +#ifndef UNITY_EXCLUDE_SETJMP_H + jmp_buf AbortFrame; +#endif +}; + +extern struct UNITY_STORAGE_T Unity; + +/*------------------------------------------------------- + * Test Suite Management + *-------------------------------------------------------*/ + +void UnityBegin(const char* filename); +int UnityEnd(void); +void UnitySetTestFile(const char* filename); +void UnityConcludeTest(void); + +#ifndef RUN_TEST +void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum); +#else +#define UNITY_SKIP_DEFAULT_RUNNER +#endif + +/*------------------------------------------------------- + * Details Support + *-------------------------------------------------------*/ + +#ifdef UNITY_EXCLUDE_DETAILS +#define UNITY_CLR_DETAILS() +#define UNITY_SET_DETAIL(d1) +#define UNITY_SET_DETAILS(d1,d2) +#else +#define UNITY_CLR_DETAILS() do { Unity.CurrentDetail1 = 0; Unity.CurrentDetail2 = 0; } while (0) +#define UNITY_SET_DETAIL(d1) do { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = 0; } while (0) +#define UNITY_SET_DETAILS(d1,d2) do { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = (d2); } while (0) + +#ifndef UNITY_DETAIL1_NAME +#define UNITY_DETAIL1_NAME "Function" +#endif + +#ifndef UNITY_DETAIL2_NAME +#define UNITY_DETAIL2_NAME "Argument" +#endif +#endif + +#ifdef UNITY_PRINT_TEST_CONTEXT +void UNITY_PRINT_TEST_CONTEXT(void); +#endif + +/*------------------------------------------------------- + * Test Output + *-------------------------------------------------------*/ + +void UnityPrint(const char* string); + +#ifdef UNITY_INCLUDE_PRINT_FORMATTED +void UnityPrintF(const UNITY_LINE_TYPE line, const char* format, ...); +#endif + +void UnityPrintLen(const char* string, const UNITY_UINT32 length); +void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number); +void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style); +void UnityPrintNumber(const UNITY_INT number_to_print); +void UnityPrintNumberUnsigned(const UNITY_UINT number); +void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print); + +#ifndef UNITY_EXCLUDE_FLOAT_PRINT +void UnityPrintFloat(const UNITY_DOUBLE input_number); +#endif + +/*------------------------------------------------------- + * Test Assertion Functions + *------------------------------------------------------- + * Use the macros below this section instead of calling + * these directly. The macros have a consistent naming + * convention and will pull in file and line information + * for you. */ + +void UnityAssertEqualNumber(const UNITY_INT expected, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style); + +void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, + const UNITY_INT actual, + const UNITY_COMPARISON_T compare, + const char *msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style); + +void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, + UNITY_INTERNAL_PTR actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style, + const UNITY_FLAGS_T flags); + +void UnityAssertBits(const UNITY_INT mask, + const UNITY_INT expected, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber); + +void UnityAssertEqualString(const char* expected, + const char* actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber); + +void UnityAssertEqualStringLen(const char* expected, + const char* actual, + const UNITY_UINT32 length, + const char* msg, + const UNITY_LINE_TYPE lineNumber); + +void UnityAssertEqualStringArray( UNITY_INTERNAL_PTR expected, + const char** actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags); + +void UnityAssertEqualMemory( UNITY_INTERNAL_PTR expected, + UNITY_INTERNAL_PTR actual, + const UNITY_UINT32 length, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags); + +void UnityAssertNumbersWithin(const UNITY_UINT delta, + const UNITY_INT expected, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style); + +void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, + UNITY_INTERNAL_PTR expected, + UNITY_INTERNAL_PTR actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style, + const UNITY_FLAGS_T flags); + +#ifndef UNITY_EXCLUDE_SETJMP_H +UNITY_NORETURN void UnityFail(const char* message, const UNITY_LINE_TYPE line); +UNITY_NORETURN void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); +#else +void UnityFail(const char* message, const UNITY_LINE_TYPE line); +void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); +#endif + +void UnityMessage(const char* message, const UNITY_LINE_TYPE line); + +#ifndef UNITY_EXCLUDE_FLOAT +void UnityAssertFloatsWithin(const UNITY_FLOAT delta, + const UNITY_FLOAT expected, + const UNITY_FLOAT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber); + +void UnityAssertFloatsNotWithin(const UNITY_FLOAT delta, + const UNITY_FLOAT expected, + const UNITY_FLOAT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber); + +void UnityAssertGreaterOrLessFloat(const UNITY_FLOAT threshold, + const UNITY_FLOAT actual, + const UNITY_COMPARISON_T compare, + const char* msg, + const UNITY_LINE_TYPE linenumber); + +void UnityAssertWithinFloatArray(const UNITY_FLOAT delta, + UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected, + UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags); + +void UnityAssertFloatSpecial(const UNITY_FLOAT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLOAT_TRAIT_T style); +#endif + +#ifndef UNITY_EXCLUDE_DOUBLE +void UnityAssertDoublesWithin(const UNITY_DOUBLE delta, + const UNITY_DOUBLE expected, + const UNITY_DOUBLE actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber); + +void UnityAssertDoublesNotWithin(const UNITY_DOUBLE delta, + const UNITY_DOUBLE expected, + const UNITY_DOUBLE actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber); + +void UnityAssertGreaterOrLessDouble(const UNITY_DOUBLE threshold, + const UNITY_DOUBLE actual, + const UNITY_COMPARISON_T compare, + const char* msg, + const UNITY_LINE_TYPE linenumber); + +void UnityAssertWithinDoubleArray(const UNITY_DOUBLE delta, + UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expected, + UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags); + +void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLOAT_TRAIT_T style); +#endif + +/*------------------------------------------------------- + * Helpers + *-------------------------------------------------------*/ + +UNITY_INTERNAL_PTR UnityNumToPtr(const UNITY_INT num, const UNITY_UINT8 size); +#ifndef UNITY_EXCLUDE_FLOAT +UNITY_INTERNAL_PTR UnityFloatToPtr(const float num); +#endif +#ifndef UNITY_EXCLUDE_DOUBLE +UNITY_INTERNAL_PTR UnityDoubleToPtr(const double num); +#endif + +/*------------------------------------------------------- + * Error Strings We Might Need + *-------------------------------------------------------*/ + +extern const char UnityStrOk[]; +extern const char UnityStrPass[]; +extern const char UnityStrFail[]; +extern const char UnityStrIgnore[]; + +extern const char UnityStrErrFloat[]; +extern const char UnityStrErrDouble[]; +extern const char UnityStrErr64[]; +extern const char UnityStrErrShorthand[]; + +/*------------------------------------------------------- + * Test Running Macros + *-------------------------------------------------------*/ + +#ifndef UNITY_EXCLUDE_SETJMP_H +#define TEST_PROTECT() (setjmp(Unity.AbortFrame) == 0) +#define TEST_ABORT() longjmp(Unity.AbortFrame, 1) +#else +#define TEST_PROTECT() 1 +#define TEST_ABORT() return +#endif + +/* Automatically enable variadic macros support, if it not enabled before */ +#ifndef UNITY_SUPPORT_VARIADIC_MACROS + #ifdef __STDC_VERSION__ + #if __STDC_VERSION__ >= 199901L + #define UNITY_SUPPORT_VARIADIC_MACROS + #endif + #endif +#endif + +/* This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__) */ +#ifndef RUN_TEST +#ifdef UNITY_SUPPORT_VARIADIC_MACROS +#define RUN_TEST(...) RUN_TEST_AT_LINE(__VA_ARGS__, __LINE__, throwaway) +#define RUN_TEST_AT_LINE(func, line, ...) UnityDefaultTestRun(func, #func, line) +#endif +#endif + +/* Enable default macros for masking param tests test cases */ +#ifdef UNITY_SUPPORT_TEST_CASES + #ifdef UNITY_SUPPORT_VARIADIC_MACROS + #if !defined(TEST_CASE) && !defined(UNITY_EXCLUDE_TEST_CASE) + #define TEST_CASE(...) + #endif + #if !defined(TEST_RANGE) && !defined(UNITY_EXCLUDE_TEST_RANGE) + #define TEST_RANGE(...) + #endif + #endif +#endif + +/* If we can't do the tricky version, we'll just have to require them to always include the line number */ +#ifndef RUN_TEST +#ifdef CMOCK +#define RUN_TEST(func, num) UnityDefaultTestRun(func, #func, num) +#else +#define RUN_TEST(func) UnityDefaultTestRun(func, #func, __LINE__) +#endif +#endif + +#define TEST_LINE_NUM (Unity.CurrentTestLineNumber) +#define TEST_IS_IGNORED (Unity.CurrentTestIgnored) +#define UNITY_NEW_TEST(a) \ + Unity.CurrentTestName = (a); \ + Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)(__LINE__); \ + Unity.NumberOfTests++; + +#ifndef UNITY_BEGIN +#define UNITY_BEGIN() UnityBegin(__FILE__) +#endif + +#ifndef UNITY_END +#define UNITY_END() UnityEnd() +#endif + +#ifndef UNITY_SHORTHAND_AS_INT +#ifndef UNITY_SHORTHAND_AS_MEM +#ifndef UNITY_SHORTHAND_AS_NONE +#ifndef UNITY_SHORTHAND_AS_RAW +#define UNITY_SHORTHAND_AS_OLD +#endif +#endif +#endif +#endif + +/*----------------------------------------------- + * Command Line Argument Support + *-----------------------------------------------*/ + +#ifdef UNITY_USE_COMMAND_LINE_ARGS +int UnityParseOptions(int argc, char** argv); +int UnityTestMatches(void); +#endif + +/*------------------------------------------------------- + * Basic Fail and Ignore + *-------------------------------------------------------*/ + +#define UNITY_TEST_FAIL(line, message) UnityFail( (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_IGNORE(line, message) UnityIgnore( (message), (UNITY_LINE_TYPE)(line)) + +/*------------------------------------------------------- + * Test Asserts + *-------------------------------------------------------*/ + +#define UNITY_TEST_ASSERT(condition, line, message) do { if (condition) { /* nothing*/ } else { UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message)); } } while (0) +#define UNITY_TEST_ASSERT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) == NULL), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_NOT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) == 0), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_NOT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) != 0), (UNITY_LINE_TYPE)(line), (message)) + +#define UNITY_TEST_ASSERT_EQUAL_INT(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_EQUAL_INT8(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_EQUAL_INT16(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_EQUAL_INT32(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_EQUAL_UINT(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_EQUAL_UINT8(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_UINT8 )(expected), (UNITY_INT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_EQUAL_UINT16(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_UINT16)(expected), (UNITY_INT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_EQUAL_UINT32(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_EQUAL_HEX8(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_EQUAL_HEX16(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_EQUAL_CHAR(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) +#define UNITY_TEST_ASSERT_BITS(mask, expected, actual, line, message) UnityAssertBits((UNITY_INT)(mask), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line)) + +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_NOT_EQUAL_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_GREATER_THAN_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_GREATER_THAN_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_SMALLER_THAN_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 ) (threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16) (threshold), (UNITY_INT)(UNITY_INT16) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32) (threshold), (UNITY_INT)(UNITY_INT32) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 ) (threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin( (delta), (UNITY_INT) (expected), (UNITY_INT) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 ) (expected), (UNITY_INT)(UNITY_INT8 ) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_INT16) (expected), (UNITY_INT)(UNITY_INT16) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_INT32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_INT32) (expected), (UNITY_INT)(UNITY_INT32) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin( (delta), (UNITY_INT) (expected), (UNITY_INT) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_UINT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_UINT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_UINT32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_HEX8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_CHAR_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 ) (expected), (UNITY_INT)(UNITY_INT8 ) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR, UNITY_ARRAY_TO_ARRAY) + + +#define UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, line, message) UnityAssertEqualNumber((UNITY_PTR_TO_INT)(expected), (UNITY_PTR_TO_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER) +#define UNITY_TEST_ASSERT_EQUAL_STRING(expected, actual, line, message) UnityAssertEqualString((const char*)(expected), (const char*)(actual), (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len, line, message) UnityAssertEqualStringLen((const char*)(expected), (const char*)(actual), (UNITY_UINT32)(len), (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), 1, (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) + +#define UNITY_TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualStringArray((UNITY_INTERNAL_PTR)(expected), (const char**)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_CHAR_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR, UNITY_ARRAY_TO_ARRAY) + +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT) (expected), (UNITY_INT_WIDTH / 8)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT16 )(expected), 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT32 )(expected), 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT) (expected), (UNITY_INT_WIDTH / 8)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT16)(expected), 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT32)(expected), 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT16 )(expected), 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT32 )(expected), 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_PTR_TO_INT) (expected), (UNITY_POINTER_WIDTH / 8)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_STRING(expected, actual, num_elements, line, message) UnityAssertEqualStringArray((UNITY_INTERNAL_PTR)(expected), (const char**)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_CHAR(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR, UNITY_ARRAY_TO_VAL) + +#ifdef UNITY_SUPPORT_64 +#define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_EQUAL_HEX64(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT64)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT64)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT64)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_ARRAY) +#else +#define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_EQUAL_HEX64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#endif + +#ifdef UNITY_EXCLUDE_FLOAT +#define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_NOT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_LESS_THAN_FLOAT(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_LESS_OR_EQUAL_FLOAT(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#else +#define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UnityAssertFloatsWithin((UNITY_FLOAT)(delta), (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN(delta, expected, actual, line, message) UnityAssertFloatsNotWithin((UNITY_FLOAT)(delta), (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((UNITY_FLOAT)(expected) * (UNITY_FLOAT)UNITY_FLOAT_PRECISION, (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_NOT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN((UNITY_FLOAT)(expected) * (UNITY_FLOAT)UNITY_FLOAT_PRECISION, (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_FLOAT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertWithinFloatArray((UNITY_FLOAT)(delta), (const UNITY_FLOAT*)(expected), (const UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UnityAssertWithinFloatArray((UNITY_FLOAT)0, (const UNITY_FLOAT*)(expected), (const UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UnityAssertWithinFloatArray((UNITY_FLOAT)0, UnityFloatToPtr(expected), (const UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_LESS_THAN_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_LESS_OR_EQUAL_FLOAT(threshold, actual, line, message) UnityAssertGreaterOrLessFloat((UNITY_FLOAT)(threshold), (UNITY_FLOAT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_INF) +#define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NEG_INF) +#define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NAN) +#define UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_DET) +#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_INF) +#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_NEG_INF) +#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_NAN) +#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_DET) +#endif + +#ifdef UNITY_EXCLUDE_DOUBLE +#define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_NOT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_NOT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_LESS_THAN_DOUBLE(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#else +#define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesWithin((UNITY_DOUBLE)(delta), (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_DOUBLE_NOT_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesNotWithin((UNITY_DOUBLE)(delta), (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_NOT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_NOT_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_DOUBLE_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertWithinDoubleArray((UNITY_DOUBLE)(delta), (const UNITY_DOUBLE*)(expected), (const UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertWithinDoubleArray((UNITY_DOUBLE)0, (const UNITY_DOUBLE*)(expected), (const UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UnityAssertWithinDoubleArray((UNITY_DOUBLE)0, UnityDoubleToPtr(expected), (const UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_LESS_THAN_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(threshold, actual, line, message) UnityAssertGreaterOrLessDouble((UNITY_DOUBLE)(threshold), (UNITY_DOUBLE)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_INF) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NEG_INF) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NAN) +#define UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_DET) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_INF) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_NEG_INF) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_NAN) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_DET) +#endif + +/* End of UNITY_INTERNALS_H */ +#endif