]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
totalorder* tests: Strengthen tests.
authorBruno Haible <bruno@clisp.org>
Wed, 17 Apr 2024 23:34:02 +0000 (01:34 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 17 Apr 2024 23:34:02 +0000 (01:34 +0200)
* tests/test-totalorder.h: Include <math.h>.
(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
modules/totalorder-tests
modules/totalorderf-tests
modules/totalorderl-tests
tests/test-totalorder.c
tests/test-totalorder.h
tests/test-totalorderf.c
tests/test-totalorderl.c

index 646653ffe54360b190424cbbefee04fd52059fbb..7c2e380dbab1205aa1b6c5ee4721472e35fb96cb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2024-04-17  Bruno Haible  <bruno@clisp.org>
+
+       totalorder* tests: Strengthen tests.
+       * tests/test-totalorder.h: Include <math.h>.
+       (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  <bruno@clisp.org>
 
        gnulib-tool.py: Use same warning style as gnulib-tool.sh.
index ca6238f7cbb1743f01df108bdef9f861c9b2137a..6df07edfcf8071bb1ad5e57d5d6111b32c812ad3 100644 (file)
@@ -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)
index dbca0add15399ea803ada4aa752dbef3169b8aa1..258cb9c0c2f75a98007b617b6b5b5fb942230518 100644 (file)
@@ -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)
index ab73b6a5fd693011f616b9d95b62df73f3ef1570..222cc3299211479e3e9da27436cabdd8ef995493 100644 (file)
@@ -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)
index 77926e4a5f23c73518497e6cf9ae4915ea9ce688..412c3d301e1f1fa9257e2ae7dd53163e5478dc7d 100644 (file)
@@ -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
index c82d11295673fe9ea3a4b8014d9d9c4f49ba14ee..b02cec310b610ba5d256d5ab4ebcc3ba1091d53f 100644 (file)
 
 #include <stdio.h>
 
+#include <math.h>
 #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;
index 0094fad5c550244f3f81473c4dd77fa15eed92cc..a3dd23a2969c72a68b417a7c3f49ffafecf312db 100644 (file)
@@ -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
index 74364ddd756a389fc43fe9762c486b786591be84..f3db8194f72d6384357263a7759d700e30a6506b 100644 (file)
@@ -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