From d1122de6bb461e0448897869b4406300c12f259f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 15 Dec 2018 14:56:23 +0100 Subject: More tests and fix attributes on wcsndup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- enaligned_strdup.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'enaligned_strdup.c') diff --git a/enaligned_strdup.c b/enaligned_strdup.c index 6390ab0..533ff56 100644 --- a/enaligned_strdup.c +++ b/enaligned_strdup.c @@ -42,6 +42,16 @@ main(void) assert(!memcmp(s, "test", 5)); free(s); + assert((s = libsimple_aligned_strdup("test", 4))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 8); + assert(info->alignment == 4); + assert(!info->zeroed); + } + assert(!memcmp(s, "test", 5)); + free(s); + if (have_custom_malloc()) { alloc_fail_in = 1; assert_exit_ptr(libsimple_enaligned_strdup(44, "hello", 2)); @@ -56,6 +66,10 @@ main(void) assert_stderr("%s: aligned_strdup: %s\n", argv0, strerror(ENOMEM)); assert(!alloc_fail_in); libsimple_default_failure_exit = 1; + + alloc_fail_in = 1; + assert(!libsimple_aligned_strdup("test", 16) && errno == ENOMEM); + assert(!alloc_fail_in); } return 0; -- cgit v1.2.3-70-g09d2