|
@@ -11,12 +11,12 @@
|
|
* @brief integration test implementation for some general functions
|
|
* @brief integration test implementation for some general functions
|
|
* @author Stefan Strobel <stefan.strobel@shimatta.net>
|
|
* @author Stefan Strobel <stefan.strobel@shimatta.net>
|
|
*/
|
|
*/
|
|
-
|
|
|
|
#include "test/framework/catch.hpp"
|
|
#include "test/framework/catch.hpp"
|
|
extern "C" {
|
|
extern "C" {
|
|
#include "shellmatta.h"
|
|
#include "shellmatta.h"
|
|
}
|
|
}
|
|
#include <string.h>
|
|
#include <string.h>
|
|
|
|
+using Catch::Matchers::Equals;
|
|
|
|
|
|
static uint32_t write_callCnt = 0u;
|
|
static uint32_t write_callCnt = 0u;
|
|
static char write_data[1024];
|
|
static char write_data[1024];
|
|
@@ -65,7 +65,6 @@ TEST_CASE( "shellmatta empty function" ) {
|
|
shellmatta_handle_t handle;
|
|
shellmatta_handle_t handle;
|
|
char buffer[1024];
|
|
char buffer[1024];
|
|
char historyBuffer[1024];
|
|
char historyBuffer[1024];
|
|
- char *dummyData = (char*)"\r\nshellmatta->";
|
|
|
|
|
|
|
|
shellmatta_doInit( &inst,
|
|
shellmatta_doInit( &inst,
|
|
&handle,
|
|
&handle,
|
|
@@ -84,8 +83,7 @@ TEST_CASE( "shellmatta empty function" ) {
|
|
shellmatta_processData(handle, (char*)"\r", 1);
|
|
shellmatta_processData(handle, (char*)"\r", 1);
|
|
|
|
|
|
CHECK( write_length == 14u);
|
|
CHECK( write_length == 14u);
|
|
- REQUIRE( strcmp(dummyData, write_data) == 0);
|
|
|
|
-
|
|
|
|
|
|
+ REQUIRE_THAT( write_data, Equals("\r\nshellmatta->") );
|
|
}
|
|
}
|
|
|
|
|
|
TEST_CASE( "shellmatta heredoc test" ) {
|
|
TEST_CASE( "shellmatta heredoc test" ) {
|
|
@@ -94,9 +92,6 @@ TEST_CASE( "shellmatta heredoc test" ) {
|
|
shellmatta_handle_t handle;
|
|
shellmatta_handle_t handle;
|
|
char buffer[1024];
|
|
char buffer[1024];
|
|
char historyBuffer[1024];
|
|
char historyBuffer[1024];
|
|
- char *dummyData = (char*)"do this ";
|
|
|
|
- char *dummyStdin = (char*)"asdf\r\n"
|
|
|
|
- "1234";
|
|
|
|
|
|
|
|
shellmatta_doInit( &inst,
|
|
shellmatta_doInit( &inst,
|
|
&handle,
|
|
&handle,
|
|
@@ -119,9 +114,9 @@ TEST_CASE( "shellmatta heredoc test" ) {
|
|
, 33);
|
|
, 33);
|
|
|
|
|
|
CHECK( doSomethingStdinLength == 10u);
|
|
CHECK( doSomethingStdinLength == 10u);
|
|
- CHECK( strcmp(dummyStdin, doSomethingStdin) == 0);
|
|
|
|
|
|
+ CHECK_THAT( doSomethingStdin, Equals("asdf\r\n1234") );
|
|
CHECK( doSomethingLength == 8u);
|
|
CHECK( doSomethingLength == 8u);
|
|
- REQUIRE( strcmp(dummyData, doSomethingArguments) == 0);
|
|
|
|
|
|
+ REQUIRE_THAT( doSomethingArguments, Equals("do this ") );
|
|
}
|
|
}
|
|
|
|
|
|
TEST_CASE( "shellmatta heredoc test empty" ) {
|
|
TEST_CASE( "shellmatta heredoc test empty" ) {
|
|
@@ -130,7 +125,6 @@ TEST_CASE( "shellmatta heredoc test empty" ) {
|
|
shellmatta_handle_t handle;
|
|
shellmatta_handle_t handle;
|
|
char buffer[1024];
|
|
char buffer[1024];
|
|
char historyBuffer[1024];
|
|
char historyBuffer[1024];
|
|
- char *dummyData = (char*)"do this ";
|
|
|
|
|
|
|
|
shellmatta_doInit( &inst,
|
|
shellmatta_doInit( &inst,
|
|
&handle,
|
|
&handle,
|
|
@@ -153,7 +147,7 @@ TEST_CASE( "shellmatta heredoc test empty" ) {
|
|
CHECK( doSomethingStdinLength == 0u);
|
|
CHECK( doSomethingStdinLength == 0u);
|
|
CHECK( NULL == doSomethingStdin );
|
|
CHECK( NULL == doSomethingStdin );
|
|
CHECK( doSomethingLength == 8u);
|
|
CHECK( doSomethingLength == 8u);
|
|
- REQUIRE( strcmp(dummyData, doSomethingArguments) == 0);
|
|
|
|
|
|
+ REQUIRE_THAT( doSomethingArguments, Equals("do this ") );
|
|
}
|
|
}
|
|
|
|
|
|
TEST_CASE( "shellmatta remove function" ) {
|
|
TEST_CASE( "shellmatta remove function" ) {
|
|
@@ -185,8 +179,7 @@ TEST_CASE( "shellmatta remove function" ) {
|
|
shellmatta_processData(handle, (char*)"?\r", 2);
|
|
shellmatta_processData(handle, (char*)"?\r", 2);
|
|
|
|
|
|
CHECK( write_length == strlen(dummyData));
|
|
CHECK( write_length == strlen(dummyData));
|
|
- CHECK( strcmp(dummyData, write_data) == 0);
|
|
|
|
-
|
|
|
|
|
|
+ CHECK_THAT( write_data, Equals(dummyData) );
|
|
|
|
|
|
write_callCnt = 0u;
|
|
write_callCnt = 0u;
|
|
memset(write_data, 0, sizeof(write_data));
|
|
memset(write_data, 0, sizeof(write_data));
|