X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-signbit.c;h=c8981498a1feb7dd398f68a479445e4a3525fb97;hb=368777cd04f76f7a3b242006fdf6c1e6b77381de;hp=94cab376721c68bfe087e4b064e29c76df47532c;hpb=ea0f5bf6444c14f97c069b5da723781ecb8a84aa;p=gnulib.git diff --git a/tests/test-signbit.c b/tests/test-signbit.c index 94cab3767..c8981498a 100644 --- a/tests/test-signbit.c +++ b/tests/test-signbit.c @@ -1,5 +1,5 @@ /* Test of signbit() substitute. - Copyright (C) 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -20,37 +20,21 @@ #include +/* signbit must be a macro. */ +#ifndef signbit +# error missing declaration +#endif + #include #include -#include -#include -#define ASSERT(expr) \ - do \ - { \ - if (!(expr)) \ - { \ - fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ - fflush (stderr); \ - abort (); \ - } \ - } \ - while (0) +#include "minus-zero.h" +#include "macros.h" float zerof = 0.0f; double zerod = 0.0; long double zerol = 0.0L; -/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f. - So we use -zerof instead. */ - -/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. - So we use -zerod instead. */ - -/* On HP-UX 10.20, negating 0.0L does not yield -0.0L. - So we use minus_zerol instead. */ -long double minus_zerol = -LDBL_MIN * LDBL_MIN; - static void test_signbitf () { @@ -63,10 +47,10 @@ test_signbitf () ASSERT (signbit (-2.718e-30f)); /* Zeros. */ ASSERT (!signbit (0.0f)); - if (1.0f / -zerof < 0) - ASSERT (signbit (-zerof)); + if (1.0f / minus_zerof < 0) + ASSERT (signbit (minus_zerof)); else - ASSERT (!signbit (-zerof)); + ASSERT (!signbit (minus_zerof)); /* Infinite values. */ ASSERT (!signbit (1.0f / 0.0f)); ASSERT (signbit (-1.0f / 0.0f)); @@ -108,10 +92,10 @@ test_signbitd () ASSERT (signbit (-2.718e-30)); /* Zeros. */ ASSERT (!signbit (0.0)); - if (1.0 / -zerod < 0) - ASSERT (signbit (-zerod)); + if (1.0 / minus_zerod < 0) + ASSERT (signbit (minus_zerod)); else - ASSERT (!signbit (-zerod)); + ASSERT (!signbit (minus_zerod)); /* Infinite values. */ ASSERT (!signbit (1.0 / 0.0)); ASSERT (signbit (-1.0 / 0.0));