X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/blobdiff_plain/ce896b0b69481d8ec941e1601fddd2df5143b259..912f6431247d27e2144c5c078bd47396d95f5175:/struct/t/dstr-putf-test.c diff --git a/struct/t/dstr-putf-test.c b/struct/t/dstr-putf-test.c index 416b164..044da71 100644 --- a/struct/t/dstr-putf-test.c +++ b/struct/t/dstr-putf-test.c @@ -18,13 +18,16 @@ static char strbuf[1024]; #define TESTGROUP(name) TVEC_TESTGROUP_TAG(grp, &tvstate, name) -static void PRINTF_LIKE(1, 2) format(const char *fmt, ...) +static int PRINTF_LIKE(1, 2) format(const char *fmt, ...) { va_list ap; + int n; + va_start(ap, fmt); dstr_reset(&d); - dstr_vputf(&d, fmt, &ap); + n = dstr_vputf(&d, fmt, &ap); va_end(ap); + return (n); } static void PRINTF_LIKE(1, 2) prepare(const char *fmt, ...) @@ -42,14 +45,18 @@ static void PRINTF_LIKE(1, 2) prepare(const char *fmt, ...) } #define TEST_KNOWN(fmtargs, want) do { \ - format fmtargs; \ + int n; n = format fmtargs; \ + tvec_claimeq_int(&tvstate, n, strlen(want), \ + __FILE__, __LINE__, "format " #fmtargs); \ tvec_claimeq_string(&tvstate, d.buf, d.len, want, strlen(want), \ __FILE__, __LINE__, "format " #fmtargs); \ } while (0) #define TEST_REF(fmtargs) do { \ - format fmtargs; \ + int n = format fmtargs; \ prepare fmtargs; \ + tvec_claimeq_int(&tvstate, n, strlen(strbuf), \ + __FILE__, __LINE__, "format " #fmtargs); \ tvec_claimeq_string(&tvstate, d.buf, d.len, strbuf, strlen(strbuf), \ __FILE__, __LINE__, "format " #fmtargs); \ } while (0)