summaryrefslogtreecommitdiff
path: root/tests/tui_div.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2011-01-14 15:10:42 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2011-01-14 15:10:42 +0000
commit1528b00025aa619e6a65b320fd64a0d1ea124d41 (patch)
tree662a5cc59ce666df712c2561fee3dd3895001ee3 /tests/tui_div.c
parent0bfaaddeb0f8fbde659f0b4340e558243b2bb73e (diff)
downloadmpfr-1528b00025aa619e6a65b320fd64a0d1ea124d41.tar.gz
[src/ui_div.c] Set the division-by-zero flag.
[tests/tui_div.c] Updated and improved the test of special cases. Note: tpow_all currently fails since the support of the division-by-zero exception is not complete yet. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@7352 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tui_div.c')
-rw-r--r--tests/tui_div.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/tui_div.c b/tests/tui_div.c
index 6f3865972..077d7f767 100644
--- a/tests/tui_div.c
+++ b/tests/tui_div.c
@@ -102,7 +102,7 @@ check_inexact (void)
}
static void
-check_nan (void)
+check_special (void)
{
mpfr_t d, q;
@@ -112,47 +112,63 @@ check_nan (void)
/* 1/+inf == 0 */
MPFR_SET_INF (d);
MPFR_SET_POS (d);
+ mpfr_clear_flags ();
MPFR_ASSERTN (mpfr_ui_div (q, 1L, d, MPFR_RNDZ) == 0); /* exact */
MPFR_ASSERTN (mpfr_number_p (q));
MPFR_ASSERTN (mpfr_sgn (q) == 0);
+ MPFR_ASSERTN (__gmpfr_flags == 0);
/* 1/-inf == -0 */
MPFR_SET_INF (d);
MPFR_SET_NEG (d);
+ mpfr_clear_flags ();
MPFR_ASSERTN (mpfr_ui_div (q, 1L, d, MPFR_RNDZ) == 0); /* exact */
MPFR_ASSERTN (mpfr_number_p (q));
MPFR_ASSERTN (mpfr_sgn (q) == 0);
+ MPFR_ASSERTN (__gmpfr_flags == 0);
/* 1/nan == nan */
MPFR_SET_NAN (d);
+ mpfr_clear_flags ();
MPFR_ASSERTN (mpfr_ui_div (q, 1L, d, MPFR_RNDZ) == 0); /* exact */
MPFR_ASSERTN (mpfr_nan_p (q));
+ MPFR_ASSERTN (__gmpfr_flags == MPFR_FLAGS_NAN);
/* 0/0 == nan */
mpfr_set_ui (d, 0L, MPFR_RNDN);
+ mpfr_clear_flags ();
MPFR_ASSERTN (mpfr_ui_div (q, 0L, d, MPFR_RNDZ) == 0); /* exact */
MPFR_ASSERTN (mpfr_nan_p (q));
+ MPFR_ASSERTN (__gmpfr_flags == MPFR_FLAGS_NAN);
/* 1/+0 = +inf */
mpfr_set_ui (d, 0L, MPFR_RNDN);
+ mpfr_clear_flags ();
MPFR_ASSERTN (mpfr_ui_div (q, 1L, d, MPFR_RNDZ) == 0); /* exact */
MPFR_ASSERTN (mpfr_inf_p (q) && mpfr_sgn (q) > 0);
+ MPFR_ASSERTN (__gmpfr_flags == MPFR_FLAGS_DIVBY0);
/* 1/-0 = -inf */
mpfr_set_ui (d, 0L, MPFR_RNDN);
mpfr_neg (d, d, MPFR_RNDN);
+ mpfr_clear_flags ();
MPFR_ASSERTN (mpfr_ui_div (q, 1L, d, MPFR_RNDZ) == 0); /* exact */
MPFR_ASSERTN (mpfr_inf_p (q) && mpfr_sgn (q) < 0);
+ MPFR_ASSERTN (__gmpfr_flags == MPFR_FLAGS_DIVBY0);
/* 0/1 = +0 */
mpfr_set_ui (d, 1L, MPFR_RNDN);
+ mpfr_clear_flags ();
MPFR_ASSERTN (mpfr_ui_div (q, 0L, d, MPFR_RNDZ) == 0); /* exact */
MPFR_ASSERTN (mpfr_cmp_ui (q, 0) == 0 && MPFR_IS_POS (q));
+ MPFR_ASSERTN (__gmpfr_flags == 0);
/* 0/-1 = -0 */
mpfr_set_si (d, -1, MPFR_RNDN);
+ mpfr_clear_flags ();
MPFR_ASSERTN (mpfr_ui_div (q, 0L, d, MPFR_RNDZ) == 0); /* exact */
MPFR_ASSERTN (mpfr_cmp_ui (q, 0) == 0 && MPFR_IS_NEG (q));
+ MPFR_ASSERTN (__gmpfr_flags == 0);
mpfr_clear (d);
mpfr_clear (q);
@@ -169,7 +185,7 @@ main (int argc, char *argv[])
{
tests_start_mpfr ();
- check_nan ();
+ check_special ();
check_inexact ();
check(948002822, "1.22191250737771397120e+20", MPFR_RNDN,
"7.758352715731357946e-12");