From 23e67076c3bf9b0b035ed2bb77066238277f76c9 Mon Sep 17 00:00:00 2001 From: Tester23 <85486843+openshwprojects@users.noreply.github.com> Date: Wed, 26 Feb 2025 22:32:11 +0100 Subject: [PATCH] ip parse test --- src/cmnds/cmd_test.c | 23 +++++++++++++++++++++++ src/driver/drv_test.c | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/cmnds/cmd_test.c b/src/cmnds/cmd_test.c index d5639f013..cd6cbc4f9 100644 --- a/src/cmnds/cmd_test.c +++ b/src/cmnds/cmd_test.c @@ -431,6 +431,27 @@ static commandResult_t CMD_TestChannelSetToExpression(const void* context, const } return CMD_RES_ERROR; } +static commandResult_t CMD_TestParseIP(const void* context, const char* cmd, const char* args, int cmdFlags) { + byte ip[4]; + str_to_ip("192.168.0.123", ip); + if (ip[0] != 192 || ip[1] != 168 || ip[2] != 0 || ip[3] != 123) { + return CMD_RES_ERROR; + } + return CMD_RES_OK; +} +static commandResult_t CMD_TestIPtoStr(const void* context, const char* cmd, const char* args, int cmdFlags) { + byte ip[4]; + ip[0] = 192; + ip[1] = 168; + ip[2] = 0; + ip[3] = 123; + char buff[64]; + convert_IP_to_string(buff, ip); + if (strcmp(buff,"192.168.0.123")) { + return CMD_RES_ERROR; + } + return CMD_RES_OK; +} int CMD_InitTestCommands(){ @@ -527,6 +548,8 @@ int CMD_InitTestCommands(){ CMD_RegisterCommand("TestMemcpy", CMD_TestMemcpy, NULL); CMD_RegisterCommand("TestMemcmp", CMD_TestMemcmp, NULL); CMD_RegisterCommand("TestChannelSetToExpression", CMD_TestChannelSetToExpression, NULL); + CMD_RegisterCommand("TestParseIP", CMD_TestParseIP, NULL); + CMD_RegisterCommand("TestIPtoStr", CMD_TestIPtoStr, NULL); return 0; } diff --git a/src/driver/drv_test.c b/src/driver/drv_test.c index 0ee7403df..ca4c89471 100644 --- a/src/driver/drv_test.c +++ b/src/driver/drv_test.c @@ -32,7 +32,9 @@ const char *g_testCommands[] = { "TestMemset", "TestMemcpy", "TestMemcmp", - "TestChannelSetToExpression" + "TestChannelSetToExpression", + "TestParseIP", + "TestIPtoStr" }; static int g_numTestCommands = sizeof(g_testCommands) / sizeof(g_testCommands[0]);