From 3be93daff3d8ed103d22829249ece9ae0df441e7 Mon Sep 17 00:00:00 2001 From: Vitalii Koshura Date: Tue, 10 Sep 2024 04:11:47 +0200 Subject: [PATCH] unittests: revert some changes to fix unit tests Signed-off-by: Vitalii Koshura --- tests/unit-tests/lib/test_str_util.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/unit-tests/lib/test_str_util.cpp b/tests/unit-tests/lib/test_str_util.cpp index 34882c1e03..67c288944d 100644 --- a/tests/unit-tests/lib/test_str_util.cpp +++ b/tests/unit-tests/lib/test_str_util.cpp @@ -297,12 +297,11 @@ namespace test_str_util { TEST_F(test_str_util, lf_terminate) { char *buf; - const size_t buf_size = 256; - buf = (char*)malloc(buf_size); - strncpy(buf, "no\nlf ending", buf_size); + buf = (char*)malloc(256); + strcpy(buf, "no\nlf ending"); buf = lf_terminate(buf); 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); EXPECT_STREQ(buf, "lf\n ending\n"); } @@ -391,7 +390,7 @@ namespace test_str_util { EXPECT_STREQ(buf, "blah"); EXPECT_EQ(path_to_filename("hellokeith", buf), 0); EXPECT_STREQ(buf, "hellokeith"); - strncpy(buf, "", 2); + strcpy(buf, ""); EXPECT_EQ(path_to_filename("/home/blah/", buf), -2); EXPECT_STREQ(buf, ""); EXPECT_EQ(path_to_filename("", buf), -1);