summaryrefslogtreecommitdiff
path: root/tests/tmul_2exp.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-06-26 00:23:19 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-06-26 00:23:19 +0000
commit58dc80888e30e28e8c2e01f8a1010476a19385fe (patch)
treeaeb26578163dcb96fa0cb65712bcd6198d7b1e00 /tests/tmul_2exp.c
parent9eb37e118223a84ea08ae597a26da645565d5ba7 (diff)
downloadmpfr-58dc80888e30e28e8c2e01f8a1010476a19385fe.tar.gz
[tests/tmul_2exp.c] Added tests where mpfr_div_2ui overflows, which
is currently not handled. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@9593 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tmul_2exp.c')
-rw-r--r--tests/tmul_2exp.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/tmul_2exp.c b/tests/tmul_2exp.c
index c8b7f6807..abbc46915 100644
--- a/tests/tmul_2exp.c
+++ b/tests/tmul_2exp.c
@@ -239,6 +239,36 @@ large0 (void)
large (MPFR_EMAX_MAX);
}
+/* Cases where mpfr_div_2ui overflows. */
+static void
+div_overflow (mpfr_exp_t e)
+{
+ mpfr_exp_t emax;
+ mpfr_t x, y;
+ int neg, r;
+
+ emax = mpfr_get_emax ();
+ set_emax (e);
+
+ mpfr_init2 (x, 8);
+ mpfr_init2 (y, 6);
+
+ mpfr_set_inf (x, 1);
+ mpfr_nextbelow (x);
+
+ for (neg = 0; neg <= 1; neg++)
+ {
+ RND_LOOP (r)
+ {
+ mpfr_div_2ui (y, x, 0, (mpfr_rnd_t) r);
+ }
+ mpfr_neg (x, x, MPFR_RNDN);
+ }
+
+ mpfr_clears (x, y, (mpfr_ptr) 0);
+ set_emax (emax);
+}
+
int
main (int argc, char *argv[])
{
@@ -331,6 +361,11 @@ main (int argc, char *argv[])
underflow0 ();
large0 ();
+ if (mpfr_get_emax () != MPFR_EMAX_MAX)
+ div_overflow (mpfr_get_emax ());
+ div_overflow (MPFR_EMAX_MAX);
+ div_overflow (-1);
+
tests_end_mpfr ();
return 0;
}