]> Savannah Git Hosting - gnulib.git/commitdiff
totalorder* tests: Test also the signalling NaNs.
authorBruno Haible <bruno@clisp.org>
Sat, 14 Oct 2023 18:43:47 +0000 (20:43 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 14 Oct 2023 18:43:47 +0000 (20:43 +0200)
* 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.

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 fadb0a9978a3634916af4e8a5597d37dc8846cf9..f4db2f61c113051497790bc63f0ca851681c2423 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2023-10-14  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        totalorder* tests: Make it easier to debug failures.
index 2035acd69748b08f975e2cfb048d7e2fcfe9e0aa..ca6238f7cbb1743f01df108bdef9f861c9b2137a 100644 (file)
@@ -8,6 +8,7 @@ tests/macros.h
 
 Depends-on:
 signed-nan
+signed-snan
 
 configure.ac:
 
index 5fb1cc8225d334251595d25dbed84d7597069f43..dbca0add15399ea803ada4aa752dbef3169b8aa1 100644 (file)
@@ -8,6 +8,7 @@ tests/macros.h
 
 Depends-on:
 signed-nan
+signed-snan
 
 configure.ac:
 
index 85d1768dfc111031116c74b2500b5dade992c6ac..ab73b6a5fd693011f616b9d95b62df73f3ef1570 100644 (file)
@@ -8,6 +8,7 @@ tests/macros.h
 
 Depends-on:
 signed-nan
+signed-snan
 
 configure.ac:
 
index 2b50b8d43777e6b369b3418e3a77704d8ce6154a..d921ab716cd0649eb50d1ed3de5ca448166f95ee 100644 (file)
 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"
index b242ff72f3d952e7b568061cf41ee37c26484e3f..6292ea130aeed97fb9adb3edbfd8364b172b8b7d 100644 (file)
 #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;
index 6d921dd1035cf155e8f3c95b6983d15560208504..1aaf35004d6f67136f0b2311e0ccda7be63f6de3 100644 (file)
 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"
index 89df547fc5afa3a793a49f3ffed591f6a5f2836d..0344f04b18513120150e8cd4a1005d056046c78d 100644 (file)
 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"