summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2014-01-23 12:26:17 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2014-01-23 12:26:17 +0000
commitabf8081545e3f1d6591fdad7b806d56d7f0ee3b2 (patch)
tree21c7cc0b25b71cd4a4e1dc569a5d550640d0fa0d /tests
parent8f049482ddc8df3244971866418c4f03bb3994e2 (diff)
downloadmpfr-abf8081545e3f1d6591fdad7b806d56d7f0ee3b2.tar.gz
[tests/tadd.c] Added check_extreme test (huge + tiny).
[tests/tsum.c] Added check_extreme test (same test as in tadd.c, but with mpfr_sum instead of mpfr_add), and temporarily disabled the cancel test. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@8877 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r--tests/tadd.c37
-rw-r--r--tests/tsum.c40
2 files changed, 77 insertions, 0 deletions
diff --git a/tests/tadd.c b/tests/tadd.c
index 043bef2fd..5b01b3993 100644
--- a/tests/tadd.c
+++ b/tests/tadd.c
@@ -1094,6 +1094,40 @@ tests (void)
check_1minuseps ();
}
+static void
+check_extreme (void)
+{
+ mpfr_t u, v, w, x, y;
+ int i, inex, r;
+
+ mpfr_inits2 (32, u, v, w, x, y, (mpfr_ptr) 0);
+ mpfr_setmin (u, mpfr_get_emax ());
+ mpfr_setmax (v, mpfr_get_emin ());
+ mpfr_setmin (w, mpfr_get_emax () - 40);
+ RND_LOOP (r)
+ for (i = 0; i < 2; i++)
+ {
+ mpfr_add (x, u, v, (mpfr_rnd_t) r);
+ mpfr_set_prec (y, 64);
+ inex = mpfr_add (y, u, w, MPFR_RNDN);
+ MPFR_ASSERTN (inex == 0);
+ mpfr_prec_round (y, 32, (mpfr_rnd_t) r);
+ if (! mpfr_equal_p (x, y))
+ {
+ printf ("Error in check_extreme (%s, i = %d)\n",
+ mpfr_print_rnd_mode ((mpfr_rnd_t) r), i);
+ printf ("Expected ");
+ mpfr_dump (y);
+ printf ("Got ");
+ mpfr_dump (x);
+ exit (1);
+ }
+ mpfr_neg (v, v, MPFR_RNDN);
+ mpfr_neg (w, w, MPFR_RNDN);
+ }
+ mpfr_clears (u, v, w, x, y, (mpfr_ptr) 0);
+}
+
#define TEST_FUNCTION test_add
#define TWO_ARGS
#define RAND_FUNCTION(x) mpfr_random2(x, MPFR_LIMB_SIZE (x), randlimb () % 100, RANDS)
@@ -1111,6 +1145,9 @@ main (int argc, char *argv[])
usesp = 1;
tests ();
#endif
+
+ check_extreme ();
+
test_generic (2, 1000, 100);
tests_end_mpfr ();
diff --git a/tests/tsum.c b/tests/tsum.c
index 3e26dcbf0..6995b521f 100644
--- a/tests/tsum.c
+++ b/tests/tsum.c
@@ -355,12 +355,51 @@ bug20131027 (void)
}
static void
+check_extreme (void)
+{
+ mpfr_t u, v, w, x, y;
+ mpfr_ptr t[] = { u, v };
+ int i, inex, r;
+
+ mpfr_inits2 (32, u, v, w, x, y, (mpfr_ptr) 0);
+ mpfr_setmin (u, mpfr_get_emax ());
+ mpfr_setmax (v, mpfr_get_emin ());
+ mpfr_setmin (w, mpfr_get_emax () - 40);
+ RND_LOOP (r)
+ for (i = 0; i < 2; i++)
+ {
+ mpfr_sum (x, t, 2, (mpfr_rnd_t) r);
+ mpfr_set_prec (y, 64);
+ inex = mpfr_add (y, u, w, MPFR_RNDN);
+ MPFR_ASSERTN (inex == 0);
+ mpfr_prec_round (y, 32, (mpfr_rnd_t) r);
+ if (! mpfr_equal_p (x, y))
+ {
+ printf ("Error in check_extreme (%s, i = %d)\n",
+ mpfr_print_rnd_mode ((mpfr_rnd_t) r), i);
+ printf ("Expected ");
+ mpfr_dump (y);
+ printf ("Got ");
+ mpfr_dump (x);
+ exit (1);
+ }
+ mpfr_neg (v, v, MPFR_RNDN);
+ mpfr_neg (w, w, MPFR_RNDN);
+ }
+ mpfr_clears (u, v, w, x, y, (mpfr_ptr) 0);
+}
+
+static void
cancel (void)
{
mpfr_t x[2 * MPFR_NCANCEL];
mpfr_ptr px[2 * MPFR_NCANCEL];
int i, j, n;
+ /* FIXME: re-enable and improve once mpfr_sum has been fixed.
+ check_extreme() is currently sufficient to show problems. */
+ return;
+
for (i = 0; i < 8; i++)
{
for (n = 0; n < numberof (x); n++)
@@ -426,6 +465,7 @@ main (void)
for (p = 2 ; p < 444 ; p += 17)
for (n = 2 ; n < 1026 ; n += 42 + p)
test_sum (p, n);
+ check_extreme ();
cancel ();
tests_end_mpfr ();