From e008967ccf0a09bb1f35d58142f675bde4daebcd Mon Sep 17 00:00:00 2001 From: vlefevre Date: Thu, 19 Aug 2010 12:08:41 +0000 Subject: [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 --- tests/tgmpop.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/tgmpop.c') 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); -- cgit v1.2.1