* 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* 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.
Files:
tests/test-totalorder.c
+tests/test-totalorder.h
tests/minus-zero.h
tests/infinity.h
+tests/signature.h
tests/macros.h
Depends-on:
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:
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:
#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"
--- /dev/null
+/* 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;
+}
+/* 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"
+/* 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"