2 * asprintf and vasprintf test suite.
4 * Written by Russ Allbery <rra@stanford.edu>
5 * Copyright 2006, 2008, 2009
6 * Board of Trustees, Leland Stanford Jr. University
8 * See LICENSE for licensing terms.
12 #include <portable/system.h>
14 #include <tests/tap/basic.h>
16 int test_asprintf(char **, const char *, ...)
17 __attribute__((__format__(printf, 2, 3)));
18 int test_vasprintf(char **, const char *, va_list);
21 vatest(char **result, const char *format, ...)
26 va_start(args, format);
27 status = test_vasprintf(result, format, args);
39 is_int(7, test_asprintf(&result, "%s", "testing"), "asprintf length");
40 is_string("testing", result, "asprintf result");
42 ok(3, "free asprintf");
43 is_int(0, test_asprintf(&result, "%s", ""), "asprintf empty length");
44 is_string("", result, "asprintf empty string");
46 ok(6, "free asprintf of empty string");
48 is_int(6, vatest(&result, "%d %s", 2, "test"), "vasprintf length");
49 is_string("2 test", result, "vasprintf result");
51 ok(9, "free vasprintf");
52 is_int(0, vatest(&result, "%s", ""), "vasprintf empty length");
53 is_string("", result, "vasprintf empty string");
55 ok(12, "free vasprintf of empty string");