From 30d5b101cc83d1e518c0d4cd2ea43d2817a7a849 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 18 Apr 2024 01:34:02 +0200 Subject: [PATCH] totalorder* tests: Strengthen tests. * tests/test-totalorder.h: Include . (positive_NaN_with_payload, negative_NaN_with_payload): New functions. (main): Test quiet NaNs of each sign with different payload. * tests/test-totalorder.c (TOTALORDER_POSITIVE_NAN, TOTALORDER_NEGATIVE_NAN): Remove macros. (TOTALORDER_SETPAYLOAD): New macro. * tests/test-totalorderf.c (TOTALORDER_POSITIVE_NAN, TOTALORDER_NEGATIVE_NAN): Remove macros. (TOTALORDER_SETPAYLOAD): New macro. * tests/test-totalorderl.c (TOTALORDER_POSITIVE_NAN, TOTALORDER_NEGATIVE_NAN): Remove macros. (TOTALORDER_SETPAYLOAD): New macro. * modules/totalorder-tests (Depends-on): Add setpayload. (Makefile.am): Link test-totalorder with $(SETPAYLOAD_LIBM). * modules/totalorderf-tests (Depends-on): Add setpayloadf. (Makefile.am): Link test-totalorderf with $(SETPAYLOADF_LIBM). * modules/totalorderl-tests (Depends-on): Add setpayloadl. (Makefile.am): Link test-totalorderl with $(SETPAYLOADL_LIBM). --- ChangeLog | 22 ++++++++++++++++++++++ modules/totalorder-tests | 3 ++- modules/totalorderf-tests | 3 ++- modules/totalorderl-tests | 3 ++- tests/test-totalorder.c | 3 +-- tests/test-totalorder.h | 24 ++++++++++++++++++++++-- tests/test-totalorderf.c | 3 +-- tests/test-totalorderl.c | 3 +-- 8 files changed, 53 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 646653ffe5..7c2e380dba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2024-04-17 Bruno Haible + + totalorder* tests: Strengthen tests. + * tests/test-totalorder.h: Include . + (positive_NaN_with_payload, negative_NaN_with_payload): New functions. + (main): Test quiet NaNs of each sign with different payload. + * tests/test-totalorder.c (TOTALORDER_POSITIVE_NAN, + TOTALORDER_NEGATIVE_NAN): Remove macros. + (TOTALORDER_SETPAYLOAD): New macro. + * tests/test-totalorderf.c (TOTALORDER_POSITIVE_NAN, + TOTALORDER_NEGATIVE_NAN): Remove macros. + (TOTALORDER_SETPAYLOAD): New macro. + * tests/test-totalorderl.c (TOTALORDER_POSITIVE_NAN, + TOTALORDER_NEGATIVE_NAN): Remove macros. + (TOTALORDER_SETPAYLOAD): New macro. + * modules/totalorder-tests (Depends-on): Add setpayload. + (Makefile.am): Link test-totalorder with $(SETPAYLOAD_LIBM). + * modules/totalorderf-tests (Depends-on): Add setpayloadf. + (Makefile.am): Link test-totalorderf with $(SETPAYLOADF_LIBM). + * modules/totalorderl-tests (Depends-on): Add setpayloadl. + (Makefile.am): Link test-totalorderl with $(SETPAYLOADL_LIBM). + 2024-04-17 Bruno Haible gnulib-tool.py: Use same warning style as gnulib-tool.sh. diff --git a/modules/totalorder-tests b/modules/totalorder-tests index ca6238f7cb..6df07edfcf 100644 --- a/modules/totalorder-tests +++ b/modules/totalorder-tests @@ -9,10 +9,11 @@ tests/macros.h Depends-on: signed-nan signed-snan +setpayload configure.ac: Makefile.am: TESTS += test-totalorder check_PROGRAMS += test-totalorder -test_totalorder_LDADD = $(LDADD) @TOTALORDER_LIBM@ +test_totalorder_LDADD = $(LDADD) @TOTALORDER_LIBM@ $(SETPAYLOAD_LIBM) diff --git a/modules/totalorderf-tests b/modules/totalorderf-tests index dbca0add15..258cb9c0c2 100644 --- a/modules/totalorderf-tests +++ b/modules/totalorderf-tests @@ -9,10 +9,11 @@ tests/macros.h Depends-on: signed-nan signed-snan +setpayloadf configure.ac: Makefile.am: TESTS += test-totalorderf check_PROGRAMS += test-totalorderf -test_totalorderf_LDADD = $(LDADD) @TOTALORDERF_LIBM@ +test_totalorderf_LDADD = $(LDADD) @TOTALORDERF_LIBM@ $(SETPAYLOADF_LIBM) diff --git a/modules/totalorderl-tests b/modules/totalorderl-tests index ab73b6a5fd..222cc32992 100644 --- a/modules/totalorderl-tests +++ b/modules/totalorderl-tests @@ -9,10 +9,11 @@ tests/macros.h Depends-on: signed-nan signed-snan +setpayloadl configure.ac: Makefile.am: TESTS += test-totalorderl check_PROGRAMS += test-totalorderl -test_totalorderl_LDADD = $(LDADD) @TOTALORDERL_LIBM@ +test_totalorderl_LDADD = $(LDADD) @TOTALORDERL_LIBM@ $(SETPAYLOADL_LIBM) diff --git a/tests/test-totalorder.c b/tests/test-totalorder.c index 77926e4a5f..412c3d301e 100644 --- a/tests/test-totalorder.c +++ b/tests/test-totalorder.c @@ -26,8 +26,7 @@ SIGNATURE_CHECK (totalorder, int, (const double *, const 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_SETPAYLOAD setpayload #define TOTALORDER_HAVE_SNAN HAVE_SNAND #define TOTALORDER_POSITIVE_SNAN memory_positive_SNaNd #define TOTALORDER_NEGATIVE_SNAN memory_negative_SNaNd diff --git a/tests/test-totalorder.h b/tests/test-totalorder.h index c82d112956..b02cec310b 100644 --- a/tests/test-totalorder.h +++ b/tests/test-totalorder.h @@ -16,18 +16,37 @@ #include +#include #include "infinity.h" #include "macros.h" #include "minus-zero.h" #include "signed-nan.h" #include "signed-snan.h" +static TOTALORDER_TYPE +positive_NaN_with_payload (int payload) +{ + TOTALORDER_TYPE x; + ASSERT (TOTALORDER_SETPAYLOAD (&x.value, payload) == 0); + return x; +} + +static TOTALORDER_TYPE +negative_NaN_with_payload (int payload) +{ + TOTALORDER_TYPE x; + ASSERT (TOTALORDER_SETPAYLOAD (&x.value, payload) == 0); + x.value = - x.value; + return x; +} + int main () { TOTALORDER_TYPE x[] = { - { TOTALORDER_NEGATIVE_NAN () }, + negative_NaN_with_payload (1729), + negative_NaN_with_payload (641), #if TOTALORDER_HAVE_SNAN TOTALORDER_NEGATIVE_SNAN (), #endif @@ -44,7 +63,8 @@ main () #if TOTALORDER_HAVE_SNAN TOTALORDER_POSITIVE_SNAN (), #endif - { TOTALORDER_POSITIVE_NAN () } + positive_NaN_with_payload (641), + positive_NaN_with_payload (1729) }; int n = SIZEOF (x); int result = 0; diff --git a/tests/test-totalorderf.c b/tests/test-totalorderf.c index 0094fad5c5..a3dd23a296 100644 --- a/tests/test-totalorderf.c +++ b/tests/test-totalorderf.c @@ -26,8 +26,7 @@ SIGNATURE_CHECK (totalorderf, int, (const float *, const 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_SETPAYLOAD setpayloadf #define TOTALORDER_HAVE_SNAN HAVE_SNANF #define TOTALORDER_POSITIVE_SNAN memory_positive_SNaNf #define TOTALORDER_NEGATIVE_SNAN memory_negative_SNaNf diff --git a/tests/test-totalorderl.c b/tests/test-totalorderl.c index 74364ddd75..f3db8194f7 100644 --- a/tests/test-totalorderl.c +++ b/tests/test-totalorderl.c @@ -26,8 +26,7 @@ SIGNATURE_CHECK (totalorderl, int, (const long double *, const 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_SETPAYLOAD setpayloadl #define TOTALORDER_HAVE_SNAN HAVE_SNANL #define TOTALORDER_POSITIVE_SNAN memory_positive_SNaNl #define TOTALORDER_NEGATIVE_SNAN memory_negative_SNaNl -- 2.39.5