summaryrefslogtreecommitdiff
path: root/tests/td_sub.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_sub.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_sub.c')
-rw-r--r--tests/td_sub.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/tests/td_sub.c b/tests/td_sub.c
index a584d294f..5a42df048 100644
--- a/tests/td_sub.c
+++ b/tests/td_sub.c
@@ -32,26 +32,36 @@ 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_sub (y, 1.0, x, GMP_RNDN);
+ mpfr_clear_flags ();
+ inexact = mpfr_d_sub (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 == -inf */
mpfr_set_inf (x, 1);
- mpfr_d_sub (y, 1.0, x, GMP_RNDN);
+ mpfr_clear_flags ();
+ inexact = mpfr_d_sub (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_NEG (y));
/* 1.0 - -inf == +inf */
mpfr_set_inf (x, -1);
- mpfr_d_sub (y, 1.0, x, GMP_RNDN);
+ mpfr_clear_flags ();
+ inexact = mpfr_d_sub (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);
@@ -63,7 +73,7 @@ check_nans (void)
#include "tgeneric.c"
int
-main (int argc, char *argv[])
+main (void)
{
mpfr_t x, y, z;
double d;