unittests: revert some changes to fix unit tests

Signed-off-by: Vitalii Koshura <lestat.de.lionkur@gmail.com>
This commit is contained in:
Vitalii Koshura 2024-09-10 04:11:47 +02:00
parent 1ad881d97d
commit 3be93daff3
No known key found for this signature in database
GPG Key ID: CE0DB1726070A5A3
1 changed files with 4 additions and 5 deletions

View File

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