Add tcp_cmd_remove_leading_space + tests
This commit is contained in:
2023-12-02 21:01:09 +01:00
committed by Sander Speetjens
parent 35656af040
commit 414e53e6e9
3 changed files with 28 additions and 0 deletions

View File

@@ -54,6 +54,22 @@ TEST(TCP_CMD, tcp_cmd_remove_newline) {
free(cmd);
}
TEST(TCP_CMD, tcp_cmd_remove_leading_space) {
char* cmd = (char*)calloc(50, 1);
strcpy(cmd, "help");
EXPECT_STREQ(tcp_cmd_remove_leading_space(cmd, strlen(cmd)), "help");
strcpy(cmd, " help");
EXPECT_STREQ(tcp_cmd_remove_leading_space(cmd, strlen(cmd)), "help");
strcpy(cmd, " help");
EXPECT_STREQ(tcp_cmd_remove_leading_space(cmd, strlen(cmd)), "help");
strcpy(cmd, " help");
EXPECT_STREQ(tcp_cmd_remove_leading_space(cmd, strlen(cmd)), "help");
strcpy(cmd, " help");
EXPECT_STREQ(tcp_cmd_remove_leading_space(cmd, strlen(cmd)), "help");
strcpy(cmd, "\n\t\r\n help");
EXPECT_STREQ(tcp_cmd_remove_leading_space(cmd, strlen(cmd)), "help");
}
TEST(TCP_CMD, tcp_data_cb) {
char* cmd = (char*)calloc(50, 1);
std::string output;