diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-03-12 17:17:56 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-03-12 17:17:56 +0000 |
commit | 5cf13de3cae6459fbac8354e935b4b1462498f2f (patch) | |
tree | da3513e1ab052df734faf9ec876760977ec39cc8 | |
parent | 3e46dd2e94b1ed9c65ac152fd70cb81ac1f28b6c (diff) | |
download | mpfr-5cf13de3cae6459fbac8354e935b4b1462498f2f.tar.gz |
[tests]
* tests.c, function bad_cases(): updated/added debug messages;
assume that the parameters are chosen in such a way that this
test always generates hard-to-round cases (including exact cases),
i.e. exit with an error if one does not get a bad case, otherwise
this can leave unexpected failures unnoticed (either due to a bug
in the MPFR library or due to poorly chosen parameters such as in
troot.c until now).
Note: ideally, this would require a proof, but it is better to get
(unlikely) spurious failures with a non-default GMP_CHECK_RANDOMIZE
value than missing important tests.
* troot.c, bad_cases() invocation:
- corrected the pos parameter: when n is even, it is useless to
generate a negative number as the function is not defined (the
inverse function generates a positive number, and the mismatch
now yields a failure due to the change in bad_cases); when n is
odd, generate as many negative numbers as positive ones.
- for n ≤ 5, reduce the psup parameter in order to also generate
inexact cases, instead of always exact cases.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13783 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | tests/tests.c | 13 | ||||
-rw-r--r-- | tests/troot.c | 12 |
2 files changed, 15 insertions, 10 deletions
diff --git a/tests/tests.c b/tests/tests.c index fd62540ca..579da8735 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -997,7 +997,7 @@ bad_cases (int (*fct)(FLIST), int (*inv)(FLIST), const char *name, int inex; if (dbg) - printf ("bad_cases: i = %d\n", i); + printf ("bad_cases: %s, i = %d\n", name, i); py = pymin + (randlimb () % (pymax - pymin + 1)); mpfr_set_prec (y, py); tests_default_random (y, pos, emin, emax, 0); @@ -1009,6 +1009,8 @@ bad_cases (int (*fct)(FLIST), int (*inv)(FLIST), const char *name, } px = py + psup; mpfr_set_prec (x, px); + if (dbg) + printf ("bad_cases: xprec =%4ld\n", (long) px); mpfr_clear_flags (); inv (x, y, MPFR_RNDN); if (mpfr_nanflag_p () || mpfr_overflow_p () || mpfr_underflow_p ()) @@ -1055,9 +1057,12 @@ bad_cases (int (*fct)(FLIST), int (*inv)(FLIST), const char *name, if (mpfr_nanflag_p () || mpfr_overflow_p () || mpfr_underflow_p () || ! mpfr_equal_p (z, y)) { - if (dbg) - printf ("bad_cases: inverse doesn't match\n"); - goto next_i; + printf ("bad_cases: inverse doesn't match for %s\ny = ", name); + mpfr_out_str (stdout, 16, 0, y, MPFR_RNDN); + printf ("\nz = "); + mpfr_out_str (stdout, 16, 0, z, MPFR_RNDN); + printf ("\n"); + exit (1); } } while (inex == 0); diff --git a/tests/troot.c b/tests/troot.c index 436b75c9c..c7d9075e8 100644 --- a/tests/troot.c +++ b/tests/troot.c @@ -590,12 +590,12 @@ main (int argc, char *argv[]) test_generic_ui (MPFR_PREC_MIN, 200, 30); - bad_cases (root2, pow2, "rootn[2]", 8, -256, 255, 4, 128, 800, 40); - bad_cases (root3, pow3, "rootn[3]", 8, -256, 255, 4, 128, 800, 40); - bad_cases (root4, pow4, "rootn[4]", 8, -256, 255, 4, 128, 800, 40); - bad_cases (root5, pow5, "rootn[5]", 8, -256, 255, 4, 128, 800, 40); - bad_cases (root17, pow17, "rootn[17]", 8, -256, 255, 4, 128, 800, 40); - bad_cases (root120, pow120, "rootn[120]", 8, -256, 255, 4, 128, 800, 40); + bad_cases (root2, pow2, "rootn[2]", 0, -256, 255, 4, 128, 80, 40); + bad_cases (root3, pow3, "rootn[3]", 256, -256, 255, 4, 128, 200, 40); + bad_cases (root4, pow4, "rootn[4]", 0, -256, 255, 4, 128, 320, 40); + bad_cases (root5, pow5, "rootn[5]", 256, -256, 255, 4, 128, 440, 40); + bad_cases (root17, pow17, "rootn[17]", 256, -256, 255, 4, 128, 800, 40); + bad_cases (root120, pow120, "rootn[120]", 0, -256, 255, 4, 128, 800, 40); tests_end_mpfr (); return 0; |