From: Bruno Haible Date: Sat, 14 Oct 2023 18:43:43 +0000 (+0200) Subject: totalorder* tests: Make it easier to debug failures. X-Git-Tag: v1.0~702 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=24bdd76dc1ed9a12791217da1e44389462092978;p=gnulib.git totalorder* tests: Make it easier to debug failures. * tests/test-totalorder.h: Include . (main): Print array indices of all failures. --- diff --git a/ChangeLog b/ChangeLog index db5cd18148..fadb0a9978 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2023-10-14 Bruno Haible + + totalorder* tests: Make it easier to debug failures. + * tests/test-totalorder.h: Include . + (main): Print array indices of all failures. + 2023-10-14 Bruno Haible totalorder* tests: Verify also the function signatures. diff --git a/tests/test-totalorder.h b/tests/test-totalorder.h index 2405e49edf..b242ff72f3 100644 --- a/tests/test-totalorder.h +++ b/tests/test-totalorder.h @@ -14,6 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include + #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; }