summaryrefslogtreecommitdiff
path: root/tests/td_div.c
diff options
context:
space:
mode:
authorthevenyp <thevenyp@280ebfd0-de03-0410-8827-d642c229c3f4>2008-02-27 11:13:18 +0000
committerthevenyp <thevenyp@280ebfd0-de03-0410-8827-d642c229c3f4>2008-02-27 11:13:18 +0000
commit4eef2a6de0affc21d70c074f35d0a2e5d17b60d0 (patch)
tree086892836c664d0bab04fbcf58783ce7a744d4ba /tests/td_div.c
parenta53b5f84e27622e106289bd7f7369aa87bc4eb10 (diff)
downloadmpfr-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/td_div.c')
-rw-r--r--tests/td_div.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/tests/td_div.c b/tests/td_div.c
index d8103d783..9598134b5 100644
--- a/tests/td_div.c
+++ b/tests/td_div.c
@@ -32,32 +32,45 @@ static void
check_nans (void)
{
mpfr_t x, y;
+ int inexact;
mpfr_init2 (x, 123);
mpfr_init2 (y, 123);
/* 1.0 / nan is nan */
mpfr_set_nan (x);
- mpfr_d_div (y, 1.0, x, GMP_RNDN);
+ mpfr_clear_flags ();
+ inexact = mpfr_d_div (y, 1.0, x, GMP_RNDN);
+ MPFR_ASSERTN (inexact == 0);
+ MPFR_ASSERTN ((__gmpfr_flags ^ MPFR_FLAGS_NAN) == 0);
MPFR_ASSERTN (mpfr_nan_p (y));
/* 1.0 / +inf == +0 */
mpfr_set_inf (x, 1);
- mpfr_d_div (y, 1.0, x, GMP_RNDN);
+ mpfr_clear_flags ();
+ inexact = mpfr_d_div (y, 1.0, x, GMP_RNDN);
+ MPFR_ASSERTN (inexact == 0);
+ MPFR_ASSERTN (__gmpfr_flags == 0);
MPFR_ASSERTN (mpfr_zero_p (y));
- MPFR_ASSERTN (MPFR_SIGN (y) > 0);
+ MPFR_ASSERTN (MPFR_IS_POS (y));
/* 1.0 / -inf == -0 */
mpfr_set_inf (x, -1);
- mpfr_d_div (y, 1.0, x, GMP_RNDN);
+ mpfr_clear_flags ();
+ inexact = mpfr_d_div (y, 1.0, x, GMP_RNDN);
+ MPFR_ASSERTN (inexact == 0);
+ MPFR_ASSERTN (__gmpfr_flags == 0);
MPFR_ASSERTN (mpfr_zero_p (y));
- MPFR_ASSERTN (MPFR_SIGN (y) < 0);
+ MPFR_ASSERTN (MPFR_IS_NEG (y));
/* 1.0 / 0 == +inf */
mpfr_set_d (x, 0.0, GMP_RNDN);
- mpfr_d_div (y, 1.0, x, GMP_RNDN);
+ mpfr_clear_flags ();
+ inexact = mpfr_d_div (y, 1.0, x, 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));
mpfr_clear (x);
mpfr_clear (y);
@@ -69,7 +82,7 @@ check_nans (void)
#include "tgeneric.c"
int
-main (int argc, char *argv[])
+main (void)
{
mpfr_t x, y, z;
double d;