changed heredoc to exchange data via a stdin like interface with a read function fix #39
This commit is contained in:
@@ -9,6 +9,8 @@ static char write_data[1024];
|
||||
static uint32_t write_length;
|
||||
static const char *doSomethingArguments;
|
||||
static uint32_t doSomethingLength;
|
||||
static char *doSomethingStdin;
|
||||
static uint32_t doSomethingStdinLength;
|
||||
|
||||
static shellmatta_retCode_t writeFct(const char* data, uint32_t length)
|
||||
{
|
||||
@@ -28,6 +30,9 @@ static shellmatta_retCode_t doSomething(shellmatta_handle_t handle, const char *
|
||||
{
|
||||
doSomethingArguments = arguments;
|
||||
doSomethingLength = length;
|
||||
|
||||
shellmatta_read(handle, &doSomethingStdin, &doSomethingStdinLength);
|
||||
|
||||
shellmatta_printf(handle, "%s - length: %u", arguments, length);
|
||||
return SHELLMATTA_OK;
|
||||
}
|
||||
@@ -140,8 +145,8 @@ TEST_CASE( "shellmatta heredoc test" ) {
|
||||
shellmatta_handle_t handle;
|
||||
char buffer[1024];
|
||||
char historyBuffer[1024];
|
||||
char *dummyData = (char*)"do this \r\n"
|
||||
"asdf\r\n"
|
||||
char *dummyData = (char*)"do this ";
|
||||
char *dummyStdin = (char*)"asdf\r\n"
|
||||
"1234";
|
||||
|
||||
shellmatta_doInit( &inst,
|
||||
@@ -162,15 +167,14 @@ TEST_CASE( "shellmatta heredoc test" ) {
|
||||
"asdf\r\n"
|
||||
"1234\r\n"
|
||||
"EOF\r\n"
|
||||
, 34);
|
||||
, 33);
|
||||
|
||||
|
||||
|
||||
CHECK( doSomethingLength == 20u);
|
||||
CHECK( doSomethingStdinLength == 10u);
|
||||
CHECK( strcmp(dummyStdin, doSomethingStdin) == 0);
|
||||
CHECK( doSomethingLength == 8u);
|
||||
REQUIRE( strcmp(dummyData, doSomethingArguments) == 0);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE( "shellmatta remove function" ) {
|
||||
|
||||
shellmatta_instance_t inst;
|
||||
|
Reference in New Issue
Block a user