diff options
Diffstat (limited to 'tests/test-signbit.c')
-rw-r--r-- | tests/test-signbit.c | 88 |
1 files changed, 18 insertions, 70 deletions
diff --git a/tests/test-signbit.c b/tests/test-signbit.c index d1305ce0..da5b7981 100644 --- a/tests/test-signbit.c +++ b/tests/test-signbit.c @@ -1,5 +1,5 @@ /* Test of signbit() substitute. - Copyright (C) 2007-2022 Free Software Foundation, Inc. + Copyright (C) 2007-2024 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 @@ -30,6 +30,8 @@ #include "minus-zero.h" #include "infinity.h" +#include "signed-nan.h" +#include "signed-snan.h" #include "macros.h" float zerof = 0.0f; @@ -56,28 +58,12 @@ test_signbitf () ASSERT (!signbit (Infinityf ())); ASSERT (signbit (- Infinityf ())); /* Quiet NaN. */ - (void) signbit (zerof / zerof); -#if defined FLT_EXPBIT0_WORD && defined FLT_EXPBIT0_BIT + ASSERT (!signbit (positive_NaNf ())); + ASSERT (signbit (negative_NaNf ())); +#if HAVE_SNANF /* Signalling NaN. */ - { - #define NWORDS \ - ((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) - typedef union { float value; unsigned int word[NWORDS]; } memory_float; - memory_float m; - m.value = zerof / zerof; -# if FLT_EXPBIT0_BIT > 0 - m.word[FLT_EXPBIT0_WORD] ^= (unsigned int) 1 << (FLT_EXPBIT0_BIT - 1); -# else - m.word[FLT_EXPBIT0_WORD + (FLT_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] - ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1); -# endif - if (FLT_EXPBIT0_WORD < NWORDS / 2) - m.word[FLT_EXPBIT0_WORD + 1] |= (unsigned int) 1 << FLT_EXPBIT0_BIT; - else - m.word[0] |= (unsigned int) 1; - (void) signbit (m.value); - #undef NWORDS - } + ASSERT (!signbit (positive_SNaNf ())); + ASSERT (signbit (negative_SNaNf ())); #endif } @@ -101,26 +87,12 @@ test_signbitd () ASSERT (!signbit (Infinityd ())); ASSERT (signbit (- Infinityd ())); /* Quiet NaN. */ - (void) signbit (zerod / zerod); -#if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT + ASSERT (!signbit (positive_NaNd ())); + ASSERT (signbit (negative_NaNd ())); +#if HAVE_SNAND /* Signalling NaN. */ - { - #define NWORDS \ - ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) - typedef union { double value; unsigned int word[NWORDS]; } memory_double; - memory_double m; - m.value = zerod / zerod; -# if DBL_EXPBIT0_BIT > 0 - m.word[DBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (DBL_EXPBIT0_BIT - 1); -# else - m.word[DBL_EXPBIT0_WORD + (DBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] - ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1); -# endif - m.word[DBL_EXPBIT0_WORD + (DBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] - |= (unsigned int) 1 << DBL_EXPBIT0_BIT; - (void) signbit (m.value); - #undef NWORDS - } + ASSERT (!signbit (positive_SNaNd ())); + ASSERT (signbit (negative_SNaNd ())); #endif } @@ -144,36 +116,12 @@ test_signbitl () ASSERT (!signbit (Infinityl ())); ASSERT (signbit (- Infinityl ())); /* Quiet NaN. */ - (void) signbit (zerol / zerol); -#if defined LDBL_EXPBIT0_WORD && defined LDBL_EXPBIT0_BIT + ASSERT (!signbit (positive_NaNl ())); + ASSERT (signbit (negative_NaNl ())); +#if HAVE_SNANL /* Signalling NaN. */ - { - #define NWORDS \ - ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) - typedef union { long double value; unsigned int word[NWORDS]; } memory_long_double; - -#if defined __powerpc__ && LDBL_MANT_DIG == 106 - /* This is PowerPC "double double", a pair of two doubles. Inf and Nan are - represented as the corresponding 64-bit IEEE values in the first double; - the second is ignored. Manipulate only the first double. */ - #undef NWORDS - #define NWORDS \ - ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) -#endif - - memory_long_double m; - m.value = zerol / zerol; -# if LDBL_EXPBIT0_BIT > 0 - m.word[LDBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (LDBL_EXPBIT0_BIT - 1); -# else - m.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] - ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1); -# endif - m.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] - |= (unsigned int) 1 << LDBL_EXPBIT0_BIT; - (void) signbit (m.value); - #undef NWORDS - } + ASSERT (!signbit (positive_SNaNl ())); + ASSERT (signbit (negative_SNaNl ())); #endif } |