diff options
author | thevenyp <thevenyp@280ebfd0-de03-0410-8827-d642c229c3f4> | 2008-02-27 11:13:18 +0000 |
---|---|---|
committer | thevenyp <thevenyp@280ebfd0-de03-0410-8827-d642c229c3f4> | 2008-02-27 11:13:18 +0000 |
commit | 4eef2a6de0affc21d70c074f35d0a2e5d17b60d0 (patch) | |
tree | 086892836c664d0bab04fbcf58783ce7a744d4ba /tests/tadd_d.c | |
parent | a53b5f84e27622e106289bd7f7369aa87bc4eb10 (diff) | |
download | mpfr-4eef2a6de0affc21d70c074f35d0a2e5d17b60d0.tar.gz |
add_d.c, div_d.c, sub_d.c, d_div.c, d_sub.c: restore flags in case of exception. This fixes the bug revealed by MPFR_SUSPICIOUS_OVERFLOW
tests/tadd_d.c, tests/tsub_d.c, tests/tdiv_d.c, tests/tmul_d.c, tests/td_sub.c, tests/td_div.c, test/tmul_d.c: add checks for exception flags and ternary value
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@5322 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tadd_d.c')
-rw-r--r-- | tests/tadd_d.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/tests/tadd_d.c b/tests/tadd_d.c index 09b8f0075..88305dcd1 100644 --- a/tests/tadd_d.c +++ b/tests/tadd_d.c @@ -93,26 +93,36 @@ static void check_nans (void) { mpfr_t x, y; + int inexact; mpfr_init2 (x, 123); mpfr_init2 (y, 123); /* nan + 1.0 is nan */ mpfr_set_nan (x); - mpfr_add_d (y, x, 1.0, GMP_RNDN); + mpfr_clear_flags (); + inexact = mpfr_add_d (y, x, 1.0, GMP_RNDN); + MPFR_ASSERTN (inexact == 0); + MPFR_ASSERTN ((__gmpfr_flags ^ MPFR_FLAGS_NAN) == 0); MPFR_ASSERTN (mpfr_nan_p (y)); /* +inf + 1.0 == +inf */ mpfr_set_inf (x, 1); - mpfr_add_d (y, x, 1.0, GMP_RNDN); + mpfr_clear_flags (); + inexact = mpfr_add_d (y, x, 1.0, GMP_RNDN); + MPFR_ASSERTN (inexact == 0); + MPFR_ASSERTN (__gmpfr_flags == 0); MPFR_ASSERTN (mpfr_inf_p (y)); - MPFR_ASSERTN (mpfr_sgn (y) > 0); + MPFR_ASSERTN (MPFR_IS_POS (y)); /* -inf + 1.0 == -inf */ mpfr_set_inf (x, -1); - mpfr_add_d (y, x, 1.0, GMP_RNDN); + mpfr_clear_flags (); + inexact = mpfr_add_d (y, x, 1.0, GMP_RNDN); + MPFR_ASSERTN (inexact == 0); + MPFR_ASSERTN (__gmpfr_flags == 0); MPFR_ASSERTN (mpfr_inf_p (y)); - MPFR_ASSERTN (mpfr_sgn (y) < 0); + MPFR_ASSERTN (MPFR_IS_NEG (y)); mpfr_clear (x); mpfr_clear (y); @@ -124,7 +134,7 @@ check_nans (void) #include "tgeneric.c" int -main (int argc, char *argv[]) +main (void) { tests_start_mpfr (); |