summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-06-10 09:21:02 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-06-10 09:21:02 +0000
commit58abf2c44dd0d3c9adafc6175bae697a278fed35 (patch)
treec2aaa18b711f9523db1ea63666a0c788583f70dc /tests
parent05c69ce9d22e5d17e8aa1c11152dc1bf8425b98c (diff)
downloadmpfr-58abf2c44dd0d3c9adafc6175bae697a278fed35.tar.gz
[tests/tgeneric.c] Fixed overflow/underflow tests introduced in r9539:
the tests were done in all rounding modes, but the code was incorrect if the exponent of the result depended on the rounding mode. So, the tests are now done only in the rounding mode previously selected. This should be sufficient to detect bugs. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@9544 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r--tests/tgeneric.c152
1 files changed, 70 insertions, 82 deletions
diff --git a/tests/tgeneric.c b/tests/tgeneric.c
index a2d325280..f28014487 100644
--- a/tests/tgeneric.c
+++ b/tests/tgeneric.c
@@ -315,109 +315,97 @@ test_generic (mpfr_prec_t p0, mpfr_prec_t p1, unsigned int nmax)
e = MPFR_GET_EXP (y);
if (test_of && e - 1 >= emax)
{
- int r;
- RND_LOOP (r)
- {
- mpfr_flags_t ex_flags;
- mpfr_rnd_t rr = (mpfr_rnd_t) r;
+ mpfr_flags_t ex_flags;
- mpfr_set_emax (e - 1);
- mpfr_clear_flags ();
+ mpfr_set_emax (e - 1);
+ mpfr_clear_flags ();
#if defined(TWO_ARGS)
- inexact = TEST_FUNCTION (w, x, u, rr);
+ inexact = TEST_FUNCTION (w, x, u, rnd);
#elif defined(DOUBLE_ARG1)
- inexact = TEST_FUNCTION (w, d, x, rr);
+ inexact = TEST_FUNCTION (w, d, x, rnd);
#elif defined(DOUBLE_ARG2)
- inexact = TEST_FUNCTION (w, x, d, rr);
+ inexact = TEST_FUNCTION (w, x, d, rnd);
#elif defined(ULONG_ARG1)
- inexact = TEST_FUNCTION (w, i, x, rr);
+ inexact = TEST_FUNCTION (w, i, x, rnd);
#elif defined(ULONG_ARG2)
- inexact = TEST_FUNCTION (w, x, i, rr);
+ inexact = TEST_FUNCTION (w, x, i, rnd);
#else
- inexact = TEST_FUNCTION (w, x, rr);
-#endif
- flags = __gmpfr_flags;
- mpfr_set_emax (oemax);
- ex_flags = MPFR_FLAGS_OVERFLOW | MPFR_FLAGS_INEXACT;
- if (flags != ex_flags)
- {
- printf ("tgeneric: error for "
- MAKE_STR(TEST_FUNCTION)
- ", reduced exponent range [%"
- MPFR_EXP_FSPEC "d,%" MPFR_EXP_FSPEC
- "d] (overflow test) on:\n",
- (mpfr_eexp_t) oemin, (mpfr_eexp_t) e - 1);
- printf ("x = ");
- mpfr_dump (x);
+ inexact = TEST_FUNCTION (w, x, rnd);
+#endif
+ flags = __gmpfr_flags;
+ mpfr_set_emax (oemax);
+ ex_flags = MPFR_FLAGS_OVERFLOW | MPFR_FLAGS_INEXACT;
+ if (flags != ex_flags)
+ {
+ printf ("tgeneric: error for " MAKE_STR(TEST_FUNCTION)
+ ", reduced exponent range [%"
+ MPFR_EXP_FSPEC "d,%" MPFR_EXP_FSPEC
+ "d] (overflow test) on:\n",
+ (mpfr_eexp_t) oemin, (mpfr_eexp_t) e - 1);
+ printf ("x = ");
+ mpfr_dump (x);
#if defined(TWO_ARGS_ALL)
- printf ("u = ");
- mpfr_dump (u);
-#endif
- printf ("yprec = %u, rnd_mode = %s\n",
- (unsigned int) yprec,
- mpfr_print_rnd_mode (rr));
- printf ("Expected flags =");
- flags_out (ex_flags);
- printf (" got flags =");
- flags_out (flags);
- printf ("inex = %d, w = ", inexact);
- mpfr_dump (w);
- exit (1);
- }
+ printf ("u = ");
+ mpfr_dump (u);
+#endif
+ printf ("yprec = %u, rnd_mode = %s\n",
+ (unsigned int) yprec,
+ mpfr_print_rnd_mode (rnd));
+ printf ("Expected flags =");
+ flags_out (ex_flags);
+ printf (" got flags =");
+ flags_out (flags);
+ printf ("inex = %d, w = ", inexact);
+ mpfr_dump (w);
+ exit (1);
}
test_of = 0; /* Overflow is tested only once. */
}
if (test_uf && e + 1 <= emin)
{
- int r;
- RND_LOOP (r)
- {
- mpfr_flags_t ex_flags;
- mpfr_rnd_t rr = (mpfr_rnd_t) r;
+ mpfr_flags_t ex_flags;
- mpfr_set_emin (e + 1);
- mpfr_clear_flags ();
+ mpfr_set_emin (e + 1);
+ mpfr_clear_flags ();
#if defined(TWO_ARGS)
- inexact = TEST_FUNCTION (w, x, u, rr);
+ inexact = TEST_FUNCTION (w, x, u, rnd);
#elif defined(DOUBLE_ARG1)
- inexact = TEST_FUNCTION (w, d, x, rr);
+ inexact = TEST_FUNCTION (w, d, x, rnd);
#elif defined(DOUBLE_ARG2)
- inexact = TEST_FUNCTION (w, x, d, rr);
+ inexact = TEST_FUNCTION (w, x, d, rnd);
#elif defined(ULONG_ARG1)
- inexact = TEST_FUNCTION (w, i, x, rr);
+ inexact = TEST_FUNCTION (w, i, x, rnd);
#elif defined(ULONG_ARG2)
- inexact = TEST_FUNCTION (w, x, i, rr);
+ inexact = TEST_FUNCTION (w, x, i, rnd);
#else
- inexact = TEST_FUNCTION (w, x, rr);
-#endif
- flags = __gmpfr_flags;
- mpfr_set_emin (oemin);
- ex_flags = MPFR_FLAGS_UNDERFLOW | MPFR_FLAGS_INEXACT;
- if (flags != ex_flags)
- {
- printf ("tgeneric: error for "
- MAKE_STR(TEST_FUNCTION)
- ", reduced exponent range [%"
- MPFR_EXP_FSPEC "d,%" MPFR_EXP_FSPEC
- "d] (underflow test) on:\n",
- (mpfr_eexp_t) e + 1, (mpfr_eexp_t) oemax);
- printf ("x = ");
- mpfr_dump (x);
+ inexact = TEST_FUNCTION (w, x, rnd);
+#endif
+ flags = __gmpfr_flags;
+ mpfr_set_emin (oemin);
+ ex_flags = MPFR_FLAGS_UNDERFLOW | MPFR_FLAGS_INEXACT;
+ if (flags != ex_flags)
+ {
+ printf ("tgeneric: error for " MAKE_STR(TEST_FUNCTION)
+ ", reduced exponent range [%"
+ MPFR_EXP_FSPEC "d,%" MPFR_EXP_FSPEC
+ "d] (underflow test) on:\n",
+ (mpfr_eexp_t) e + 1, (mpfr_eexp_t) oemax);
+ printf ("x = ");
+ mpfr_dump (x);
#if defined(TWO_ARGS_ALL)
- printf ("u = ");
- mpfr_dump (u);
-#endif
- printf ("yprec = %u, rnd_mode = %s\n",
- (unsigned int) yprec,
- mpfr_print_rnd_mode (rr));
- printf ("Expected flags =");
- flags_out (ex_flags);
- printf (" got flags =");
- flags_out (flags);
- printf ("inex = %d, w = ", inexact);
- mpfr_dump (w);
- exit (1);
- }
+ printf ("u = ");
+ mpfr_dump (u);
+#endif
+ printf ("yprec = %u, rnd_mode = %s\n",
+ (unsigned int) yprec,
+ mpfr_print_rnd_mode (rnd));
+ printf ("Expected flags =");
+ flags_out (ex_flags);
+ printf (" got flags =");
+ flags_out (flags);
+ printf ("inex = %d, w = ", inexact);
+ mpfr_dump (w);
+ exit (1);
}
test_uf = 0; /* Underflow is tested only once. */
}