add functions that need to be tested to header file
This commit is contained in:
2023-12-02 10:40:56 +01:00
parent 6a0be6e469
commit 55ea5b31e1
3 changed files with 52 additions and 4 deletions

View File

@@ -9,6 +9,51 @@ extern "C" {
#include "tcp_cmd.h"
}
TEST(TCP_CMD, tcp_cmd_remove_newline) {
char* cmd = (char*)calloc(50, 1);
strcpy(cmd, "help\n");
tcp_cmd_remove_newline(cmd, strlen(cmd));
EXPECT_STREQ(cmd, "help");
strcpy(cmd, "help");
tcp_cmd_remove_newline(cmd, strlen(cmd));
EXPECT_STREQ(cmd, "help");
strcpy(cmd, "help\n\n");
tcp_cmd_remove_newline(cmd, strlen(cmd));
EXPECT_STREQ(cmd, "help");
strcpy(cmd, "\nhelp\n\n");
tcp_cmd_remove_newline(cmd, strlen(cmd));
EXPECT_STREQ(cmd, "help");
strcpy(cmd, "\n\nhelp\n\n");
tcp_cmd_remove_newline(cmd, strlen(cmd));
EXPECT_STREQ(cmd, "help");
strcpy(cmd, "\n\nhelp\n\n\n");
tcp_cmd_remove_newline(cmd, strlen(cmd));
EXPECT_STREQ(cmd, "help");
strcpy(cmd, "\n\nhelp\n\n\n\n");
tcp_cmd_remove_newline(cmd, strlen(cmd));
EXPECT_STREQ(cmd, "help");
strcpy(cmd, "\n\nhelp\n\n\n\n\n");
tcp_cmd_remove_newline(cmd, strlen(cmd));
EXPECT_STREQ(cmd, "help");
strcpy(cmd, "\n\nhelp\n\n\n\n\n\n");
tcp_cmd_remove_newline(cmd, strlen(cmd));
EXPECT_STREQ(cmd, "help");
strcpy(cmd, "\n\nhelp\n\n\n\n\n\n\n");
tcp_cmd_remove_newline(cmd, strlen(cmd));
EXPECT_STREQ(cmd, "help");
strcpy(cmd, "\n\nhelp\n\n\n\n\n\n\n\n");
tcp_cmd_remove_newline(cmd, strlen(cmd));
EXPECT_STREQ(cmd, "help");
strcpy(cmd, "\n\nhelp\n\n\n\n\n\n\n\n\n");
tcp_cmd_remove_newline(cmd, strlen(cmd));
EXPECT_STREQ(cmd, "help");
strcpy(cmd, "\n\nhel\np\n");
tcp_cmd_remove_newline(cmd, strlen(cmd));
EXPECT_STREQ(cmd, "help");
free(cmd);
}
TEST(TCP_CMD, tcp_data_cb) {
char* cmd = (char*)calloc(50, 1);
std::string output;