From: Bruno Haible Date: Sat, 14 Oct 2023 18:43:47 +0000 (+0200) Subject: totalorder* tests: Test also the signalling NaNs. X-Git-Tag: v1.0~701 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=57b9775f4a36aadb32bfcc445bfe8038190ca689;p=gnulib.git totalorder* tests: Test also the signalling NaNs. * tests/test-totalorder.h: Include signed-snan.h. (main): Change the array initializer to contain memory_* objects rather than floating-point numbers. This is needed for i386 and x86_64 CPUs. * tests/test-totalorder.c (TOTALORDER_TYPE): Use memory_double. (TOTALORDER_HAVE_SNAN, TOTALORDER_POSITIVE_SNAN, TOTALORDER_NEGATIVE_SNAN): New macros. * tests/test-totalorderf.c (TOTALORDER_TYPE): Use memory_float. (TOTALORDER_HAVE_SNAN, TOTALORDER_POSITIVE_SNAN, TOTALORDER_NEGATIVE_SNAN): New macros. * tests/test-totalorderl.c (TOTALORDER_TYPE): Use memory_long_double. (TOTALORDER_HAVE_SNAN, TOTALORDER_POSITIVE_SNAN, TOTALORDER_NEGATIVE_SNAN): New macros. * modules/totalorder-tests (Depends-on): Add signed-snan. * modules/totalorderf-tests (Depends-on): Likewise. * modules/totalorderl-tests (Depends-on): Likewise. --- diff --git a/ChangeLog b/ChangeLog index fadb0a9978..f4db2f61c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2023-10-14 Bruno Haible + + totalorder* tests: Test also the signalling NaNs. + * tests/test-totalorder.h: Include signed-snan.h. + (main): Change the array initializer to contain memory_* objects rather + than floating-point numbers. This is needed for i386 and x86_64 CPUs. + * tests/test-totalorder.c (TOTALORDER_TYPE): Use memory_double. + (TOTALORDER_HAVE_SNAN, TOTALORDER_POSITIVE_SNAN, + TOTALORDER_NEGATIVE_SNAN): New macros. + * tests/test-totalorderf.c (TOTALORDER_TYPE): Use memory_float. + (TOTALORDER_HAVE_SNAN, TOTALORDER_POSITIVE_SNAN, + TOTALORDER_NEGATIVE_SNAN): New macros. + * tests/test-totalorderl.c (TOTALORDER_TYPE): Use memory_long_double. + (TOTALORDER_HAVE_SNAN, TOTALORDER_POSITIVE_SNAN, + TOTALORDER_NEGATIVE_SNAN): New macros. + * modules/totalorder-tests (Depends-on): Add signed-snan. + * modules/totalorderf-tests (Depends-on): Likewise. + * modules/totalorderl-tests (Depends-on): Likewise. + 2023-10-14 Bruno Haible totalorder* tests: Make it easier to debug failures. diff --git a/modules/totalorder-tests b/modules/totalorder-tests index 2035acd697..ca6238f7cb 100644 --- a/modules/totalorder-tests +++ b/modules/totalorder-tests @@ -8,6 +8,7 @@ tests/macros.h Depends-on: signed-nan +signed-snan configure.ac: diff --git a/modules/totalorderf-tests b/modules/totalorderf-tests index 5fb1cc8225..dbca0add15 100644 --- a/modules/totalorderf-tests +++ b/modules/totalorderf-tests @@ -8,6 +8,7 @@ tests/macros.h Depends-on: signed-nan +signed-snan configure.ac: diff --git a/modules/totalorderl-tests b/modules/totalorderl-tests index 85d1768dfc..ab73b6a5fd 100644 --- a/modules/totalorderl-tests +++ b/modules/totalorderl-tests @@ -8,6 +8,7 @@ tests/macros.h Depends-on: signed-nan +signed-snan configure.ac: diff --git a/tests/test-totalorder.c b/tests/test-totalorder.c index 2b50b8d437..d921ab716c 100644 --- a/tests/test-totalorder.c +++ b/tests/test-totalorder.c @@ -23,9 +23,12 @@ SIGNATURE_CHECK (totalorderf, int, (const float *, const float *)); #define TOTALORDER totalorder -#define TOTALORDER_TYPE double +#define TOTALORDER_TYPE memory_double #define TOTALORDER_INF Infinityd #define TOTALORDER_MINUS_ZERO minus_zerod #define TOTALORDER_POSITIVE_NAN positive_NaNd #define TOTALORDER_NEGATIVE_NAN negative_NaNd +#define TOTALORDER_HAVE_SNAN HAVE_SNAND +#define TOTALORDER_POSITIVE_SNAN memory_positive_SNaNd +#define TOTALORDER_NEGATIVE_SNAN memory_negative_SNaNd #include "test-totalorder.h" diff --git a/tests/test-totalorder.h b/tests/test-totalorder.h index b242ff72f3..6292ea130a 100644 --- a/tests/test-totalorder.h +++ b/tests/test-totalorder.h @@ -20,22 +20,38 @@ #include "macros.h" #include "minus-zero.h" #include "signed-nan.h" +#include "signed-snan.h" int main () { TOTALORDER_TYPE x[] = { - TOTALORDER_NEGATIVE_NAN (), -TOTALORDER_INF (), -1e37, -1, -1e-5, - TOTALORDER_MINUS_ZERO, 0, - 1e-5, 1, 1e37, TOTALORDER_INF (), TOTALORDER_POSITIVE_NAN () + { .value = TOTALORDER_NEGATIVE_NAN () }, +#if TOTALORDER_HAVE_SNAN + TOTALORDER_NEGATIVE_SNAN (), +#endif + { .value = -TOTALORDER_INF () }, + { .value = -1e37 }, + { .value = -1 }, + { .value = -1e-5 }, + { .value = TOTALORDER_MINUS_ZERO }, + { .value = 0 }, + { .value = 1e-5 }, + { .value = 1 }, + { .value = 1e37 }, + { .value = TOTALORDER_INF () }, +#if TOTALORDER_HAVE_SNAN + TOTALORDER_POSITIVE_SNAN (), +#endif + { .value = TOTALORDER_POSITIVE_NAN () } }; int n = SIZEOF (x); int result = 0; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) - if (!(!!TOTALORDER (&x[i], &x[j]) == (i <= j))) + if (!(!!TOTALORDER (&x[i].value, &x[j].value) == (i <= j))) { fprintf (stderr, "Failed: i=%d j=%d\n", i, j); result = 1; diff --git a/tests/test-totalorderf.c b/tests/test-totalorderf.c index 6d921dd103..1aaf35004d 100644 --- a/tests/test-totalorderf.c +++ b/tests/test-totalorderf.c @@ -23,9 +23,12 @@ SIGNATURE_CHECK (totalorderf, int, (const float *, const float *)); #define TOTALORDER totalorderf -#define TOTALORDER_TYPE float +#define TOTALORDER_TYPE memory_float #define TOTALORDER_INF Infinityf #define TOTALORDER_MINUS_ZERO minus_zerof #define TOTALORDER_POSITIVE_NAN positive_NaNf #define TOTALORDER_NEGATIVE_NAN negative_NaNf +#define TOTALORDER_HAVE_SNAN HAVE_SNANF +#define TOTALORDER_POSITIVE_SNAN memory_positive_SNaNf +#define TOTALORDER_NEGATIVE_SNAN memory_negative_SNaNf #include "test-totalorder.h" diff --git a/tests/test-totalorderl.c b/tests/test-totalorderl.c index 89df547fc5..0344f04b18 100644 --- a/tests/test-totalorderl.c +++ b/tests/test-totalorderl.c @@ -23,9 +23,12 @@ SIGNATURE_CHECK (totalorderl, int, (const long double *, const long double *)); #define TOTALORDER totalorderl -#define TOTALORDER_TYPE long double +#define TOTALORDER_TYPE memory_long_double #define TOTALORDER_INF Infinityl #define TOTALORDER_MINUS_ZERO minus_zerol #define TOTALORDER_POSITIVE_NAN positive_NaNl #define TOTALORDER_NEGATIVE_NAN negative_NaNl +#define TOTALORDER_HAVE_SNAN HAVE_SNANL +#define TOTALORDER_POSITIVE_SNAN memory_positive_SNaNl +#define TOTALORDER_NEGATIVE_SNAN memory_negative_SNaNl #include "test-totalorder.h"