From 75d146361fe980e1e1bbb9639edc6fbed5345e82 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 29 Apr 2007 09:15:13 +0000 Subject: [PATCH] Better ASSERT macro. --- ChangeLog | 5 +++++ tests/test-argmatch.c | 12 +++++++++++- tests/test-array_list.c | 12 +++++++++++- tests/test-array_oset.c | 12 +++++++++++- tests/test-avltree_list.c | 12 +++++++++++- tests/test-avltree_oset.c | 12 +++++++++++- tests/test-avltreehash_list.c | 12 +++++++++++- tests/test-binary-io.c | 11 ++++++++++- tests/test-byteswap.c | 12 +++++++++++- tests/test-c-ctype.c | 14 ++++++++++++-- tests/test-c-strcasecmp.c | 12 +++++++++++- tests/test-c-strcasestr.c | 12 +++++++++++- tests/test-c-strncasecmp.c | 12 +++++++++++- tests/test-c-strstr.c | 12 +++++++++++- tests/test-canonicalize-lgpl.c | 12 +++++++++++- tests/test-carray_list.c | 12 +++++++++++- tests/test-fbufmode.c | 12 +++++++++++- tests/test-fprintf-posix.c | 12 +++++++++++- tests/test-fpurge.c | 12 +++++++++++- tests/test-freadable.c | 12 +++++++++++- tests/test-freading.c | 12 +++++++++++- tests/test-frexp.c | 12 +++++++++++- tests/test-frexpl.c | 12 +++++++++++- tests/test-fwritable.c | 12 +++++++++++- tests/test-fwriting.c | 12 +++++++++++- tests/test-iconv.c | 12 +++++++++++- tests/test-isnan.c | 12 +++++++++++- tests/test-isnanf.c | 12 +++++++++++- tests/test-isnanl.h | 12 +++++++++++- tests/test-ldexpl.c | 12 +++++++++++- tests/test-linked_list.c | 12 +++++++++++- tests/test-linkedhash_list.c | 12 +++++++++++- tests/test-mbscasecmp.c | 12 +++++++++++- tests/test-mbscasestr1.c | 12 +++++++++++- tests/test-mbscasestr2.c | 12 +++++++++++- tests/test-mbscasestr3.c | 12 +++++++++++- tests/test-mbscasestr4.c | 12 +++++++++++- tests/test-mbschr.c | 12 +++++++++++- tests/test-mbscspn.c | 12 +++++++++++- tests/test-mbsncasecmp.c | 12 +++++++++++- tests/test-mbspbrk.c | 12 +++++++++++- tests/test-mbspcasecmp.c | 12 +++++++++++- tests/test-mbsrchr.c | 12 +++++++++++- tests/test-mbsspn.c | 12 +++++++++++- tests/test-mbsstr1.c | 12 +++++++++++- tests/test-mbsstr2.c | 12 +++++++++++- tests/test-mbsstr3.c | 12 +++++++++++- tests/test-printf-frexp.c | 12 +++++++++++- tests/test-printf-frexpl.c | 12 +++++++++++- tests/test-printf-posix.c | 12 +++++++++++- tests/test-rbtree_list.c | 12 +++++++++++- tests/test-rbtree_oset.c | 12 +++++++++++- tests/test-rbtreehash_list.c | 12 +++++++++++- tests/test-signbit.c | 12 +++++++++++- tests/test-snprintf-posix.c | 12 +++++++++++- tests/test-snprintf.c | 11 ++++++++++- tests/test-sprintf-posix.c | 12 +++++++++++- tests/test-stat-time.c | 11 ++++++++++- tests/test-strcasestr.c | 12 +++++++++++- tests/test-striconv.c | 12 +++++++++++- tests/test-striconveh.c | 12 +++++++++++- tests/test-striconveha.c | 12 +++++++++++- tests/test-vasnprintf-posix.c | 12 +++++++++++- tests/test-vasnprintf-posix2.c | 12 +++++++++++- tests/test-vasnprintf.c | 12 +++++++++++- tests/test-vasprintf-posix.c | 12 +++++++++++- tests/test-vasprintf.c | 11 ++++++++++- tests/test-vfprintf-posix.c | 12 +++++++++++- tests/test-vprintf-posix.c | 12 +++++++++++- tests/test-vsnprintf-posix.c | 12 +++++++++++- tests/test-vsnprintf.c | 11 ++++++++++- tests/test-vsprintf-posix.c | 12 +++++++++++- tests/test-xvasprintf.c | 12 +++++++++++- tests/uniconv/test-u16-conv-from-enc.c | 12 +++++++++++- tests/uniconv/test-u16-strconv-from-enc.c | 12 +++++++++++- tests/uniconv/test-u16-strconv-to-enc.c | 12 +++++++++++- tests/uniconv/test-u32-conv-from-enc.c | 12 +++++++++++- tests/uniconv/test-u32-strconv-from-enc.c | 12 +++++++++++- tests/uniconv/test-u32-strconv-to-enc.c | 12 +++++++++++- tests/uniconv/test-u8-conv-from-enc.c | 12 +++++++++++- tests/uniconv/test-u8-strconv-from-enc.c | 12 +++++++++++- tests/uniconv/test-u8-strconv-to-enc.c | 12 +++++++++++- 82 files changed, 892 insertions(+), 82 deletions(-) diff --git a/ChangeLog b/ChangeLog index f819138fd..1d9ef89cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2007-04-29 Bruno Haible + * tests/**/test-*.[hc] (ASSERT): Use fprintf to show the line number. + This helps debugging on systems on which no gdb is available. + +2007-04-29 Bruno Haible + * lib/freading.h: Improve comments. * lib/fwriting.h: Likewise. * tests/test-freading.c (main): Don't check freading immediately after diff --git a/tests/test-argmatch.c b/tests/test-argmatch.c index c37fc5dc6..e61b88fcc 100644 --- a/tests/test-argmatch.c +++ b/tests/test-argmatch.c @@ -24,11 +24,21 @@ #include "argmatch.h" +#include #include #include "progname.h" -#define ASSERT(expr) if (!(expr)) abort (); +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) enum backup_type { diff --git a/tests/test-array_list.c b/tests/test-array_list.c index b9de7cef0..1d831f9a3 100644 --- a/tests/test-array_list.c +++ b/tests/test-array_list.c @@ -22,6 +22,7 @@ #include "gl_array_list.h" +#include #include #include "progname.h" @@ -32,7 +33,16 @@ static const char *objects[15] = }; #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(condition) if (!(condition)) abort () +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) #define RANDOM(n) (rand () % (n)) #define RANDOM_OBJECT() objects[RANDOM (SIZEOF (objects))] diff --git a/tests/test-array_oset.c b/tests/test-array_oset.c index 646e90842..a7d1f001d 100644 --- a/tests/test-array_oset.c +++ b/tests/test-array_oset.c @@ -22,6 +22,7 @@ #include "gl_array_oset.h" +#include #include #include @@ -35,7 +36,16 @@ static const char *objects[30] = }; #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(condition) if (!(condition)) abort () +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) #define RANDOM(n) (rand () % (n)) #define RANDOM_OBJECT() objects[RANDOM (SIZEOF (objects))] diff --git a/tests/test-avltree_list.c b/tests/test-avltree_list.c index af608cef8..8105c8ee4 100644 --- a/tests/test-avltree_list.c +++ b/tests/test-avltree_list.c @@ -22,6 +22,7 @@ #include "gl_avltree_list.h" +#include #include #include "gl_array_list.h" @@ -35,7 +36,16 @@ static const char *objects[15] = }; #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(condition) if (!(condition)) abort () +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) #define RANDOM(n) (rand () % (n)) #define RANDOM_OBJECT() objects[RANDOM (SIZEOF (objects))] diff --git a/tests/test-avltree_oset.c b/tests/test-avltree_oset.c index c7991359d..e90177450 100644 --- a/tests/test-avltree_oset.c +++ b/tests/test-avltree_oset.c @@ -22,6 +22,7 @@ #include "gl_avltree_oset.h" +#include #include #include @@ -37,7 +38,16 @@ static const char *objects[30] = }; #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(condition) if (!(condition)) abort () +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) #define RANDOM(n) (rand () % (n)) #define RANDOM_OBJECT() objects[RANDOM (SIZEOF (objects))] diff --git a/tests/test-avltreehash_list.c b/tests/test-avltreehash_list.c index f5ea12990..65ab49a99 100644 --- a/tests/test-avltreehash_list.c +++ b/tests/test-avltreehash_list.c @@ -23,6 +23,7 @@ #include "gl_avltreehash_list.h" #include +#include #include #include @@ -62,7 +63,16 @@ string_hash (const void *x) } #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(condition) if (!(condition)) abort () +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) #define RANDOM(n) (rand () % (n)) #define RANDOM_OBJECT() objects[RANDOM (SIZEOF (objects))] diff --git a/tests/test-binary-io.c b/tests/test-binary-io.c index 718a66e54..677db703e 100644 --- a/tests/test-binary-io.c +++ b/tests/test-binary-io.c @@ -30,7 +30,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) int main () diff --git a/tests/test-byteswap.c b/tests/test-byteswap.c index 5f9a5a371..97c7c5ebb 100644 --- a/tests/test-byteswap.c +++ b/tests/test-byteswap.c @@ -21,9 +21,19 @@ #include +#include #include -#define ASSERT(condition) if (!(condition)) abort () +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) int main () diff --git a/tests/test-c-ctype.c b/tests/test-c-ctype.c index c8318329a..e691ba2e6 100644 --- a/tests/test-c-ctype.c +++ b/tests/test-c-ctype.c @@ -1,5 +1,5 @@ /* Test of character handling in C locale. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,9 +24,19 @@ #include "c-ctype.h" #include +#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 void test_all (void) diff --git a/tests/test-c-strcasecmp.c b/tests/test-c-strcasecmp.c index 5c153c9af..2fa0f5981 100644 --- a/tests/test-c-strcasecmp.c +++ b/tests/test-c-strcasecmp.c @@ -24,10 +24,20 @@ #include "c-strcase.h" #include +#include #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) int main (int argc, char *argv[]) diff --git a/tests/test-c-strcasestr.c b/tests/test-c-strcasestr.c index a457e5d8c..427653b54 100644 --- a/tests/test-c-strcasestr.c +++ b/tests/test-c-strcasestr.c @@ -23,10 +23,20 @@ #include "c-strcasestr.h" +#include #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) int main () diff --git a/tests/test-c-strncasecmp.c b/tests/test-c-strncasecmp.c index 24b00a86e..76a003e81 100644 --- a/tests/test-c-strncasecmp.c +++ b/tests/test-c-strncasecmp.c @@ -24,10 +24,20 @@ #include "c-strcase.h" #include +#include #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) int main (int argc, char *argv[]) diff --git a/tests/test-c-strstr.c b/tests/test-c-strstr.c index 98138bab8..204e0a5fe 100644 --- a/tests/test-c-strstr.c +++ b/tests/test-c-strstr.c @@ -23,10 +23,20 @@ #include "c-strstr.h" +#include #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) int main () diff --git a/tests/test-canonicalize-lgpl.c b/tests/test-canonicalize-lgpl.c index c5eee8db4..738482b2b 100644 --- a/tests/test-canonicalize-lgpl.c +++ b/tests/test-canonicalize-lgpl.c @@ -23,10 +23,20 @@ #include "canonicalize.h" +#include #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) int main () diff --git a/tests/test-carray_list.c b/tests/test-carray_list.c index 4aeece932..3234baf3f 100644 --- a/tests/test-carray_list.c +++ b/tests/test-carray_list.c @@ -22,6 +22,7 @@ #include "gl_carray_list.h" +#include #include #include "gl_array_list.h" @@ -33,7 +34,16 @@ static const char *objects[15] = }; #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(condition) if (!(condition)) abort () +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) #define RANDOM(n) (rand () % (n)) #define RANDOM_OBJECT() objects[RANDOM (SIZEOF (objects))] diff --git a/tests/test-fbufmode.c b/tests/test-fbufmode.c index cbdf29d7f..044d872b3 100644 --- a/tests/test-fbufmode.c +++ b/tests/test-fbufmode.c @@ -21,9 +21,19 @@ #include "fbufmode.h" +#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) #define TESTFILE "t-fbufmode.tmp" diff --git a/tests/test-fprintf-posix.c b/tests/test-fprintf-posix.c index 00402f6db..eaf093104 100644 --- a/tests/test-fprintf-posix.c +++ b/tests/test-fprintf-posix.c @@ -25,11 +25,21 @@ #include #include +#include #include #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) #include "test-fprintf-posix.h" diff --git a/tests/test-fpurge.c b/tests/test-fpurge.c index b7bac0b6a..4aadf7f4b 100644 --- a/tests/test-fpurge.c +++ b/tests/test-fpurge.c @@ -21,10 +21,20 @@ #include "fpurge.h" +#include #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) #define TESTFILE "t-fpurge.tmp" diff --git a/tests/test-freadable.c b/tests/test-freadable.c index 6d15583ca..5fb9f3ba2 100644 --- a/tests/test-freadable.c +++ b/tests/test-freadable.c @@ -21,9 +21,19 @@ #include "freadable.h" +#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) #define TESTFILE "t-freadable.tmp" diff --git a/tests/test-freading.c b/tests/test-freading.c index b2f6fc7b0..1a38b9e44 100644 --- a/tests/test-freading.c +++ b/tests/test-freading.c @@ -21,9 +21,19 @@ #include "freading.h" +#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) #define TESTFILE "t-freading.tmp" diff --git a/tests/test-frexp.c b/tests/test-frexp.c index 7d2a2758e..9ce989b06 100644 --- a/tests/test-frexp.c +++ b/tests/test-frexp.c @@ -22,11 +22,21 @@ #include #include +#include #include #include "isnan.h" -#define ASSERT(expr) if (!(expr)) abort (); +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ #ifdef __DECC diff --git a/tests/test-frexpl.c b/tests/test-frexpl.c index fd2c7e079..93cfa1443 100644 --- a/tests/test-frexpl.c +++ b/tests/test-frexpl.c @@ -22,12 +22,22 @@ #include #include +#include #include #include "fpucw.h" #include "isnanl-nolibm.h" -#define ASSERT(expr) if (!(expr)) abort (); +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) /* On MIPS IRIX machines, LDBL_MIN_EXP is -1021, but the smallest reliable exponent for 'long double' is -964. For exponents below that, the diff --git a/tests/test-fwritable.c b/tests/test-fwritable.c index c3b71ecf3..29bcee942 100644 --- a/tests/test-fwritable.c +++ b/tests/test-fwritable.c @@ -21,9 +21,19 @@ #include "fwritable.h" +#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) #define TESTFILE "t-fwritable.tmp" diff --git a/tests/test-fwriting.c b/tests/test-fwriting.c index 0f97df5cc..a16213046 100644 --- a/tests/test-fwriting.c +++ b/tests/test-fwriting.c @@ -21,9 +21,19 @@ #include "fwriting.h" +#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) #define TESTFILE "t-fwriting.tmp" diff --git a/tests/test-iconv.c b/tests/test-iconv.c index 00157dad1..520b96b5a 100644 --- a/tests/test-iconv.c +++ b/tests/test-iconv.c @@ -26,10 +26,20 @@ #endif #include +#include #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) int main () diff --git a/tests/test-isnan.c b/tests/test-isnan.c index 0897a55b3..c23b377a2 100644 --- a/tests/test-isnan.c +++ b/tests/test-isnan.c @@ -22,9 +22,19 @@ #include "isnan.h" #include +#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) /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ #ifdef __DECC diff --git a/tests/test-isnanf.c b/tests/test-isnanf.c index 0fafeade1..428c23772 100644 --- a/tests/test-isnanf.c +++ b/tests/test-isnanf.c @@ -22,9 +22,19 @@ #include "isnanf.h" #include +#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) /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ #ifdef __DECC diff --git a/tests/test-isnanl.h b/tests/test-isnanl.h index 0dab89908..0b3e2f84a 100644 --- a/tests/test-isnanl.h +++ b/tests/test-isnanl.h @@ -18,9 +18,19 @@ /* Written by Bruno Haible , 2007. */ #include +#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) int main () diff --git a/tests/test-ldexpl.c b/tests/test-ldexpl.c index c4f35811a..97bac54f5 100644 --- a/tests/test-ldexpl.c +++ b/tests/test-ldexpl.c @@ -22,12 +22,22 @@ #include #include +#include #include #include "fpucw.h" #include "isnanl-nolibm.h" -#define ASSERT(expr) if (!(expr)) abort (); +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) int main () diff --git a/tests/test-linked_list.c b/tests/test-linked_list.c index 059b2eef6..71d96c164 100644 --- a/tests/test-linked_list.c +++ b/tests/test-linked_list.c @@ -22,6 +22,7 @@ #include "gl_linked_list.h" +#include #include #include "gl_array_list.h" @@ -33,7 +34,16 @@ static const char *objects[15] = }; #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(condition) if (!(condition)) abort () +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) #define RANDOM(n) (rand () % (n)) #define RANDOM_OBJECT() objects[RANDOM (SIZEOF (objects))] diff --git a/tests/test-linkedhash_list.c b/tests/test-linkedhash_list.c index 22b67b330..765811ac7 100644 --- a/tests/test-linkedhash_list.c +++ b/tests/test-linkedhash_list.c @@ -23,6 +23,7 @@ #include "gl_linkedhash_list.h" #include +#include #include #include @@ -60,7 +61,16 @@ string_hash (const void *x) } #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(condition) if (!(condition)) abort () +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) #define RANDOM(n) (rand () % (n)) #define RANDOM_OBJECT() objects[RANDOM (SIZEOF (objects))] diff --git a/tests/test-mbscasecmp.c b/tests/test-mbscasecmp.c index 5fd112714..f4d8e859c 100644 --- a/tests/test-mbscasecmp.c +++ b/tests/test-mbscasecmp.c @@ -24,9 +24,19 @@ #include #include +#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) int main () diff --git a/tests/test-mbscasestr1.c b/tests/test-mbscasestr1.c index 87f2605c0..1e6585677 100644 --- a/tests/test-mbscasestr1.c +++ b/tests/test-mbscasestr1.c @@ -23,9 +23,19 @@ #include +#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) int main () diff --git a/tests/test-mbscasestr2.c b/tests/test-mbscasestr2.c index fc7dca6e8..548818756 100644 --- a/tests/test-mbscasestr2.c +++ b/tests/test-mbscasestr2.c @@ -24,9 +24,19 @@ #include #include +#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) int main () diff --git a/tests/test-mbscasestr3.c b/tests/test-mbscasestr3.c index 935e45752..24ace449b 100644 --- a/tests/test-mbscasestr3.c +++ b/tests/test-mbscasestr3.c @@ -24,9 +24,19 @@ #include #include +#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) int main () diff --git a/tests/test-mbscasestr4.c b/tests/test-mbscasestr4.c index ef0c26d41..146b3fe5c 100644 --- a/tests/test-mbscasestr4.c +++ b/tests/test-mbscasestr4.c @@ -24,9 +24,19 @@ #include #include +#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) int main () diff --git a/tests/test-mbschr.c b/tests/test-mbschr.c index 33f461273..bf29ee8cb 100644 --- a/tests/test-mbschr.c +++ b/tests/test-mbschr.c @@ -24,9 +24,19 @@ #include #include +#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) int main () diff --git a/tests/test-mbscspn.c b/tests/test-mbscspn.c index 62a29e30a..4403927a7 100644 --- a/tests/test-mbscspn.c +++ b/tests/test-mbscspn.c @@ -24,9 +24,19 @@ #include #include +#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) int main () diff --git a/tests/test-mbsncasecmp.c b/tests/test-mbsncasecmp.c index 2a6ffdfda..6170dffc6 100644 --- a/tests/test-mbsncasecmp.c +++ b/tests/test-mbsncasecmp.c @@ -24,9 +24,19 @@ #include #include +#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) int main () diff --git a/tests/test-mbspbrk.c b/tests/test-mbspbrk.c index fb6be2642..a6a1404da 100644 --- a/tests/test-mbspbrk.c +++ b/tests/test-mbspbrk.c @@ -24,9 +24,19 @@ #include #include +#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) int main () diff --git a/tests/test-mbspcasecmp.c b/tests/test-mbspcasecmp.c index ad9e57584..5000dfce0 100644 --- a/tests/test-mbspcasecmp.c +++ b/tests/test-mbspcasecmp.c @@ -24,9 +24,19 @@ #include #include +#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) int main () diff --git a/tests/test-mbsrchr.c b/tests/test-mbsrchr.c index 58cd6763f..35b865c6c 100644 --- a/tests/test-mbsrchr.c +++ b/tests/test-mbsrchr.c @@ -24,9 +24,19 @@ #include #include +#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) int main () diff --git a/tests/test-mbsspn.c b/tests/test-mbsspn.c index cbd4da5a4..3170a6a94 100644 --- a/tests/test-mbsspn.c +++ b/tests/test-mbsspn.c @@ -24,9 +24,19 @@ #include #include +#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) int main () diff --git a/tests/test-mbsstr1.c b/tests/test-mbsstr1.c index 549121206..d1b079a71 100644 --- a/tests/test-mbsstr1.c +++ b/tests/test-mbsstr1.c @@ -23,9 +23,19 @@ #include +#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) int main () diff --git a/tests/test-mbsstr2.c b/tests/test-mbsstr2.c index 6aebf56af..8ce3be712 100644 --- a/tests/test-mbsstr2.c +++ b/tests/test-mbsstr2.c @@ -24,9 +24,19 @@ #include #include +#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) int main () diff --git a/tests/test-mbsstr3.c b/tests/test-mbsstr3.c index 5461196b9..9f65520cd 100644 --- a/tests/test-mbsstr3.c +++ b/tests/test-mbsstr3.c @@ -24,9 +24,19 @@ #include #include +#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) int main () diff --git a/tests/test-printf-frexp.c b/tests/test-printf-frexp.c index b821e4613..6940ceb96 100644 --- a/tests/test-printf-frexp.c +++ b/tests/test-printf-frexp.c @@ -22,9 +22,19 @@ #include "printf-frexp.h" #include +#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 double my_ldexp (double x, int d) diff --git a/tests/test-printf-frexpl.c b/tests/test-printf-frexpl.c index c57d2f81a..fe481eec8 100644 --- a/tests/test-printf-frexpl.c +++ b/tests/test-printf-frexpl.c @@ -22,11 +22,21 @@ #include "printf-frexpl.h" #include +#include #include #include "fpucw.h" -#define ASSERT(expr) if (!(expr)) abort (); +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) /* On MIPS IRIX machines, LDBL_MIN_EXP is -1021, but the smallest reliable exponent for 'long double' is -964. For exponents below that, the diff --git a/tests/test-printf-posix.c b/tests/test-printf-posix.c index d8e728a27..e4d5e874d 100644 --- a/tests/test-printf-posix.c +++ b/tests/test-printf-posix.c @@ -24,11 +24,21 @@ #include #include +#include #include #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) #include "test-printf-posix.h" diff --git a/tests/test-rbtree_list.c b/tests/test-rbtree_list.c index d6080c05e..c8cd526aa 100644 --- a/tests/test-rbtree_list.c +++ b/tests/test-rbtree_list.c @@ -22,6 +22,7 @@ #include "gl_rbtree_list.h" +#include #include #include "gl_array_list.h" @@ -35,7 +36,16 @@ static const char *objects[15] = }; #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(condition) if (!(condition)) abort () +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) #define RANDOM(n) (rand () % (n)) #define RANDOM_OBJECT() objects[RANDOM (SIZEOF (objects))] diff --git a/tests/test-rbtree_oset.c b/tests/test-rbtree_oset.c index dd778bb02..2ecb81f4a 100644 --- a/tests/test-rbtree_oset.c +++ b/tests/test-rbtree_oset.c @@ -22,6 +22,7 @@ #include "gl_rbtree_oset.h" +#include #include #include @@ -37,7 +38,16 @@ static const char *objects[30] = }; #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(condition) if (!(condition)) abort () +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) #define RANDOM(n) (rand () % (n)) #define RANDOM_OBJECT() objects[RANDOM (SIZEOF (objects))] diff --git a/tests/test-rbtreehash_list.c b/tests/test-rbtreehash_list.c index 7a0cf9665..deb9cdef5 100644 --- a/tests/test-rbtreehash_list.c +++ b/tests/test-rbtreehash_list.c @@ -23,6 +23,7 @@ #include "gl_rbtreehash_list.h" #include +#include #include #include @@ -62,7 +63,16 @@ string_hash (const void *x) } #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(condition) if (!(condition)) abort () +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) #define RANDOM(n) (rand () % (n)) #define RANDOM_OBJECT() objects[RANDOM (SIZEOF (objects))] diff --git a/tests/test-signbit.c b/tests/test-signbit.c index 3a87c6489..63b84eb7d 100644 --- a/tests/test-signbit.c +++ b/tests/test-signbit.c @@ -22,9 +22,19 @@ #include #include +#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) float zerof = 0.0f; double zerod = 0.0; diff --git a/tests/test-snprintf-posix.c b/tests/test-snprintf-posix.c index 3913515e4..bbdf3e351 100644 --- a/tests/test-snprintf-posix.c +++ b/tests/test-snprintf-posix.c @@ -24,11 +24,21 @@ #include #include +#include #include #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) #include "test-snprintf-posix.h" diff --git a/tests/test-snprintf.c b/tests/test-snprintf.c index 7b3e9b49e..c1235ef03 100644 --- a/tests/test-snprintf.c +++ b/tests/test-snprintf.c @@ -26,7 +26,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) int main (int argc, char *argv[]) diff --git a/tests/test-sprintf-posix.c b/tests/test-sprintf-posix.c index bca3b1c6d..54e7117a7 100644 --- a/tests/test-sprintf-posix.c +++ b/tests/test-sprintf-posix.c @@ -24,11 +24,21 @@ #include #include +#include #include #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) #include "test-sprintf-posix.h" diff --git a/tests/test-stat-time.c b/tests/test-stat-time.c index bf3e8dfe3..907ba4b90 100644 --- a/tests/test-stat-time.c +++ b/tests/test-stat-time.c @@ -28,7 +28,16 @@ #include #include -#define ASSERT(condition) if (!(condition)) abort () +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) enum { NFILES = 4 }; diff --git a/tests/test-strcasestr.c b/tests/test-strcasestr.c index 5ea0f4e79..3d18c06d3 100644 --- a/tests/test-strcasestr.c +++ b/tests/test-strcasestr.c @@ -23,9 +23,19 @@ #include +#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) int main () diff --git a/tests/test-striconv.c b/tests/test-striconv.c index 8fb662c80..90c2ed38d 100644 --- a/tests/test-striconv.c +++ b/tests/test-striconv.c @@ -28,10 +28,20 @@ #endif #include +#include #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) int main () diff --git a/tests/test-striconveh.c b/tests/test-striconveh.c index bb72662ea..8810dfe3e 100644 --- a/tests/test-striconveh.c +++ b/tests/test-striconveh.c @@ -28,11 +28,21 @@ #endif #include +#include #include #include #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(expr) if (!(expr)) abort (); +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) /* Magic number for detecting bounds violations. */ #define MAGIC 0x1983EFF1 diff --git a/tests/test-striconveha.c b/tests/test-striconveha.c index 3d833ac16..e3d120cc4 100644 --- a/tests/test-striconveha.c +++ b/tests/test-striconveha.c @@ -28,11 +28,21 @@ #endif #include +#include #include #include #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(expr) if (!(expr)) abort (); +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) /* Magic number for detecting bounds violations. */ #define MAGIC 0x1983EFF1 diff --git a/tests/test-vasnprintf-posix.c b/tests/test-vasnprintf-posix.c index a81865587..f08e1ad99 100644 --- a/tests/test-vasnprintf-posix.c +++ b/tests/test-vasnprintf-posix.c @@ -25,11 +25,21 @@ #include #include +#include #include #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) /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ #ifdef __DECC diff --git a/tests/test-vasnprintf-posix2.c b/tests/test-vasnprintf-posix2.c index eaa95b211..aa68216cd 100644 --- a/tests/test-vasnprintf-posix2.c +++ b/tests/test-vasnprintf-posix2.c @@ -24,10 +24,20 @@ #include "vasnprintf.h" #include +#include #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) int main (int argc, char *argv[]) diff --git a/tests/test-vasnprintf.c b/tests/test-vasnprintf.c index cd901a950..80a2543bb 100644 --- a/tests/test-vasnprintf.c +++ b/tests/test-vasnprintf.c @@ -24,10 +24,20 @@ #include "vasnprintf.h" #include +#include #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 char * my_asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) diff --git a/tests/test-vasprintf-posix.c b/tests/test-vasprintf-posix.c index dad45d143..40798ea2b 100644 --- a/tests/test-vasprintf-posix.c +++ b/tests/test-vasprintf-posix.c @@ -25,11 +25,21 @@ #include #include +#include #include #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) /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ #ifdef __DECC diff --git a/tests/test-vasprintf.c b/tests/test-vasprintf.c index cae32d6ec..70fca148a 100644 --- a/tests/test-vasprintf.c +++ b/tests/test-vasprintf.c @@ -27,7 +27,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_asprintf (char **result, const char *format, ...) diff --git a/tests/test-vfprintf-posix.c b/tests/test-vfprintf-posix.c index 67e50bcf8..95c3017f6 100644 --- a/tests/test-vfprintf-posix.c +++ b/tests/test-vfprintf-posix.c @@ -25,11 +25,21 @@ #include #include +#include #include #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_fprintf (FILE *fp, const char *format, ...) diff --git a/tests/test-vprintf-posix.c b/tests/test-vprintf-posix.c index 6f7f141d1..57b674016 100644 --- a/tests/test-vprintf-posix.c +++ b/tests/test-vprintf-posix.c @@ -25,11 +25,21 @@ #include #include +#include #include #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_printf (const char *format, ...) diff --git a/tests/test-vsnprintf-posix.c b/tests/test-vsnprintf-posix.c index 052cd7266..097872f93 100644 --- a/tests/test-vsnprintf-posix.c +++ b/tests/test-vsnprintf-posix.c @@ -25,11 +25,21 @@ #include #include +#include #include #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 *str, size_t size, const char *format, ...) diff --git a/tests/test-vsnprintf.c b/tests/test-vsnprintf.c index ccc9e5a70..a8ed6ec7c 100644 --- a/tests/test-vsnprintf.c +++ b/tests/test-vsnprintf.c @@ -27,7 +27,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, ...) diff --git a/tests/test-vsprintf-posix.c b/tests/test-vsprintf-posix.c index 43c7196bf..20cc4b2a0 100644 --- a/tests/test-vsprintf-posix.c +++ b/tests/test-vsprintf-posix.c @@ -25,11 +25,21 @@ #include #include +#include #include #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_sprintf (char *str, const char *format, ...) diff --git a/tests/test-xvasprintf.c b/tests/test-xvasprintf.c index a07864c70..41e22e47b 100644 --- a/tests/test-xvasprintf.c +++ b/tests/test-xvasprintf.c @@ -24,12 +24,22 @@ #include "xvasprintf.h" #include +#include #include #include #include "progname.h" -#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 char * my_xasprintf (const char *format, ...) diff --git a/tests/uniconv/test-u16-conv-from-enc.c b/tests/uniconv/test-u16-conv-from-enc.c index 506af0ec7..02ce13720 100644 --- a/tests/uniconv/test-u16-conv-from-enc.c +++ b/tests/uniconv/test-u16-conv-from-enc.c @@ -23,13 +23,23 @@ #include "uniconv.h" +#include #include #include #include "unistr.h" #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(expr) if (!(expr)) abort (); +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) /* Magic number for detecting bounds violations. */ #define MAGIC 0x1983EFF1 diff --git a/tests/uniconv/test-u16-strconv-from-enc.c b/tests/uniconv/test-u16-strconv-from-enc.c index ea805d67b..32e482b8d 100644 --- a/tests/uniconv/test-u16-strconv-from-enc.c +++ b/tests/uniconv/test-u16-strconv-from-enc.c @@ -23,12 +23,22 @@ #include "uniconv.h" +#include #include #include "unistr.h" #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(expr) if (!(expr)) abort (); +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) int main () diff --git a/tests/uniconv/test-u16-strconv-to-enc.c b/tests/uniconv/test-u16-strconv-to-enc.c index c8b9df0aa..35a8eb7b9 100644 --- a/tests/uniconv/test-u16-strconv-to-enc.c +++ b/tests/uniconv/test-u16-strconv-to-enc.c @@ -24,11 +24,21 @@ #include "uniconv.h" #include +#include #include #include #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(expr) if (!(expr)) abort (); +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) int main () diff --git a/tests/uniconv/test-u32-conv-from-enc.c b/tests/uniconv/test-u32-conv-from-enc.c index 3226767ba..5bf5e14e6 100644 --- a/tests/uniconv/test-u32-conv-from-enc.c +++ b/tests/uniconv/test-u32-conv-from-enc.c @@ -23,13 +23,23 @@ #include "uniconv.h" +#include #include #include #include "unistr.h" #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(expr) if (!(expr)) abort (); +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) /* Magic number for detecting bounds violations. */ #define MAGIC 0x1983EFF1 diff --git a/tests/uniconv/test-u32-strconv-from-enc.c b/tests/uniconv/test-u32-strconv-from-enc.c index ab8b86c14..b7c02d826 100644 --- a/tests/uniconv/test-u32-strconv-from-enc.c +++ b/tests/uniconv/test-u32-strconv-from-enc.c @@ -23,12 +23,22 @@ #include "uniconv.h" +#include #include #include "unistr.h" #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(expr) if (!(expr)) abort (); +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) int main () diff --git a/tests/uniconv/test-u32-strconv-to-enc.c b/tests/uniconv/test-u32-strconv-to-enc.c index 6d6588672..0173370ce 100644 --- a/tests/uniconv/test-u32-strconv-to-enc.c +++ b/tests/uniconv/test-u32-strconv-to-enc.c @@ -24,11 +24,21 @@ #include "uniconv.h" #include +#include #include #include #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(expr) if (!(expr)) abort (); +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) int main () diff --git a/tests/uniconv/test-u8-conv-from-enc.c b/tests/uniconv/test-u8-conv-from-enc.c index e74bc5893..95cd1003d 100644 --- a/tests/uniconv/test-u8-conv-from-enc.c +++ b/tests/uniconv/test-u8-conv-from-enc.c @@ -23,13 +23,23 @@ #include "uniconv.h" +#include #include #include #include "unistr.h" #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(expr) if (!(expr)) abort (); +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) /* Magic number for detecting bounds violations. */ #define MAGIC 0x1983EFF1 diff --git a/tests/uniconv/test-u8-strconv-from-enc.c b/tests/uniconv/test-u8-strconv-from-enc.c index 2d640992e..2a937cc48 100644 --- a/tests/uniconv/test-u8-strconv-from-enc.c +++ b/tests/uniconv/test-u8-strconv-from-enc.c @@ -23,12 +23,22 @@ #include "uniconv.h" +#include #include #include "unistr.h" #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(expr) if (!(expr)) abort (); +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) int main () diff --git a/tests/uniconv/test-u8-strconv-to-enc.c b/tests/uniconv/test-u8-strconv-to-enc.c index e03582fb7..86550f5c2 100644 --- a/tests/uniconv/test-u8-strconv-to-enc.c +++ b/tests/uniconv/test-u8-strconv-to-enc.c @@ -24,11 +24,21 @@ #include "uniconv.h" #include +#include #include #include #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(expr) if (!(expr)) abort (); +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) int main () -- 2.11.0