aboutsummaryrefslogtreecommitdiffstats
path: root/asprintf.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-08-12 21:35:12 +0200
committerMattias Andrée <maandree@kth.se>2018-08-12 21:35:12 +0200
commit93b8428b5812191177c790ea9ffb9158d5a296b4 (patch)
tree8e43220208a7e3b4780a49b8278e731f3b5fcbbf /asprintf.c
parentAdd DONT_DEFINE_CLOCK_MONOTONIC_RAW (diff)
downloadlibsimple-93b8428b5812191177c790ea9ffb9158d5a296b4.tar.gz
libsimple-93b8428b5812191177c790ea9ffb9158d5a296b4.tar.bz2
libsimple-93b8428b5812191177c790ea9ffb9158d5a296b4.tar.xz
Add tests
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'asprintf.c')
-rw-r--r--asprintf.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/asprintf.c b/asprintf.c
index 7f565a3..e57c320 100644
--- a/asprintf.c
+++ b/asprintf.c
@@ -12,3 +12,23 @@ libsimple_asprintf(char **strp, const char *fmt, ...)
va_end(ap);
return r;
}
+
+
+#ifdef TEST
+#include <assert.h>
+
+int
+main(void)
+{
+ char *s = "";
+ char *old = s;
+
+ assert(libsimple_asprintf(&s, "%i %X", 99999, 255) == sizeof("99999 FF") - 1);
+ assert(s && s != old);
+ assert(!strcmp(s, "99999 FF"));
+ free(s);
+
+ return 0;
+}
+
+#endif