mirror of
https://gitee.com/const-zpc/param.git
synced 2025-01-30 04:32:52 +08:00
commit
761e5b4b60
@ -1,170 +1,46 @@
|
||||
|
||||
#include "param.h"
|
||||
#include "param_demo.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define HEX_PRINTF(str, hex, len) \
|
||||
printf("%s: [%d] -> ", str, len);\
|
||||
for (int i = 0; i < (len); i++){printf("%02x ", hex[i]);}\
|
||||
printf("\n");
|
||||
|
||||
uint8_t sg_buf[500];
|
||||
|
||||
int main()
|
||||
{
|
||||
size_t length;
|
||||
InitParam(true);
|
||||
|
||||
printf("\nInit:\n");
|
||||
ShowAllParam(sg_ParamTable, sizeof(sg_ParamTable) / sizeof(ParamInfo_t));
|
||||
ShowAllParam();
|
||||
|
||||
/* 展示多种序列化方式效果 */
|
||||
g_test = 80;
|
||||
g_test_3 = -20.5;
|
||||
|
||||
length = Param_Serialize(sg_buf, sg_ParamTable, sizeof(sg_ParamTable) / sizeof(ParamInfo_t), 0, 0); // 普通序列化
|
||||
HEX_PRINTF("\n1- Serialize", sg_buf, length);
|
||||
SaveParam(false);
|
||||
ReloadParam(false);
|
||||
|
||||
length = Param_Serialize(sg_buf, sg_ParamTable, sizeof(sg_ParamTable) / sizeof(ParamInfo_t), 0, 1); // 编码序列化
|
||||
HEX_PRINTF("2- Serialize", sg_buf, length);
|
||||
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);
|
||||
|
||||
length = Param_Serialize(sg_buf, sg_ParamTable, sizeof(sg_ParamTable) / sizeof(ParamInfo_t), 1, 0); // 增加键值序列化
|
||||
HEX_PRINTF("3- Serialize", sg_buf, length);
|
||||
ret = PARAM_DAT_SET_NEW_VALUE(g_test_6, 101, PARAM_DEF);
|
||||
printf("ret = %d, g_test_6 = %d\n", ret, g_test_6);
|
||||
|
||||
length = Param_Serialize(sg_buf, sg_ParamTable, sizeof(sg_ParamTable) / sizeof(ParamInfo_t), 1, 1); // 增加键值并编码序列化
|
||||
HEX_PRINTF("4- Serialize", sg_buf, length);
|
||||
ret = PARAM_DAT_SET_NEW_VALUE(g_test_6, 101, PARAM_NONE);
|
||||
printf("ret = %d, g_test_6 = %d\n", ret, g_test_6);
|
||||
|
||||
/* 直接使用该值修改后显示 */
|
||||
test = -50;
|
||||
test_2 = 10;
|
||||
test_3 = 8.265;
|
||||
sprintf(test_str, "%s", "ertb");
|
||||
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);
|
||||
|
||||
printf("\nchange:\n");
|
||||
ShowAllParam(sg_ParamTable, sizeof(sg_ParamTable) / sizeof(ParamInfo_t));
|
||||
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_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));
|
||||
PARAM_STR_SET_NEW_VALUE(g_test_str, "123aa1245249", PARAM_DEF);
|
||||
printf("ret = %d, g_test_str = %s\n", ret, g_test_str);
|
||||
|
||||
/* 使用完整信息接口序列化数据(无序列化选项,可修改看效果) */
|
||||
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);
|
||||
PARAM_STR_SET_NEW_VALUE(g_test_str, "123aa945457", PARAM_MIN_MAX);
|
||||
printf("ret = %d, g_test_str = %s\n", ret, g_test_str);
|
||||
|
||||
/* 使用完整信息接口序列化数据(序列化选项拉满,可修改看效果) */
|
||||
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); // 展示信息
|
||||
ShowAllParam();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -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
|
||||
|
433
Demo/cmd_shell/param_demo.c
Normal file
433
Demo/cmd_shell/param_demo.c
Normal file
@ -0,0 +1,433 @@
|
||||
#include "param_demo.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
/****************************************** 模拟储存设备操作 ******************************************************/
|
||||
// 储存空间定义
|
||||
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);
|
||||
}
|
29
Demo/cmd_shell/param_demo.h
Normal file
29
Demo/cmd_shell/param_demo.h
Normal file
@ -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
|
@ -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 定义字符串参数, 具有默认值和长度校验
|
||||
*
|
||||
* @param name 参数名(变量名)
|
||||
* @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 _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
|
||||
|
||||
|
||||
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);
|
||||
#define PARAM_NONE 0
|
||||
#define PARAM_DEF 1
|
||||
#define PARAM_MIN_MAX 2
|
||||
|
||||
|
||||
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);
|
||||
#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 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 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
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
/** 字符串参数长度需要使用的字节(1:最长可定义254长度的字符串参数, 2:最长可定义63335长度的字符串参数) */
|
||||
#define PARAM_STRING_SIZE 1
|
||||
/**
|
||||
* @brief 使用64位的参数类型
|
||||
* 0,禁止; 1,使能
|
||||
*/
|
||||
#define PARAM_USE_64_BIT_LENGTH 1
|
||||
|
||||
/** 参数名字最大定义长度(包括结束符) */
|
||||
#define PARAM_NAME_MAX_LENGTH 32
|
||||
/** 参数名字最大定义长度(包括结束符'\0'), 因此小于或等于1则禁用参数名字字符串相关功能 */
|
||||
#define PARAM_NAME_MAX_LENGTH 15
|
||||
|
||||
#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
|
||||
|
||||
#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
|
||||
|
@ -16,28 +16,24 @@
|
||||
#define _PARAM_TYPE_H_
|
||||
|
||||
/* Includes ----------------------------------------------------------------------------------------------------------*/
|
||||
#include "param_cfg.h"
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
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
|
||||
|
@ -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
|
1114
Param/src/param.c
1114
Param/src/param.c
File diff suppressed because it is too large
Load Diff
@ -1,719 +0,0 @@
|
||||
#include "stream.h"
|
||||
#include "param_cfg.h"
|
||||
#include <string.h>
|
||||
|
||||
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;
|
||||
}
|
195
README.md
195
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
|
||||
// 首先需要在头文件声明
|
||||
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);
|
||||
|
||||
|
||||
"跨设备的序列化(携带基础信息)": [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
|
||||
//函数中使用
|
||||
int main()
|
||||
{
|
||||
//方法一:
|
||||
// 对参数g_test_6设置新的值50,如果超出限定范围则不处理
|
||||
PARAM_DAT_SET_NEW_VALUE(g_test_6, 50, PARAM_NONE);
|
||||
|
||||
"跨设备的序列化(携带所有信息)": [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
|
||||
// 对参数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);
|
||||
}
|
||||
```
|
||||
|
||||
## 使用说明
|
||||
1. 通过函数 Param_ModifyById、Param_ModifyByName 限制修改参数
|
||||
2. 调用函数 Param_Serialize 对参数序列化, 保存至储存芯片中
|
||||
3. 从储存芯片读取数据后,调用 Param_Parse 反序列化得到参数,同时进行参数范围校验
|
||||
通过函数去操作参数示例片段代码
|
||||
|
||||
```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);
|
||||
}
|
||||
```
|
||||
|
||||
序列化 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
|
||||
|
||||
```
|
||||
|
||||
## 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. 了解更多可关注微信公众号
|
||||
|
||||
1. CSDN 博客 [大橙子疯](https://blog.csdn.net/qq_24130227?spm=1010.2135.3001.5343)
|
||||
2. 联系邮箱 const_zpc@163.com
|
||||
3. 了解更多可关注微信公众号
|
||||
|
||||
![大橙子疯嵌入式](微信公众号.jpg)
|
22
test/makefile
Normal file
22
test/makefile
Normal file
@ -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}
|
490
test/param_test.c
Normal file
490
test/param_test.c
Normal file
@ -0,0 +1,490 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <float.h>
|
||||
#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;
|
||||
}
|
2466
test/unity/unity.c
Normal file
2466
test/unity/unity.c
Normal file
File diff suppressed because it is too large
Load Diff
687
test/unity/unity.h
Normal file
687
test/unity/unity.h
Normal file
@ -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 <stdint.h>
|
||||
* - define UNITY_EXCLUDE_LIMITS_H to stop attempting to look in <limits.h>
|
||||
* - 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
|
1145
test/unity/unity_internals.h
Normal file
1145
test/unity/unity_internals.h
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user