aboutsummaryrefslogtreecommitdiffstats
path: root/memdup.c
diff options
context:
space:
mode:
Diffstat (limited to 'memdup.c')
-rw-r--r--memdup.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/memdup.c b/memdup.c
index f3997a6..882442b 100644
--- a/memdup.c
+++ b/memdup.c
@@ -10,3 +10,23 @@ libsimple_memdup(const void *s, size_t n)
return NULL;
return memcpy(ret, s, n);
}
+
+
+#ifdef TEST
+#include <assert.h>
+
+int
+main(void)
+{
+ const char *s = "test";
+ void *p = libsimple_memdup(s, 5);
+ assert(p);
+ assert(p != s);
+ assert(!strcmp(p, s));
+ memset(p, 0, 5);
+ assert(!strcmp(s, "test"));
+ free(p);
+ return 0;
+}
+
+#endif