summaryrefslogtreecommitdiff
path: root/tests/tgmpop.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2010-08-19 12:08:41 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2010-08-19 12:08:41 +0000
commite008967ccf0a09bb1f35d58142f675bde4daebcd (patch)
tree390738e3b2f891b866a1fb9f8fc258586ecbc0de /tests/tgmpop.c
parent788d16fb8c034c49d7ddc5533a578beb4a6ef9c1 (diff)
downloadmpfr-e008967ccf0a09bb1f35d58142f675bde4daebcd.tar.gz
[src/gmp_op.c] Fixed the Inf +/- Inf cases for mpfr_add_q / mpfr_sub_q.
[tests/tgmpop.c] Added Inf +/- Inf tests. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@7101 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tgmpop.c')
-rw-r--r--tests/tgmpop.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/tgmpop.c b/tests/tgmpop.c
index ce0f9d440..06d0e844e 100644
--- a/tests/tgmpop.c
+++ b/tests/tgmpop.c
@@ -107,6 +107,28 @@ special (void)
CHECK_FOR ("0.5- -1/0", mpfr_inf_p (y) && MPFR_SIGN (y) > 0 && res == 0);
res = mpfr_div_q (y, x, z, MPFR_RNDN);
CHECK_FOR ("0.5 / (-1/0)", mpfr_zero_p (y) && MPFR_SIGN (y) < 0 && res == 0);
+ mpq_set_ui (z, 1, 0);
+ mpfr_set_inf (x, 1);
+ res = mpfr_add_q (y, x, z, MPFR_RNDN);
+ CHECK_FOR ("+Inf + +Inf", mpfr_inf_p (y) && MPFR_SIGN (y) > 0 && res == 0);
+ res = mpfr_sub_q (y, x, z, MPFR_RNDN);
+ CHECK_FOR ("+Inf - +Inf", MPFR_IS_NAN (y) && res == 0);
+ mpfr_set_inf (x, -1);
+ res = mpfr_add_q (y, x, z, MPFR_RNDN);
+ CHECK_FOR ("-Inf + +Inf", MPFR_IS_NAN (y) && res == 0);
+ res = mpfr_sub_q (y, x, z, MPFR_RNDN);
+ CHECK_FOR ("-Inf - +Inf", mpfr_inf_p (y) && MPFR_SIGN (y) < 0 && res == 0);
+ mpq_set_si (z, -1, 0);
+ mpfr_set_inf (x, 1);
+ res = mpfr_add_q (y, x, z, MPFR_RNDN);
+ CHECK_FOR ("+Inf + -Inf", MPFR_IS_NAN (y) && res == 0);
+ res = mpfr_sub_q (y, x, z, MPFR_RNDN);
+ CHECK_FOR ("+Inf - -Inf", mpfr_inf_p (y) && MPFR_SIGN (y) > 0 && res == 0);
+ mpfr_set_inf (x, -1);
+ res = mpfr_add_q (y, x, z, MPFR_RNDN);
+ CHECK_FOR ("-Inf + -Inf", mpfr_inf_p (y) && MPFR_SIGN (y) < 0 && res == 0);
+ res = mpfr_sub_q (y, x, z, MPFR_RNDN);
+ CHECK_FOR ("-Inf - -Inf", MPFR_IS_NAN (y) && res == 0);
/* 0 */
mpq_set_ui (z, 0, 1);