X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Fmacros.h;h=adb3744d5c03732ce758ee158199b61c9e1cb7d7;hb=3c7d5d0cf885baa9add1cd34364fa1adfc459630;hp=dc55fbe02eb195fd387655b6bbca552c81149242;hpb=987e5651e8d1c5aa933c9ce88562806af4093702;p=gnulib.git diff --git a/tests/macros.h b/tests/macros.h index dc55fbe02..adb3744d5 100644 --- a/tests/macros.h +++ b/tests/macros.h @@ -1,5 +1,5 @@ /* Common macros used by gnulib tests. - Copyright (C) 2006-2009 Free Software Foundation, Inc. + Copyright (C) 2006-2011 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 @@ -21,9 +21,16 @@ #include #include +/* Define ASSERT_STREAM before including this file if ASSERT must + target a stream other than stderr. */ +#ifndef ASSERT_STREAM +# define ASSERT_STREAM stderr +#endif + /* ASSERT (condition); verifies that the specified condition is fulfilled. If not, a message - is printed to stderr and the program is terminated with an error code. + is printed to ASSERT_STREAM if defined (defaulting to stderr if + undefined) and the program is terminated with an error code. This macro has the following properties: - The programmer specifies the expected condition, not the failure @@ -33,16 +40,17 @@ - On Unix platforms, the tester can debug the test program with a debugger (provided core dumps are enabled: "ulimit -c unlimited"). - For the sake of platforms where no debugger is available (such as - some mingw systems), an error message is printed on stderr that - includes the source location of the ASSERT invocation. + some mingw systems), an error message is printed on the error + stream that includes the source location of the ASSERT invocation. */ #define ASSERT(expr) \ do \ { \ if (!(expr)) \ { \ - fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ - fflush (stderr); \ + fprintf (ASSERT_STREAM, "%s:%d: assertion failed\n", \ + __FILE__, __LINE__); \ + fflush (ASSERT_STREAM); \ abort (); \ } \ } \ @@ -54,3 +62,7 @@ *not* work for function parameters of array type, because they are actually parameters of pointer type. */ #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) + +/* STREQ (str1, str2) + Return true if two strings compare equal. */ +#define STREQ(a, b) (strcmp (a, b) == 0)