]> Savannah Git Hosting - gnulib.git/commitdiff
totalorder* tests: Make it easier to debug failures.
authorBruno Haible <bruno@clisp.org>
Sat, 14 Oct 2023 18:43:43 +0000 (20:43 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 14 Oct 2023 18:43:43 +0000 (20:43 +0200)
* tests/test-totalorder.h: Include <stdio.h>.
(main): Print array indices of all failures.

ChangeLog
tests/test-totalorder.h

index db5cd181482ed158dd1b5f8092d47c23e0333773..fadb0a9978a3634916af4e8a5597d37dc8846cf9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-10-14  Bruno Haible  <bruno@clisp.org>
+
+       totalorder* tests: Make it easier to debug failures.
+       * tests/test-totalorder.h: Include <stdio.h>.
+       (main): Print array indices of all failures.
+
 2023-10-14  Bruno Haible  <bruno@clisp.org>
 
        totalorder* tests: Verify also the function signatures.
index 2405e49edfd9c5ee573f89815d1b4a273f041121..b242ff72f3d952e7b568061cf41ee37c26484e3f 100644 (file)
@@ -14,6 +14,8 @@
    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 <stdio.h>
+
 #include "infinity.h"
 #include "macros.h"
 #include "minus-zero.h"
@@ -28,10 +30,16 @@ main ()
       TOTALORDER_MINUS_ZERO, 0,
       1e-5, 1, 1e37, TOTALORDER_INF (), TOTALORDER_POSITIVE_NAN ()
     };
-  int n = sizeof x / sizeof *x;
+  int n = SIZEOF (x);
+  int result = 0;
 
   for (int i = 0; i < n; i++)
     for (int j = 0; j < n; j++)
-      ASSERT (!!TOTALORDER (&x[i], &x[j]) == (i <= j));
-  return 0;
+      if (!(!!TOTALORDER (&x[i], &x[j]) == (i <= j)))
+        {
+          fprintf (stderr, "Failed: i=%d j=%d\n", i, j);
+          result = 1;
+        }
+
+  return result;
 }