summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2017-09-15 11:51:18 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2017-09-15 11:51:18 +0000
commitf96e3b4fa7037fa401aa1b648443df5efd48e5af (patch)
tree625e8e18642a689141732ee5da77c27407b8d954
parent6c017f6f1cbbf9843a5412249bf345a61d235de6 (diff)
downloadmpfr-f96e3b4fa7037fa401aa1b648443df5efd48e5af.tar.gz
[tests] Solve issues with the incorrect use of mpfr_sgn, and make sure
that this cannot happen again without being detected: on zero, +1 or -1 was sometimes expected to check the sign of zero, but mpfr_sgn actually returned 0, so that the check always succeeded whatever the sign of the null result. * mpfr-test.h: define a new mpfr_sgn macro that fails when used on NaN or zero (whose sign is not +1 or -1), except when MPFR_TESTS_TSGN is defined. * tacos.c, tasin.c, tasinh.c, tatanh.c, tcbrt.c, tdim.c, terf.c, texp.c, texp10.c, texp2.c, texpm1.c, tset.c, tset_str.c: replaced the incorrect use of mpfr_sgn; some other related improvements. Note: in tset.c, a "mpfr_sgn (x) < 0" test had to be replaced by "MPFR_IS_POS (x)" since we really want to test whether the sign is positive (not negative). * tdiv.c, tmul.c, tui_div.c: simplified some tests, in particular to avoid a failure with the new mpfr_sgn macro for the tests; here, the use of mpfr_sgn was correct, but one could do simpler. * tgmpop.c: replaced "mpfr_sgn (z)" by "(mpfr_sgn) (z)" to avoid the new mpfr_sgn macro (here, we really want the mathematical sign). * tsgn.c: define MPFR_TESTS_TSGN as the goal of this program is to test mpfr_sgn itself (both the function and the macro in mpfr.h). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@11755 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--tests/mpfr-test.h19
-rw-r--r--tests/tacos.c2
-rw-r--r--tests/tasin.c4
-rw-r--r--tests/tasinh.c4
-rw-r--r--tests/tatanh.c4
-rw-r--r--tests/tcbrt.c4
-rw-r--r--tests/tdim.c4
-rw-r--r--tests/tdiv.c12
-rw-r--r--tests/terf.c6
-rw-r--r--tests/texp.c4
-rw-r--r--tests/texp10.c2
-rw-r--r--tests/texp2.c2
-rw-r--r--tests/texpm1.c4
-rw-r--r--tests/tgmpop.c6
-rw-r--r--tests/tmul.c2
-rw-r--r--tests/tset.c16
-rw-r--r--tests/tset_str.c7
-rw-r--r--tests/tsgn.c1
-rw-r--r--tests/tui_div.c12
19 files changed, 65 insertions, 50 deletions
diff --git a/tests/mpfr-test.h b/tests/mpfr-test.h
index f4d452f39..7bcc15f37 100644
--- a/tests/mpfr-test.h
+++ b/tests/mpfr-test.h
@@ -85,6 +85,25 @@ extern "C" {
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define ABS(x) (((x)>0) ? (x) : -(x))
+/* In the tests, mpfr_sgn was sometimes used incorrectly, for instance:
+ *
+ * if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
+ *
+ * to check that y is +0. This does not make sense since on 0, mpfr_sgn
+ * yields 0, so that -0 would not be detected as an error. To make sure
+ * that mpfr_sgn is not used incorrectly, we choose to fail when this
+ * macro is used on a datum whose mathematical sign is not +1 or -1.
+ * This feature is disabled when MPFR_TESTS_TSGN is defined, typically
+ * in tsgn (to test mpfr_sgn itself).
+ */
+#ifndef MPFR_TESTS_TSGN
+# undef mpfr_sgn
+# define mpfr_sgn(x) \
+ (MPFR_ASSERTN (! MPFR_IS_NAN (x)), \
+ MPFR_ASSERTN (! MPFR_IS_ZERO (x)), \
+ MPFR_SIGN (x))
+#endif
+
#define FLIST mpfr_ptr, mpfr_srcptr, mpfr_rnd_t
int test_version (void);
diff --git a/tests/tacos.c b/tests/tacos.c
index 1ade3113e..cb803c299 100644
--- a/tests/tacos.c
+++ b/tests/tacos.c
@@ -136,7 +136,7 @@ main (void)
/* acos (1) = 0 */
mpfr_set_ui (x, 1, MPFR_RNDN);
mpfr_acos (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_NEG (y))
{
printf ("Error: acos(1) != +0.0\n");
exit (1);
diff --git a/tests/tasin.c b/tests/tasin.c
index efaf0bf87..b949279ac 100644
--- a/tests/tasin.c
+++ b/tests/tasin.c
@@ -79,14 +79,14 @@ special (void)
/* asin(+/-0) = +/-0 */
mpfr_set_ui (x, 0, MPFR_RNDN);
mpfr_asin (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_NEG (y))
{
printf ("Error: mpfr_asin (+0) <> +0\n");
exit (1);
}
mpfr_neg (x, x, MPFR_RNDN);
mpfr_asin (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) > 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_POS (y))
{
printf ("Error: mpfr_asin (-0) <> -0\n");
exit (1);
diff --git a/tests/tasinh.c b/tests/tasinh.c
index b7b89142c..8a5a47468 100644
--- a/tests/tasinh.c
+++ b/tests/tasinh.c
@@ -53,14 +53,14 @@ special (void)
/* asinh(+0) = +0, asinh(-0) = -0 */
mpfr_set_ui (x, 0, MPFR_RNDN);
mpfr_asinh (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_NEG (y))
{
printf ("Error: mpfr_asinh(+0) <> +0\n");
exit (1);
}
mpfr_neg (x, x, MPFR_RNDN);
mpfr_asinh (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) > 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_POS (y))
{
printf ("Error: mpfr_asinh(-0) <> -0\n");
exit (1);
diff --git a/tests/tatanh.c b/tests/tatanh.c
index 5a034c75e..38c7803ef 100644
--- a/tests/tatanh.c
+++ b/tests/tatanh.c
@@ -75,14 +75,14 @@ special (void)
/* atanh(+0) = +0, atanh(-0) = -0 */
mpfr_set_ui (x, 0, MPFR_RNDN);
mpfr_atanh (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_NEG (y))
{
printf ("Error: mpfr_atanh(+0) <> +0\n");
exit (1);
}
mpfr_neg (x, x, MPFR_RNDN);
mpfr_atanh (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) > 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_POS (y))
{
printf ("Error: mpfr_atanh(-0) <> -0\n");
exit (1);
diff --git a/tests/tcbrt.c b/tests/tcbrt.c
index 65a0f1db9..b8380a0fc 100644
--- a/tests/tcbrt.c
+++ b/tests/tcbrt.c
@@ -60,14 +60,14 @@ special (void)
/* cbrt(+/-0) = +/-0 */
mpfr_set_ui (x, 0, MPFR_RNDN);
mpfr_cbrt (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_NEG (y))
{
printf ("Error: cbrt(+0) <> +0\n");
exit (1);
}
mpfr_neg (x, x, MPFR_RNDN);
mpfr_cbrt (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) > 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_POS (y))
{
printf ("Error: cbrt(-0) <> -0\n");
exit (1);
diff --git a/tests/tdim.c b/tests/tdim.c
index 06b12e1a8..01c44e97d 100644
--- a/tests/tdim.c
+++ b/tests/tdim.c
@@ -64,7 +64,7 @@ main (void)
mpfr_set_inf (x, -1);
mpfr_set_ui (y, 0, MPFR_RNDN);
mpfr_dim (z, x, y, MPFR_RNDN);
- if (mpfr_cmp_ui (z, 0) || mpfr_sgn (z) < 0)
+ if (MPFR_NOTZERO (z) || MPFR_IS_NEG (z))
{
printf ("Error in mpfr_dim (-Inf, 0)\n");
exit (1);
@@ -74,7 +74,7 @@ main (void)
mpfr_set_inf (x, 1);
mpfr_set_inf (y, 1);
mpfr_dim (z, x, y, MPFR_RNDN);
- if (mpfr_cmp_ui (z, 0) || mpfr_sgn (z) < 0)
+ if (MPFR_NOTZERO (z) || MPFR_IS_NEG (z))
{
printf ("Error in mpfr_dim (+Inf, +Inf)\n");
exit (1);
diff --git a/tests/tdiv.c b/tests/tdiv.c
index fba3b9a82..077347e66 100644
--- a/tests/tdiv.c
+++ b/tests/tdiv.c
@@ -786,8 +786,7 @@ check_special (void)
MPFR_SET_POS (d);
mpfr_clear_flags ();
MPFR_ASSERTN (test_div (q, a, d, MPFR_RNDZ) == 0); /* exact */
- MPFR_ASSERTN (mpfr_number_p (q));
- MPFR_ASSERTN (mpfr_sgn (q) == 0);
+ MPFR_ASSERTN (MPFR_IS_ZERO (q));
MPFR_ASSERTN (MPFR_IS_POS (q));
MPFR_ASSERTN (__gmpfr_flags == 0);
@@ -797,8 +796,7 @@ check_special (void)
MPFR_SET_NEG (d);
mpfr_clear_flags ();
MPFR_ASSERTN (test_div (q, a, d, MPFR_RNDZ) == 0); /* exact */
- MPFR_ASSERTN (mpfr_number_p (q));
- MPFR_ASSERTN (mpfr_sgn (q) == 0);
+ MPFR_ASSERTN (MPFR_IS_ZERO (q));
MPFR_ASSERTN (MPFR_IS_NEG (q));
MPFR_ASSERTN (__gmpfr_flags == 0);
@@ -808,8 +806,7 @@ check_special (void)
MPFR_SET_POS (d);
mpfr_clear_flags ();
MPFR_ASSERTN (test_div (q, a, d, MPFR_RNDZ) == 0); /* exact */
- MPFR_ASSERTN (mpfr_number_p (q));
- MPFR_ASSERTN (mpfr_sgn (q) == 0);
+ MPFR_ASSERTN (MPFR_IS_ZERO (q));
MPFR_ASSERTN (MPFR_IS_NEG (q));
MPFR_ASSERTN (__gmpfr_flags == 0);
@@ -819,8 +816,7 @@ check_special (void)
MPFR_SET_NEG (d);
mpfr_clear_flags ();
MPFR_ASSERTN (test_div (q, a, d, MPFR_RNDZ) == 0); /* exact */
- MPFR_ASSERTN (mpfr_number_p (q));
- MPFR_ASSERTN (mpfr_sgn (q) == 0);
+ MPFR_ASSERTN (MPFR_IS_ZERO (q));
MPFR_ASSERTN (MPFR_IS_POS (q));
MPFR_ASSERTN (__gmpfr_flags == 0);
diff --git a/tests/terf.c b/tests/terf.c
index f3fda2e49..b23da0f0e 100644
--- a/tests/terf.c
+++ b/tests/terf.c
@@ -76,7 +76,7 @@ special_erf (void)
/* erf(+0) = +0 */
mpfr_set_ui (x, 0, MPFR_RNDN);
mpfr_erf (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_NEG (y))
{
printf ("mpfr_erf failed for x=+0\n");
exit (1);
@@ -85,7 +85,7 @@ special_erf (void)
/* erf(-0) = -0 */
mpfr_neg (x, x, MPFR_RNDN);
mpfr_erf (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) > 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_POS (y))
{
printf ("mpfr_erf failed for x=-0\n");
exit (1);
@@ -477,7 +477,7 @@ large_arg (void)
mpfr_set_prec (y, 85);
mpfr_set_str_binary (x, "0.111110111111010011101011001100001010011110101010011111010010111101010001011E15");
mpfr_erfc (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_NEG (y))
{
printf ("mpfr_erfc failed for large x (3b)\n");
exit (1);
diff --git a/tests/texp.c b/tests/texp.c
index 29db9794a..1d002bd2e 100644
--- a/tests/texp.c
+++ b/tests/texp.c
@@ -263,7 +263,7 @@ check_special (void)
/* check exp(-inf) = +0 */
mpfr_set_inf (x, -1);
test_exp (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_NEG (y))
{
printf ("Error for exp(-inf)\n");
exit (1);
@@ -354,7 +354,7 @@ check_special (void)
set_emin (-10);
mpfr_set_si (x, -9, MPFR_RNDN);
test_exp (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_NEG (y))
{
printf ("Error for exp(-9) for emin=-10\n");
printf ("Expected +0\n");
diff --git a/tests/texp10.c b/tests/texp10.c
index 5b73c23c1..5147210c1 100644
--- a/tests/texp10.c
+++ b/tests/texp10.c
@@ -233,7 +233,7 @@ main (int argc, char *argv[])
set_emin (-11);
mpfr_set_si (x, -4, MPFR_RNDN);
mpfr_exp10 (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_NEG (y))
{
printf ("Error for emin = -11, x = -4, RNDN\n");
printf ("Expected +0\n");
diff --git a/tests/texp2.c b/tests/texp2.c
index 2e81da246..d568d88e0 100644
--- a/tests/texp2.c
+++ b/tests/texp2.c
@@ -288,7 +288,7 @@ main (int argc, char *argv[])
set_emin (-10);
mpfr_set_si (x, -12, MPFR_RNDN);
mpfr_exp2 (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_NEG (y))
{
printf ("Error for x=emin-2, RNDN\n");
printf ("Expected +0\n");
diff --git a/tests/texpm1.c b/tests/texpm1.c
index 8b7ddfe55..5bc6a3315 100644
--- a/tests/texpm1.c
+++ b/tests/texpm1.c
@@ -85,7 +85,7 @@ special (void)
mpfr_set_ui (x, 0, MPFR_RNDN);
test_expm1 (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_NEG (y))
{
printf ("Error for expm1(+0)\n");
exit (1);
@@ -93,7 +93,7 @@ special (void)
mpfr_neg (x, x, MPFR_RNDN);
test_expm1 (y, x, MPFR_RNDN);
- if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) > 0)
+ if (MPFR_NOTZERO (y) || MPFR_IS_POS (y))
{
printf ("Error for expm1(-0)\n");
exit (1);
diff --git a/tests/tgmpop.c b/tests/tgmpop.c
index d7100201d..6be2043c4 100644
--- a/tests/tgmpop.c
+++ b/tests/tgmpop.c
@@ -276,7 +276,7 @@ test_cmp_z (mpfr_prec_t pmin, mpfr_prec_t pmax, int nmax)
if (!MPFR_IS_SINGULAR (x))
{
mpfr_sub_z (z, x, y, MPFR_RNDN);
- res1 = mpfr_sgn (z);
+ res1 = (mpfr_sgn) (z);
res2 = mpfr_cmp_z (x, y);
if (res1 != res2)
{
@@ -328,7 +328,7 @@ test_cmp_q (mpfr_prec_t pmin, mpfr_prec_t pmax, int nmax)
if (!MPFR_IS_SINGULAR (x))
{
mpfr_sub_q (z, x, y, MPFR_RNDN);
- res1 = mpfr_sgn (z);
+ res1 = (mpfr_sgn) (z);
res2 = mpfr_cmp_q (x, y);
if (res1 != res2)
{
@@ -382,7 +382,7 @@ test_cmp_f (mpfr_prec_t pmin, mpfr_prec_t pmax, int nmax)
{
mpfr_set_f (z, y, MPFR_RNDN);
mpfr_sub (z, x, z, MPFR_RNDN);
- res1 = mpfr_sgn (z);
+ res1 = (mpfr_sgn) (z);
res2 = mpfr_cmp_f (x, y);
if (res1 != res2)
{
diff --git a/tests/tmul.c b/tests/tmul.c
index 55f18b2a4..4ed13a9df 100644
--- a/tests/tmul.c
+++ b/tests/tmul.c
@@ -351,7 +351,7 @@ check_min(void)
mpfr_set_str1(yy, "0.9375");
mpfr_mul_2si(yy, yy, MPFR_EMIN_DEFAULT - MPFR_EMIN_DEFAULT/2 - 1, MPFR_RNDN);
test_mul(zz, xx, yy, MPFR_RNDD);
- if (mpfr_sgn(zz) != 0)
+ if (MPFR_NOTZERO (zz))
{
printf("check_min failed: got ");
mpfr_out_str(stdout, 2, 0, zz, MPFR_RNDZ);
diff --git a/tests/tset.c b/tests/tset.c
index 0777a9d51..402d62a54 100644
--- a/tests/tset.c
+++ b/tests/tset.c
@@ -71,7 +71,7 @@ check_special (void)
"ERROR: mpfr_set failed to set variable to +infinity.\n");
inexact = mpfr_set_ui (y, 0, MPFR_RNDN);
- PRINT_ERROR_IF (!mpfr_zero_p (y) || mpfr_sgn (y) < 0 || inexact != 0,
+ PRINT_ERROR_IF (MPFR_NOTZERO (y) || MPFR_IS_NEG (y) || inexact != 0,
"ERROR: mpfr_set_ui failed to set variable to +0.\n");
mpfr_set_inf (x, -1);
@@ -85,26 +85,26 @@ check_special (void)
"ERROR: mpfr_set failed to set variable to -infinity.\n");
mpfr_set_zero (x, 1);
- PRINT_ERROR_IF (!mpfr_zero_p (x) || mpfr_sgn (x) < 0,
+ PRINT_ERROR_IF (MPFR_NOTZERO (x) || MPFR_IS_NEG (x),
"ERROR: mpfr_set_zero failed to set variable to +0 [1].\n");
mpfr_set_zero (x, INT_MAX);
- PRINT_ERROR_IF (!mpfr_zero_p (x) || mpfr_sgn (x) < 0,
+ PRINT_ERROR_IF (MPFR_NOTZERO (x) || MPFR_IS_NEG (x),
"ERROR: mpfr_set_zero failed to set variable to +0 [2].\n");
mpfr_set_zero (x, 0);
- PRINT_ERROR_IF (!mpfr_zero_p (x) || mpfr_sgn (x) < 0,
+ PRINT_ERROR_IF (MPFR_NOTZERO (x) || MPFR_IS_NEG (x),
"ERROR: mpfr_set_zero failed to set variable to +0 [3].\n");
inexact = mpfr_set (y, x, MPFR_RNDN);
- PRINT_ERROR_IF (!mpfr_zero_p (y) || mpfr_sgn (y) < 0 || inexact != 0,
+ PRINT_ERROR_IF (MPFR_NOTZERO (y) || MPFR_IS_NEG (y) || inexact != 0,
"ERROR: mpfr_set failed to set variable to +0.\n");
mpfr_set_zero (x, -1);
- PRINT_ERROR_IF (!mpfr_zero_p (x) || mpfr_sgn (x) > 0,
+ PRINT_ERROR_IF (MPFR_NOTZERO (x) || MPFR_IS_POS (x),
"ERROR: mpfr_set_zero failed to set variable to -0 [1].\n");
mpfr_set_zero (x, INT_MIN);
- PRINT_ERROR_IF (!mpfr_zero_p (x) || mpfr_sgn (x) < 0,
+ PRINT_ERROR_IF (MPFR_NOTZERO (x) || MPFR_IS_POS (x),
"ERROR: mpfr_set_zero failed to set variable to -0 [2].\n");
inexact = mpfr_set (y, x, MPFR_RNDN);
- PRINT_ERROR_IF (!mpfr_zero_p (y) || mpfr_sgn (y) > 0 || inexact != 0,
+ PRINT_ERROR_IF (MPFR_NOTZERO (y) || MPFR_IS_POS (y) || inexact != 0,
"ERROR: mpfr_set failed to set variable to -0.\n");
mpfr_set_nan (x);
diff --git a/tests/tset_str.c b/tests/tset_str.c
index e6852d562..6ddd209cb 100644
--- a/tests/tset_str.c
+++ b/tests/tset_str.c
@@ -787,16 +787,17 @@ main (int argc, char *argv[])
/* end of tests added by Alain Delplanque */
- /* check that flags are correctly cleared */
mpfr_set_nan (x);
mpfr_set_str (x, "+0.0", 10, MPFR_RNDN);
- if (!mpfr_number_p(x) || mpfr_cmp_ui (x, 0) != 0 || mpfr_sgn (x) < 0)
+ if (MPFR_NOTZERO (x) || MPFR_IS_NEG (x))
{
printf ("x <- +0.0 failed after x=NaN\n");
exit (1);
}
+
+ mpfr_set_nan (x);
mpfr_set_str (x, "-0.0", 10, MPFR_RNDN);
- if (!mpfr_number_p(x) || mpfr_cmp_ui (x, 0) != 0 || mpfr_sgn (x) > 0)
+ if (MPFR_NOTZERO (x) || MPFR_IS_POS (x))
{
printf ("x <- -0.0 failed after x=NaN\n");
exit (1);
diff --git a/tests/tsgn.c b/tests/tsgn.c
index 67c2f27fe..521d1f2f3 100644
--- a/tests/tsgn.c
+++ b/tests/tsgn.c
@@ -20,6 +20,7 @@ along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see
http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
+#define MPFR_TESTS_TSGN 1
#include "mpfr-test.h"
static void
diff --git a/tests/tui_div.c b/tests/tui_div.c
index 5a013a6e9..82d2d22d7 100644
--- a/tests/tui_div.c
+++ b/tests/tui_div.c
@@ -104,13 +104,12 @@ check_special (void)
mpfr_init2 (d, 100L);
mpfr_init2 (q, 100L);
- /* 1/+inf == 0 */
+ /* 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 (MPFR_IS_ZERO (q) && MPFR_IS_POS (q));
MPFR_ASSERTN (__gmpfr_flags == 0);
/* 1/-inf == -0 */
@@ -118,8 +117,7 @@ check_special (void)
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 (MPFR_IS_ZERO (q) && MPFR_IS_NEG (q));
MPFR_ASSERTN (__gmpfr_flags == 0);
/* 1/nan == nan */
@@ -155,14 +153,14 @@ check_special (void)
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 (MPFR_IS_ZERO (q) && 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 (MPFR_IS_ZERO (q) && MPFR_IS_NEG (q));
MPFR_ASSERTN (__gmpfr_flags == 0);
mpfr_clear (d);