aboutsummaryrefslogtreecommitdiffstats
path: root/enaligned_strdup.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-12-15 14:56:23 +0100
committerMattias Andrée <maandree@kth.se>2018-12-15 14:56:23 +0100
commitd1122de6bb461e0448897869b4406300c12f259f (patch)
tree031bf1bdb887be786e5bb370c83eb52eef649ddc /enaligned_strdup.c
parentA bunch of stuff (diff)
downloadlibsimple-d1122de6bb461e0448897869b4406300c12f259f.tar.gz
libsimple-d1122de6bb461e0448897869b4406300c12f259f.tar.bz2
libsimple-d1122de6bb461e0448897869b4406300c12f259f.tar.xz
More tests and fix attributes on wcsndup
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--enaligned_strdup.c14
1 files changed, 14 insertions, 0 deletions
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;