From 9d0f0787d0af80f6989c04846020c0756f4e2f58 Mon Sep 17 00:00:00 2001 From: vlefevre Date: Sat, 27 Jan 2018 03:52:35 +0000 Subject: [tests/tdiv.c] mpfr_div bug bug20180126: also test negative values. (merged changeset r12137 from the trunk) git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/4.0@12138 280ebfd0-de03-0410-8827-d642c229c3f4 --- tests/tdiv.c | 51 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/tests/tdiv.c b/tests/tdiv.c index 092970131..4bd6748c3 100644 --- a/tests/tdiv.c +++ b/tests/tdiv.c @@ -1532,7 +1532,7 @@ static void bug20180126 (void) { mpfr_t a, b1, b2, c1, c2; - int pa, i, j, pc, r, inex1, inex2; + int pa, i, j, pc, sa, sb, r, inex1, inex2; for (pa = 100; pa < 800; pa += 11) for (i = 1; i <= 4; i++) @@ -1557,30 +1557,43 @@ bug20180126 (void) { mpfr_inits2 (pc, c1, c2, (mpfr_ptr) 0); - RND_LOOP_NO_RNDF (r) + for (sa = 0; sa < 2; sa++) { - MPFR_ASSERTN (mpfr_equal_p (b1, b2)); - inex1 = mpfr_div (c1, a, b1, (mpfr_rnd_t) r); - inex2 = mpfr_div (c2, a, b2, (mpfr_rnd_t) r); - - if (! mpfr_equal_p (c1, c2) || ! SAME_SIGN (inex1, inex2)) + for (sb = 0; sb < 2; sb++) { - printf ("Error in bug20180126 for " - "pa=%d pb=%d pc=%d %s\n", pa, pb, pc, - mpfr_print_rnd_mode ((mpfr_rnd_t) r)); - printf ("inex1 = %d, c1 = ", inex1); - mpfr_dump (c1); - printf ("inex2 = %d, c2 = ", inex2); - mpfr_dump (c2); - exit (1); - } - } + RND_LOOP_NO_RNDF (r) + { + MPFR_ASSERTN (mpfr_equal_p (b1, b2)); + inex1 = mpfr_div (c1, a, b1, (mpfr_rnd_t) r); + inex2 = mpfr_div (c2, a, b2, (mpfr_rnd_t) r); + + if (! mpfr_equal_p (c1, c2) || + ! SAME_SIGN (inex1, inex2)) + { + printf ("Error in bug20180126 for " + "pa=%d pb=%d pc=%d sa=%d sb=%d %s\n", + pa, pb, pc, sa, sb, + mpfr_print_rnd_mode ((mpfr_rnd_t) r)); + printf ("inex1 = %d, c1 = ", inex1); + mpfr_dump (c1); + printf ("inex2 = %d, c2 = ", inex2); + mpfr_dump (c2); + exit (1); + } + } + + mpfr_neg (b1, b1, MPFR_RNDN); + mpfr_neg (b2, b2, MPFR_RNDN); + } /* sb */ + + mpfr_neg (a, a, MPFR_RNDN); + } /* sa */ mpfr_clears (c1, c2, (mpfr_ptr) 0); - } + } /* pc */ mpfr_clears (a, b1, b2, (mpfr_ptr) 0); - } + } /* j */ } int -- cgit v1.2.1