added remove api + small integratio test close #9
This commit is contained in:
@@ -161,3 +161,68 @@ TEST_CASE( "shellmatta heredoc test" ) {
|
||||
CHECK( doSomethingLength == 20u);
|
||||
REQUIRE( strcmp(dummyData, doSomethingArguments) == 0);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE( "shellmatta remove function" ) {
|
||||
|
||||
shellmatta_instance_t inst;
|
||||
shellmatta_handle_t handle;
|
||||
char buffer[1024];
|
||||
char historyBuffer[1024];
|
||||
char *dummyData = (char*)"h\r\n"
|
||||
"doSomething do Function does something use me, please\r\n"
|
||||
"help h Print this help text help\r\n"
|
||||
"\r\nshellmatta->";
|
||||
|
||||
shellmatta_doInit( &inst,
|
||||
&handle,
|
||||
buffer,
|
||||
sizeof(buffer),
|
||||
historyBuffer,
|
||||
sizeof(historyBuffer),
|
||||
"shellmatta->",
|
||||
NULL,
|
||||
writeFct);
|
||||
shellmatta_addCmd(handle, &doSomethingCmd);
|
||||
|
||||
write_callCnt = 0u;
|
||||
memset(write_data, 0, sizeof(write_data));
|
||||
write_length = 0u;
|
||||
|
||||
shellmatta_processData(handle, (char*)"h\r", 2);
|
||||
|
||||
CHECK( write_length == 123u);
|
||||
CHECK( strcmp(dummyData, write_data) == 0);
|
||||
|
||||
|
||||
write_callCnt = 0u;
|
||||
memset(write_data, 0, sizeof(write_data));
|
||||
write_length = 0u;
|
||||
|
||||
dummyData = (char*)"h 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"
|
||||
"\r\nshellmatta->";
|
||||
|
||||
shellmatta_processData(handle, (char*)"h 564 321 56 465 46\r", 20);
|
||||
|
||||
CHECK( write_length == 141u);
|
||||
CHECK( strcmp(dummyData, write_data) == 0);
|
||||
|
||||
write_callCnt = 0u;
|
||||
memset(write_data, 0, sizeof(write_data));
|
||||
write_length = 0u;
|
||||
|
||||
shellmatta_removeCmd(handle, &doSomethingCmd);
|
||||
shellmatta_processData(handle, (char*)"h 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"
|
||||
"\r\nshellmatta->";
|
||||
|
||||
printf("sdfsd sdf sdf sdf sdf sd fds\n%s", write_data);
|
||||
|
||||
CHECK( write_length == 72u);
|
||||
REQUIRE( strcmp(dummyData, write_data) == 0);
|
||||
|
||||
}
|
Reference in New Issue
Block a user