From 5cf13de3cae6459fbac8354e935b4b1462498f2f Mon Sep 17 00:00:00 2001 From: vlefevre Date: Thu, 12 Mar 2020 17:17:56 +0000 Subject: =?UTF-8?q?[tests]=20=20=20*=20tests.c,=20function=20bad=5Fcases()?= =?UTF-8?q?:=20updated/added=20debug=20messages;=20=20=20=20=20assume=20th?= =?UTF-8?q?at=20the=20parameters=20are=20chosen=20in=20such=20a=20way=20th?= =?UTF-8?q?at=20this=20=20=20=20=20test=20always=20generates=20hard-to-rou?= =?UTF-8?q?nd=20cases=20(including=20exact=20cases),=20=20=20=20=20i.e.=20?= =?UTF-8?q?exit=20with=20an=20error=20if=20one=20does=20not=20get=20a=20ba?= =?UTF-8?q?d=20case,=20otherwise=20=20=20=20=20this=20can=20leave=20unexpe?= =?UTF-8?q?cted=20failures=20unnoticed=20(either=20due=20to=20a=20bug=20?= =?UTF-8?q?=20=20=20=20in=20the=20MPFR=20library=20or=20due=20to=20poorly?= =?UTF-8?q?=20chosen=20parameters=20such=20as=20in=20=20=20=20=20troot.c?= =?UTF-8?q?=20until=20now).=20=20=20=20=20Note:=20ideally,=20this=20would?= =?UTF-8?q?=20require=20a=20proof,=20but=20it=20is=20better=20to=20get=20?= =?UTF-8?q?=20=20=20=20(unlikely)=20spurious=20failures=20with=20a=20non-d?= =?UTF-8?q?efault=20GMP=5FCHECK=5FRANDOMIZE=20=20=20=20=20value=20than=20m?= =?UTF-8?q?issing=20important=20tests.=20=20=20*=20troot.c,=20bad=5Fcases(?= =?UTF-8?q?)=20invocation:=20=20=20=20=20=20=20-=20corrected=20the=20pos?= =?UTF-8?q?=20parameter:=20when=20n=20is=20even,=20it=20is=20useless=20to?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20generate=20a=20negative=20number=20a?= =?UTF-8?q?s=20the=20function=20is=20not=20defined=20(the=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20inverse=20function=20generates=20a=20positive=20num?= =?UTF-8?q?ber,=20and=20the=20mismatch=20=20=20=20=20=20=20=20=20now=20yie?= =?UTF-8?q?lds=20a=20failure=20due=20to=20the=20change=20in=20bad=5Fcases)?= =?UTF-8?q?;=20when=20n=20is=20=20=20=20=20=20=20=20=20odd,=20generate=20a?= =?UTF-8?q?s=20many=20negative=20numbers=20as=20positive=20ones.=20=20=20?= =?UTF-8?q?=20=20=20=20-=20for=20n=20=E2=89=A4=205,=20reduce=20the=20psup?= =?UTF-8?q?=20parameter=20in=20order=20to=20also=20generate=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20inexact=20cases,=20instead=20of=20always=20exact=20?= =?UTF-8?q?cases.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13783 280ebfd0-de03-0410-8827-d642c229c3f4 --- tests/tests.c | 13 +++++++++---- 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; -- cgit v1.2.1