1 #include "../unittest.h"
3 #ifndef CONFIG_HAVE_STRNDUP
4 #include "../../oslib/strndup.h"
9 static void test_strndup_1(void)
12 char *p = strndup(s, 3);
15 CU_ASSERT_EQUAL(strcmp(p, "tes"), 0);
16 CU_ASSERT_EQUAL(strlen(p), 3);
20 static void test_strndup_2(void)
23 char *p = strndup(s, 4);
26 CU_ASSERT_EQUAL(strcmp(p, s), 0);
27 CU_ASSERT_EQUAL(strlen(p), 4);
31 static void test_strndup_3(void)
34 char *p = strndup(s, 5);
37 CU_ASSERT_EQUAL(strcmp(p, s), 0);
38 CU_ASSERT_EQUAL(strlen(p), 4);
42 static struct fio_unittest_entry tests[] = {
60 CU_ErrorCode fio_unittest_oslib_strndup(void)
62 return fio_unittest_add_suite("oslib/strndup.c", NULL, NULL, tests);