Skip to content

Commit

Permalink
fix unittests
Browse files Browse the repository at this point in the history
Signed-off-by: Vitalii Koshura <lestat.de.lionkur@gmail.com>
  • Loading branch information
AenBleidd committed Sep 10, 2024
1 parent bd3b2a9 commit 1ad881d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/unit-tests/lib/test_str_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,12 @@ namespace test_str_util {

TEST_F(test_str_util, lf_terminate) {
char *buf;
buf = (char*)malloc(256);
strncpy(buf, "no\nlf ending", sizeof(buf));
const size_t buf_size = 256;
buf = (char*)malloc(buf_size);
strncpy(buf, "no\nlf ending", buf_size);
buf = lf_terminate(buf);
EXPECT_STREQ(buf, "no\nlf ending\n");
strncpy(buf, "lf\n ending\n", sizeof(buf));
strncpy(buf, "lf\n ending\n", buf_size);
buf = lf_terminate(buf);
EXPECT_STREQ(buf, "lf\n ending\n");
}
Expand Down Expand Up @@ -390,7 +391,7 @@ namespace test_str_util {
EXPECT_STREQ(buf, "blah");
EXPECT_EQ(path_to_filename("hellokeith", buf), 0);
EXPECT_STREQ(buf, "hellokeith");
strncpy(buf, "", sizeof(buf));
strncpy(buf, "", 2);
EXPECT_EQ(path_to_filename("/home/blah/", buf), -2);
EXPECT_STREQ(buf, "");
EXPECT_EQ(path_to_filename("", buf), -1);
Expand Down

0 comments on commit 1ad881d

Please sign in to comment.