From: Ivan Maidanski Date: Thu, 27 Oct 2016 08:24:26 +0000 (+0300) Subject: Eliminate 'CORD_*printf is never used' cppcheck style warnings (cordtest) X-Git-Tag: v8.0.0~1066 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=da4203df71cf2e030afdc48f90b93a817f79a592;p=gc Eliminate 'CORD_*printf is never used' cppcheck style warnings (cordtest) Minimal testing of CORD_[v][f]printf is added to cordtest. * cord/tests/cordtest.c: Include stdarg.h. * cord/tests/cordtest.c: Reformat the comment describing cordtest. * cord/tests/cordtest.c (wrap_vprintf, wrap_vfprintf): New function (calling CORD_v[f]printf). * cord/tests/cordtest.c (test_printf): Call CORD_printf, wrap_vfprintf, wrap_vprintf for CORD_EMPTY (with the output to stdout); add TODO item. --- diff --git a/cord/tests/cordtest.c b/cord/tests/cordtest.c index 3e2092a6..35ea9aed 100644 --- a/cord/tests/cordtest.c +++ b/cord/tests/cordtest.c @@ -13,12 +13,15 @@ # include "gc.h" /* For GC_INIT() only */ # include "cord.h" + +# include # include # include # include + /* This is a very incomplete test of the cord package. It knows about */ /* a few internals of the package (e.g. when C strings are returned) */ -/* that real clients shouldn't rely on. */ +/* that real clients shouldn't rely on. */ # define ABORT(string) \ { fprintf(stderr, "FAILED: %s\n", string); abort(); } @@ -207,6 +210,28 @@ void test_extras(void) } } +int wrap_vprintf(CORD format, ...) +{ + va_list args; + int result; + + va_start(args, format); + result = CORD_vprintf(format, args); + va_end(args); + return result; +} + +int wrap_vfprintf(FILE * f, CORD format, ...) +{ + va_list args; + int result; + + va_start(args, format); + result = CORD_vfprintf(f, format, args); + va_end(args); + return result; +} + #if defined(__DJGPP__) || defined(__STRICT_ANSI__) /* snprintf is missing in DJGPP (v2.0.3) */ #else @@ -252,6 +277,10 @@ void test_printf(void) # endif result2[sizeof(result2) - 1] = '\0'; if (CORD_cmp(result, result2) != 0)ABORT("CORD_sprintf goofed 5"); + /* TODO: Better test CORD_[v][f]printf. */ + (void)CORD_printf(CORD_EMPTY); + (void)wrap_vfprintf(stdout, CORD_EMPTY); + (void)wrap_vprintf(CORD_EMPTY); } int main(void)