summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2016-06-03 15:02:05 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2016-06-03 15:02:05 +0000
commit82d9c355317c65cb29ea9f0dc5c20dc9ba7fac6f (patch)
tree830643bff34044183fb0e9381ad4e5a84540cd10 /tests
parenta21710f6c20e5b499b3d981efce8ca1941f2ca8f (diff)
downloadmpfr-82d9c355317c65cb29ea9f0dc5c20dc9ba7fac6f.tar.gz
[tests/tset_float128.c] Take into account failures in division by 0
and absence of signed zeros. Also fixed the code checking the sign of 0 (mpfr_sgn cannot be used for that since it returns 0 for ±0). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@10429 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r--tests/tset_float128.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/tests/tset_float128.c b/tests/tset_float128.c
index ad50bf820..a325ceecc 100644
--- a/tests/tset_float128.c
+++ b/tests/tset_float128.c
@@ -40,10 +40,11 @@ check_special (void)
mpfr_init2 (x, 113);
+#if !defined(MPFR_ERRDIVZERO)
/* check NaN */
f = 0.0 / 0.0;
mpfr_set_float128 (x, f, MPFR_RNDN);
- if (mpfr_nan_p (x) == 0)
+ if (! mpfr_nan_p (x))
{
printf ("Error in mpfr_set_float128(x, NaN)\n");
exit (1);
@@ -59,7 +60,7 @@ check_special (void)
/* check +Inf */
f = 1.0 / 0.0;
mpfr_set_float128 (x, f, MPFR_RNDN);
- if (mpfr_inf_p (x) == 0 || mpfr_sgn (x) < 0)
+ if (! mpfr_inf_p (x) || MPFR_IS_NEG (x))
{
printf ("Error in mpfr_set_float128(x, +Inf)\n");
exit (1);
@@ -74,7 +75,7 @@ check_special (void)
/* check -Inf */
f = -1.0 / 0.0;
mpfr_set_float128 (x, f, MPFR_RNDN);
- if (mpfr_inf_p (x) == 0 || mpfr_sgn (x) > 0)
+ if (! mpfr_inf_p (x) || MPFR_IS_POS (x))
{
printf ("Error in mpfr_set_float128(x, -Inf)\n");
exit (1);
@@ -85,36 +86,58 @@ check_special (void)
printf ("Error in mpfr_get_float128(-Inf)\n");
exit (1);
}
+#endif
/* check +0 */
f = 0.0;
mpfr_set_float128 (x, f, MPFR_RNDN);
- if (mpfr_zero_p (x) == 0 || mpfr_sgn (x) < 0)
+ if (! mpfr_zero_p (x) || MPFR_IS_NEG (x))
{
printf ("Error in mpfr_set_float128(x, +0)\n");
exit (1);
}
f = mpfr_get_float128 (x, MPFR_RNDN);
- if (f != 0.0 || 1 / f != 1 / 0.0)
+ if (f != 0.0) /* the sign is not checked */
+ {
+ printf ("Error in mpfr_get_float128(+0.0)\n");
+ exit (1);
+ }
+#if !defined(MPFR_ERRDIVZERO) && defined(HAVE_SIGNEDZ)
+ if (1 / f != 1 / 0.0) /* check the sign */
{
printf ("Error in mpfr_get_float128(+0.0)\n");
exit (1);
}
+#endif
/* check -0 */
f = -0.0;
mpfr_set_float128 (x, f, MPFR_RNDN);
- if (mpfr_zero_p (x) == 0 || mpfr_sgn (x) > 0)
+ if (! mpfr_zero_p (x))
+ {
+ printf ("Error in mpfr_set_float128(x, -0)\n");
+ exit (1);
+ }
+#if defined(HAVE_SIGNEDZ)
+ if (MPFR_IS_POS (x))
{
printf ("Error in mpfr_set_float128(x, -0)\n");
exit (1);
}
+#endif
f = mpfr_get_float128 (x, MPFR_RNDN);
- if (f != -0.0 || 1 / f != 1 / -0.0)
+ if (f != -0.0) /* the sign is not checked */
+ {
+ printf ("Error in mpfr_get_float128(-0.0)\n");
+ exit (1);
+ }
+#if !defined(MPFR_ERRDIVZERO) && defined(HAVE_SIGNEDZ)
+ if (1 / f != 1 / -0.0) /* check the sign */
{
printf ("Error in mpfr_get_float128(-0.0)\n");
exit (1);
}
+#endif
mpfr_clear (x);
}