|
@@ -377,8 +377,107 @@ TEST_CASE( "shellmatta reset no prompt heredoc" ) {
|
|
|
/* now the new command should be processed */
|
|
|
shellmatta_processData(handle, (char*)"?\r", 2);
|
|
|
|
|
|
- printf("%s", write_data);
|
|
|
-
|
|
|
CHECK( write_length == strlen(dummyData));
|
|
|
REQUIRE( strcmp(dummyData, write_data) == 0);
|
|
|
}
|
|
|
+
|
|
|
+TEST_CASE( "shellmatta configure disable echo" ) {
|
|
|
+
|
|
|
+ shellmatta_instance_t inst;
|
|
|
+ shellmatta_handle_t handle;
|
|
|
+ shellmatta_retCode_t ret;
|
|
|
+ char buffer[1024];
|
|
|
+ char historyBuffer[1024];
|
|
|
+ char *dummyData = (char*)"help this is some dummy Text\r\n"
|
|
|
+ "doSomething do Function does something use me, please\r\n"
|
|
|
+ "help ? Print this help text help\r\n"
|
|
|
+ "\r\nshellmatta->";
|
|
|
+
|
|
|
+ char *dummyData2 = (char*)"doSomething do Function does something use me, please\r\n"
|
|
|
+ "help ? 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;
|
|
|
+
|
|
|
+ /* check with echo enabled */
|
|
|
+ shellmatta_processData(handle, (char*)"help this is some dummy Text\r\n", 30u);
|
|
|
+
|
|
|
+ CHECK( write_length == strlen(dummyData));
|
|
|
+ CHECK( strcmp(dummyData, write_data) == 0);
|
|
|
+
|
|
|
+ write_callCnt = 0u;
|
|
|
+ memset(write_data, 0, sizeof(write_data));
|
|
|
+ write_length = 0u;
|
|
|
+
|
|
|
+ /* turn off echo now */
|
|
|
+ ret = shellmatta_configure(handle, SHELLMATTA_MODE_INSERT, false);
|
|
|
+ CHECK( ret == SHELLMATTA_OK );
|
|
|
+
|
|
|
+ /* check with echo disabled */
|
|
|
+ shellmatta_processData(handle, (char*)"help this is some dummy Text\r\n", 30u);
|
|
|
+
|
|
|
+ CHECK( write_length == strlen(dummyData2));
|
|
|
+ REQUIRE( strcmp(dummyData2, write_data) == 0);
|
|
|
+}
|
|
|
+
|
|
|
+TEST_CASE( "shellmatta configure mode" ) {
|
|
|
+
|
|
|
+ shellmatta_instance_t inst;
|
|
|
+ shellmatta_handle_t handle;
|
|
|
+ shellmatta_retCode_t ret;
|
|
|
+ char buffer[1024];
|
|
|
+ char historyBuffer[1024];
|
|
|
+ char *dummyData = (char*)"\r\nCommand: meow this is some dum123456my Text not found\r\nshellmatta->";
|
|
|
+
|
|
|
+ char *dummyData2 = (char*)"\r\nCommand: meow this is some dum123456t not found\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);
|
|
|
+
|
|
|
+ write_callCnt = 0u;
|
|
|
+ memset(write_data, 0, sizeof(write_data));
|
|
|
+ write_length = 0u;
|
|
|
+
|
|
|
+ /* check with insert mode */
|
|
|
+ shellmatta_processData(handle, (char*)"meow this is some dummy Text\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D123456\r\n", 57u);
|
|
|
+
|
|
|
+ CHECK( write_length == strlen(dummyData));
|
|
|
+ CHECK( strcmp(dummyData, write_data) == 0);
|
|
|
+
|
|
|
+ write_callCnt = 0u;
|
|
|
+ memset(write_data, 0, sizeof(write_data));
|
|
|
+ write_length = 0u;
|
|
|
+
|
|
|
+ /* check with overwrite mode */
|
|
|
+ ret = shellmatta_configure(handle, SHELLMATTA_MODE_OVERWRITE, false);
|
|
|
+ CHECK( ret == SHELLMATTA_OK );
|
|
|
+
|
|
|
+ /* check with echo disabled */
|
|
|
+ shellmatta_processData(handle, (char*)"meow this is some dummy Text\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D123456\r\n", 57u);
|
|
|
+
|
|
|
+ CHECK( write_length == strlen(dummyData2));
|
|
|
+ REQUIRE( strcmp(dummyData2, write_data) == 0);
|
|
|
+}
|
|
|
+
|