diff mbox series

[v3,3/3] unit: Add l_memcpy test

Message ID 20241031202627.1548592-3-denkenz@gmail.com (mailing list archive)
State New
Headers show
Series [v3,1/3] timeout: add l_timeout_remaining | expand

Commit Message

Denis Kenzior Oct. 31, 2024, 8:26 p.m. UTC
---
 unit/test-util.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/unit/test-util.c b/unit/test-util.c
index 341c790c3731..27b0422200d0 100644
--- a/unit/test-util.c
+++ b/unit/test-util.c
@@ -288,6 +288,16 @@  static void test_roundup_pow_of_two(const void *test_data)
 	}
 }
 
+static void test_l_memcpy(const void *test_data)
+{
+	static const uint8_t src[] = { 0x00, 0xff, 0xff, 0xff };
+	uint8_t dst[10];
+
+	assert(l_memcpy(dst, src, sizeof(src)) == dst);
+	assert(l_memcpy(dst, src, 0) == dst);
+	assert(l_memcpy(dst, NULL, 0) == dst);
+}
+
 int main(int argc, char *argv[])
 {
 	l_test_init(&argc, &argv);
@@ -313,5 +323,7 @@  int main(int argc, char *argv[])
 
 	l_test_add("roundup_pow_of_two", test_roundup_pow_of_two, NULL);
 
+	l_test_add("l_memcpy", test_l_memcpy, NULL);
+
 	return l_test_run();
 }