]> Savannah Git Hosting - gnulib.git/commitdiff
totalorder* tests: Verify also the function signatures.
authorBruno Haible <bruno@clisp.org>
Sat, 14 Oct 2023 18:43:39 +0000 (20:43 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 14 Oct 2023 18:43:39 +0000 (20:43 +0200)
* tests/test-totalorder.h: New file, based on tests/test-totalorder.c.
* tests/test-totalorder.c: Check the signature. Include
test-totalorder.h for the rest.
* tests/test-totalorderf.c: Include <config.h>, <math.h>. Check the
signature. Include test-totalorder.h instead of test-totalorder.c.
* tests/test-totalorderl.c: Likewise.
* modules/totalorder-tests (Files): Add test-totalorder.h, signature.h.
* modules/totalorderf-tests (Files): Add test-totalorder.h, signature.h.
Remove test-totalorder.c.
* modules/totalorderl-tests (Files): Likewise.

ChangeLog
modules/totalorder-tests
modules/totalorderf-tests
modules/totalorderl-tests
tests/test-totalorder.c
tests/test-totalorder.h [new file with mode: 0644]
tests/test-totalorderf.c
tests/test-totalorderl.c

index 40b2116a88ef535ebf818a1878cea4ddd2d47fb8..db5cd181482ed158dd1b5f8092d47c23e0333773 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-10-14  Bruno Haible  <bruno@clisp.org>
+
+       totalorder* tests: Verify also the function signatures.
+       * tests/test-totalorder.h: New file, based on tests/test-totalorder.c.
+       * tests/test-totalorder.c: Check the signature. Include
+       test-totalorder.h for the rest.
+       * tests/test-totalorderf.c: Include <config.h>, <math.h>. Check the
+       signature. Include test-totalorder.h instead of test-totalorder.c.
+       * tests/test-totalorderl.c: Likewise.
+       * modules/totalorder-tests (Files): Add test-totalorder.h, signature.h.
+       * modules/totalorderf-tests (Files): Add test-totalorder.h, signature.h.
+       Remove test-totalorder.c.
+       * modules/totalorderl-tests (Files): Likewise.
+
 2023-10-14  Bruno Haible  <bruno@clisp.org>
 
        totalorder*: Improve documentation.
index 3741b88d4c108378470efb6564a990b2a488f185..2035acd69748b08f975e2cfb048d7e2fcfe9e0aa 100644 (file)
@@ -1,7 +1,9 @@
 Files:
 tests/test-totalorder.c
+tests/test-totalorder.h
 tests/minus-zero.h
 tests/infinity.h
+tests/signature.h
 tests/macros.h
 
 Depends-on:
index f2801f496f272bcaa0efce4c137b79fd929f8c0b..5fb1cc8225d334251595d25dbed84d7597069f43 100644 (file)
@@ -1,8 +1,9 @@
 Files:
 tests/test-totalorderf.c
-tests/test-totalorder.c
+tests/test-totalorder.h
 tests/minus-zero.h
 tests/infinity.h
+tests/signature.h
 tests/macros.h
 
 Depends-on:
index fa25c3e301ab56ccb412b0def3a180f84a218b63..85d1768dfc111031116c74b2500b5dade992c6ac 100644 (file)
@@ -1,8 +1,9 @@
 Files:
 tests/test-totalorderl.c
-tests/test-totalorder.c
+tests/test-totalorder.h
 tests/minus-zero.h
 tests/infinity.h
+tests/signature.h
 tests/macros.h
 
 Depends-on:
index af903c68b51485c7f65aa43c2ef25e52e1b6dc93..2b50b8d43777e6b369b3418e3a77704d8ce6154a 100644 (file)
 
 #include <config.h>
 
+/* Specification.  */
 #include <math.h>
 
-#include "infinity.h"
-#include "macros.h"
-#include "minus-zero.h"
-#include "signed-nan.h"
+#include "signature.h"
+SIGNATURE_CHECK (totalorderf, int, (const float *, const float *));
 
-#ifndef TOTALORDER
-# define TOTALORDER totalorder
-# define TOTALORDER_INF Infinityd
-# define TOTALORDER_MINUS_ZERO minus_zerod
-# define TOTALORDER_POSITIVE_NAN positive_NaNd
-# define TOTALORDER_NEGATIVE_NAN negative_NaNd
-# define TOTALORDER_TYPE double
-#endif
-
-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 ()
-    };
-  int n = sizeof x / sizeof *x;
-
-  for (int i = 0; i < n; i++)
-    for (int j = 0; j < n; j++)
-      ASSERT (!!TOTALORDER (&x[i], &x[j]) == (i <= j));
-  return 0;
-}
+#define TOTALORDER totalorder
+#define TOTALORDER_TYPE double
+#define TOTALORDER_INF Infinityd
+#define TOTALORDER_MINUS_ZERO minus_zerod
+#define TOTALORDER_POSITIVE_NAN positive_NaNd
+#define TOTALORDER_NEGATIVE_NAN negative_NaNd
+#include "test-totalorder.h"
diff --git a/tests/test-totalorder.h b/tests/test-totalorder.h
new file mode 100644 (file)
index 0000000..2405e49
--- /dev/null
@@ -0,0 +1,37 @@
+/* Test a totalorder-like function.
+   Copyright 2023 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
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+#include "infinity.h"
+#include "macros.h"
+#include "minus-zero.h"
+#include "signed-nan.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 ()
+    };
+  int n = sizeof x / sizeof *x;
+
+  for (int i = 0; i < n; i++)
+    for (int j = 0; j < n; j++)
+      ASSERT (!!TOTALORDER (&x[i], &x[j]) == (i <= j));
+  return 0;
+}
index 5fd27031c0403338ffabaaabf08422ed5f65e094..6d921dd1035cf155e8f3c95b6983d15560208504 100644 (file)
@@ -1,7 +1,31 @@
+/* Test totalorderf.
+   Copyright 2023 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
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <math.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (totalorderf, int, (const float *, const float *));
+
 #define TOTALORDER totalorderf
+#define TOTALORDER_TYPE 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_TYPE float
-#include "test-totalorder.c"
+#include "test-totalorder.h"
index c8f1fbd4b622ce831ba4f93988c82ebedde97242..89df547fc5afa3a793a49f3ffed591f6a5f2836d 100644 (file)
@@ -1,7 +1,31 @@
+/* Test totalorderl.
+   Copyright 2023 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
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <math.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (totalorderl, int, (const long double *, const long double *));
+
 #define TOTALORDER totalorderl
+#define TOTALORDER_TYPE 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_TYPE long double
-#include "test-totalorder.c"
+#include "test-totalorder.h"