fix #43 added a config interface to change the newline character expected

This commit is contained in:
prozessorkern
2020-03-27 18:34:43 +01:00
parent c2e4324236
commit 3b99ad2a56
5 changed files with 79 additions and 17 deletions

View File

@@ -459,7 +459,7 @@ TEST_CASE( "shellmatta configure disable echo" ) {
write_length = 0u;
/* turn off echo now */
ret = shellmatta_configure(handle, SHELLMATTA_MODE_INSERT, false);
ret = shellmatta_configure(handle, SHELLMATTA_MODE_INSERT, false, '\r');
CHECK( ret == SHELLMATTA_OK );
/* check with echo disabled */
@@ -490,7 +490,7 @@ TEST_CASE( "shellmatta configure mode" ) {
NULL,
writeFct);
shellmatta_addCmd(handle, &doSomethingCmd);
ret = shellmatta_configure(handle, SHELLMATTA_MODE_INSERT, false);
ret = shellmatta_configure(handle, SHELLMATTA_MODE_INSERT, false, '\r');
write_callCnt = 0u;
memset(write_data, 0, sizeof(write_data));
@@ -507,7 +507,7 @@ TEST_CASE( "shellmatta configure mode" ) {
write_length = 0u;
/* check with overwrite mode */
ret = shellmatta_configure(handle, SHELLMATTA_MODE_OVERWRITE, false);
ret = shellmatta_configure(handle, SHELLMATTA_MODE_OVERWRITE, false, '\r');
CHECK( ret == SHELLMATTA_OK );
/* check with echo disabled */
@@ -517,3 +517,49 @@ TEST_CASE( "shellmatta configure mode" ) {
REQUIRE( strcmp(dummyData2, write_data) == 0);
}
TEST_CASE( "shellmatta configure delimiter" ) {
shellmatta_instance_t inst;
shellmatta_handle_t handle;
shellmatta_retCode_t ret;
char buffer[1024];
char historyBuffer[1024];
char *dummyData = (char*)"doSomething argument - length: 20\r\nshellmatta->";
shellmatta_doInit( &inst,
&handle,
buffer,
sizeof(buffer),
historyBuffer,
sizeof(historyBuffer),
"shellmatta->",
NULL,
writeFct);
shellmatta_addCmd(handle, &doSomethingCmd);
ret = shellmatta_configure(handle, SHELLMATTA_MODE_INSERT, false, '\r');
write_callCnt = 0u;
memset(write_data, 0, sizeof(write_data));
write_length = 0u;
/* check with insert mode */
shellmatta_processData(handle, (char*)"doSomething argument\n", 21u);
CHECK( write_length == 0u);
shellmatta_resetShell(handle, false);
write_callCnt = 0u;
memset(write_data, 0, sizeof(write_data));
write_length = 0u;
/* check with changed delimiter mode */
ret = shellmatta_configure(handle, SHELLMATTA_MODE_INSERT, false, '\n');
CHECK( ret == SHELLMATTA_OK );
/* check with echo disabled */
shellmatta_processData(handle, (char*)"doSomething argument\n", 21u);
CHECK( write_length == strlen(dummyData));
REQUIRE( strcmp(dummyData, write_data) == 0);
}