X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=tests%2Ftest-vsnprintf.c;h=08aca8868be3f169a647c75a2728a07101ff47a8;hb=fb7fde6f658ac18b7ab7ca61dca9a290cc8c3348;hp=ccc9e5a70364250fcbd92fa8830d00b2490cef82;hpb=2ebbda00230a4447662e3c8e45cf0fb99c6fac6a;p=gnulib.git diff --git a/tests/test-vsnprintf.c b/tests/test-vsnprintf.c index ccc9e5a70..08aca8868 100644 --- a/tests/test-vsnprintf.c +++ b/tests/test-vsnprintf.c @@ -17,9 +17,7 @@ /* Written by Bruno Haible , 2007. */ -#ifdef HAVE_CONFIG_H -# include -#endif +#include #include @@ -27,7 +25,16 @@ #include #include -#define ASSERT(expr) if (!(expr)) abort (); +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) static int my_snprintf (char *buf, int size, const char *format, ...) @@ -54,13 +61,18 @@ main (int argc, char *argv[]) retval = my_snprintf (buf, size, "%d", 12345); if (size < 6) { +#if CHECK_VSNPRINTF_POSIX ASSERT (retval < 0 || retval >= size); +#endif if (size > 0) { ASSERT (memcmp (buf, "12345", size - 1) == 0); ASSERT (buf[size - 1] == '\0' || buf[size - 1] == '0' + size); } - ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0); +#if !CHECK_VSNPRINTF_POSIX + if (size > 0) +#endif + ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0); } else {