Skip to content

Commit

Permalink
ip parse test
Browse files Browse the repository at this point in the history
  • Loading branch information
openshwprojects committed Feb 26, 2025
1 parent e67d605 commit 23e6707
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/cmnds/cmd_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion src/driver/drv_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down

0 comments on commit 23e6707

Please sign in to comment.