@@ -288,6 +288,16 @@ static void test_roundup_pow_of_two(const void *test_data)
}
}
+static void test_safe_memcpy(const void *test_data)
+{
+ static const uint8_t src[] = { 0x00, 0xff, 0xff, 0xff };
+ uint8_t dst[10];
+
+ assert(l_safe_memcpy(dst, src, sizeof(src)) == dst);
+ assert(l_safe_memcpy(dst, src, 0) == dst);
+ assert(l_safe_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_safememcpy", test_safe_memcpy, NULL);
+
return l_test_run();
}