summaryrefslogtreecommitdiff
path: root/tests/tadd.c
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/tadd.c
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/tadd.c')
-rw-r--r--tests/tadd.c37
1 files changed, 37 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 ();