diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2016-10-27 11:24:26 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2016-10-27 11:24:26 +0300 |
commit | da4203df71cf2e030afdc48f90b93a817f79a592 (patch) | |
tree | 8994c9ab641f18d6c9133abbf8660f583b43c0a9 /cord | |
parent | b97e18ce5726ceff1e0a55ebe296fe89f411b347 (diff) | |
download | bdwgc-da4203df71cf2e030afdc48f90b93a817f79a592.tar.gz |
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.
Diffstat (limited to 'cord')
-rw-r--r-- | cord/tests/cordtest.c | 31 |
1 files changed, 30 insertions, 1 deletions
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 <stdarg.h> # include <string.h> # include <stdio.h> # include <stdlib.h> + /* 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) |