close #31 - made all command parameter except the command name optional + added and fixed tests
This commit is contained in:
@@ -33,6 +33,12 @@ static shellmatta_retCode_t doSomething(shellmatta_handle_t handle, const char *
|
||||
}
|
||||
shellmatta_cmd_t doSomethingCmd = {(char*)"doSomething", (char*)"do", (char*)"Function does something", (char*)"use me, please", doSomething, NULL};
|
||||
|
||||
static shellmatta_retCode_t empty(shellmatta_handle_t handle, const char *arguments, uint32_t length)
|
||||
{
|
||||
shellmatta_printf(handle, "empty - %s - length: %u", arguments, length);
|
||||
return SHELLMATTA_OK;
|
||||
}
|
||||
shellmatta_cmd_t emptyCmd = {(char*)"empty", NULL, NULL, NULL, empty, NULL};
|
||||
|
||||
TEST_CASE( "shellmatta empty function" ) {
|
||||
|
||||
@@ -69,9 +75,9 @@ TEST_CASE( "shellmatta help function" ) {
|
||||
shellmatta_handle_t handle;
|
||||
char buffer[1024];
|
||||
char historyBuffer[1024];
|
||||
char *dummyData = (char*)"h\r\n"
|
||||
char *dummyData = (char*)"?\r\n"
|
||||
"doSomething do Function does something use me, please\r\n"
|
||||
"help h Print this help text help\r\n"
|
||||
"help ? Print this help text help\r\n"
|
||||
"\r\nshellmatta->";
|
||||
|
||||
shellmatta_doInit( &inst,
|
||||
@@ -89,24 +95,26 @@ TEST_CASE( "shellmatta help function" ) {
|
||||
memset(write_data, 0, sizeof(write_data));
|
||||
write_length = 0u;
|
||||
|
||||
shellmatta_processData(handle, (char*)"h\r", 2);
|
||||
shellmatta_processData(handle, (char*)"?\r", 2);
|
||||
|
||||
CHECK( write_length == 123u);
|
||||
CHECK( strcmp(dummyData, write_data) == 0);
|
||||
|
||||
shellmatta_addCmd(handle, &emptyCmd);
|
||||
|
||||
write_callCnt = 0u;
|
||||
memset(write_data, 0, sizeof(write_data));
|
||||
write_length = 0u;
|
||||
|
||||
dummyData = (char*)"h 564 321 56 465 46\r\n"
|
||||
dummyData = (char*)"? 564 321 56 465 46\r\n"
|
||||
"doSomething do Function does something use me, please\r\n"
|
||||
"help h Print this help text help\r\n"
|
||||
"empty \r\n"
|
||||
"help ? Print this help text help\r\n"
|
||||
"\r\nshellmatta->";
|
||||
|
||||
shellmatta_processData(handle, (char*)"h 564 321 56 465 46\r", 20);
|
||||
shellmatta_processData(handle, (char*)"? 564 321 56 465 46\r", 20);
|
||||
|
||||
CHECK( write_length == 141u);
|
||||
CHECK( write_length == strlen(dummyData));
|
||||
CHECK( strcmp(dummyData, write_data) == 0);
|
||||
|
||||
|
||||
@@ -114,11 +122,11 @@ TEST_CASE( "shellmatta help function" ) {
|
||||
memset(write_data, 0, sizeof(write_data));
|
||||
write_length = 0u;
|
||||
|
||||
dummyData = (char*)"hr\r\n"
|
||||
"Command: hr not found"
|
||||
dummyData = (char*)"?r\r\n"
|
||||
"Command: ?r not found"
|
||||
"\r\nshellmatta->";
|
||||
|
||||
shellmatta_processData(handle, (char*)"hr\r", 3);
|
||||
shellmatta_processData(handle, (char*)"?r\r", 3);
|
||||
|
||||
CHECK( write_length == 39u);
|
||||
REQUIRE( strcmp(dummyData, write_data) == 0);
|
||||
@@ -169,9 +177,9 @@ TEST_CASE( "shellmatta remove function" ) {
|
||||
shellmatta_handle_t handle;
|
||||
char buffer[1024];
|
||||
char historyBuffer[1024];
|
||||
char *dummyData = (char*)"h\r\n"
|
||||
char *dummyData = (char*)"?\r\n"
|
||||
"doSomething do Function does something use me, please\r\n"
|
||||
"help h Print this help text help\r\n"
|
||||
"help ? Print this help text help\r\n"
|
||||
"\r\nshellmatta->";
|
||||
|
||||
shellmatta_doInit( &inst,
|
||||
@@ -189,7 +197,7 @@ TEST_CASE( "shellmatta remove function" ) {
|
||||
memset(write_data, 0, sizeof(write_data));
|
||||
write_length = 0u;
|
||||
|
||||
shellmatta_processData(handle, (char*)"h\r", 2);
|
||||
shellmatta_processData(handle, (char*)"?\r", 2);
|
||||
|
||||
CHECK( write_length == 123u);
|
||||
CHECK( strcmp(dummyData, write_data) == 0);
|
||||
@@ -199,12 +207,12 @@ TEST_CASE( "shellmatta remove function" ) {
|
||||
memset(write_data, 0, sizeof(write_data));
|
||||
write_length = 0u;
|
||||
|
||||
dummyData = (char*)"h 564 321 56 465 46\r\n"
|
||||
dummyData = (char*)"? 564 321 56 465 46\r\n"
|
||||
"doSomething do Function does something use me, please\r\n"
|
||||
"help h Print this help text help\r\n"
|
||||
"help ? Print this help text help\r\n"
|
||||
"\r\nshellmatta->";
|
||||
|
||||
shellmatta_processData(handle, (char*)"h 564 321 56 465 46\r", 20);
|
||||
shellmatta_processData(handle, (char*)"? 564 321 56 465 46\r", 20);
|
||||
|
||||
CHECK( write_length == 141u);
|
||||
CHECK( strcmp(dummyData, write_data) == 0);
|
||||
@@ -214,10 +222,10 @@ TEST_CASE( "shellmatta remove function" ) {
|
||||
write_length = 0u;
|
||||
|
||||
shellmatta_removeCmd(handle, &doSomethingCmd);
|
||||
shellmatta_processData(handle, (char*)"h 564 321 56 465 46\r", 20);
|
||||
shellmatta_processData(handle, (char*)"? 564 321 56 465 46\r", 20);
|
||||
|
||||
dummyData = (char*)"h 564 321 56 465 46\r\n"
|
||||
"help h Print this help text help\r\n"
|
||||
dummyData = (char*)"? 564 321 56 465 46\r\n"
|
||||
"help ? Print this help text help\r\n"
|
||||
"\r\nshellmatta->";
|
||||
|
||||
printf("sdfsd sdf sdf sdf sdf sd fds\n%s", write_data);
|
||||
|
Reference in New Issue
Block a user