diff options
Diffstat (limited to 'tests/test_asprintf.c')
| -rw-r--r-- | tests/test_asprintf.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_asprintf.c b/tests/test_asprintf.c new file mode 100644 index 0000000..a02d110 --- /dev/null +++ b/tests/test_asprintf.c | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | #define _GNU_SOURCE | ||
| 2 | #include "common.h" | ||
| 3 | |||
| 4 | #include <assert.h> | ||
| 5 | #include <stdio.h> | ||
| 6 | #include <stdlib.h> | ||
| 7 | |||
| 8 | int main(int argc, char** argv) { | ||
| 9 | char* buf; | ||
| 10 | asprintf(&buf, "total: %d+%d=%d", 1, 2, 3); | ||
| 11 | puts(buf); | ||
| 12 | free(buf); | ||
| 13 | |||
| 14 | #ifndef __clang__ | ||
| 15 | asprintf(&buf, "total: %", 1); | ||
| 16 | assert(buf == NULL); | ||
| 17 | #endif | ||
| 18 | |||
| 19 | return 0; | ||
| 20 | } | ||
