]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-iovec: add unit test for IOVEC_MAKE_BYTE()
authorLennart Poettering <lennart@amutable.com>
Tue, 24 Mar 2026 07:57:26 +0000 (08:57 +0100)
committerLennart Poettering <lennart@amutable.com>
Wed, 25 Mar 2026 10:52:33 +0000 (11:52 +0100)
As requested here: https://github.com/systemd/systemd/pull/40980#discussion_r2964650885

src/test/test-iovec-util.c

index 217ee8cf5d9ec9d261223ef440b77edb5b824a3a..e091463a93423190bab560211991e8df192de231 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include "iovec-util.h"
+#include "memory-util.h"
 #include "tests.h"
 
 TEST(iovec_memcmp) {
@@ -67,4 +68,11 @@ TEST(iovec_append) {
         assert_se(iovec_memcmp(&iov, &IOVEC_MAKE_STRING("waldoquuxp")) == 0);
 }
 
+TEST(iovec_make_byte) {
+        struct iovec x = IOVEC_MAKE_BYTE('x');
+
+        ASSERT_EQ(x.iov_len, 1U);
+        ASSERT_EQ(memcmp_nn(x.iov_base, x.iov_len, "x", 1), 0);
+}
+
 DEFINE_TEST_MAIN(LOG_INFO);