summaryrefslogtreecommitdiff
path: root/tests/tgmpop.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2011-09-19 09:31:42 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2011-09-19 09:31:42 +0000
commit0f6dae9fda5ab4f73eb2d99dfa5074280f33d3d2 (patch)
tree01b2cc91f78cfbcf1852fde851e08a64a62edea8 /tests/tgmpop.c
parent75be286b095c25d13437f40984dfcf67ccee015a (diff)
downloadmpfr-0f6dae9fda5ab4f73eb2d99dfa5074280f33d3d2.tar.gz
[tests/tgmpop.c] check for erange flag in mpfr_cmp_[f,q,z]
(https://sympa.inria.fr/sympa/arc/mpfr/2011-09/msg00013.html) git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@7860 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tgmpop.c')
-rw-r--r--tests/tgmpop.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/tests/tgmpop.c b/tests/tgmpop.c
index a7a5f6120..71926f0c8 100644
--- a/tests/tgmpop.c
+++ b/tests/tgmpop.c
@@ -1,5 +1,5 @@
-/* Test file for mpfr_add_[q,z], mpfr_sub_[q,z], mpfr_div_[q,z], mpfr_mul_[q,z]
- and mpfr_cmp_[q,z]
+/* Test file for mpfr_add_[q,z], mpfr_sub_[q,z], mpfr_div_[q,z],
+ mpfr_mul_[q,z], mpfr_cmp_[f,q,z]
Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
Contributed by the Arenaire and Caramel projects, INRIA.
@@ -232,6 +232,20 @@ test_cmp_z (mpfr_prec_t pmin, mpfr_prec_t pmax, int nmax)
mpfr_init (x);
mpfr_init2 (z, MPFR_PREC_MIN);
mpz_init (y);
+
+ /* check the erange flag when x is NaN */
+ mpfr_set_nan (x);
+ mpz_set_ui (y, 17);
+ mpfr_clear_erangeflag ();
+ res1 = mpfr_cmp_z (x, y);
+ if (res1 != 0 || mpfr_erangeflag_p () == 0)
+ {
+ printf ("Error for mpfr_cmp_z (NaN, 17)\n");
+ printf ("Return value: expected 0, got %d\n", res1);
+ printf ("Erange flag: expected set, got %d\n", mpfr_erangeflag_p ());
+ exit (1);
+ }
+
for(p=pmin ; p < pmax ; p++)
{
mpfr_set_prec (x, p);
@@ -270,6 +284,20 @@ test_cmp_q (mpfr_prec_t pmin, mpfr_prec_t pmax, int nmax)
mpfr_init (x);
mpfr_init2 (z, MPFR_PREC_MIN);
mpq_init (y);
+
+ /* check the erange flag when x is NaN */
+ mpfr_set_nan (x);
+ mpq_set_ui (y, 17, 1);
+ mpfr_clear_erangeflag ();
+ res1 = mpfr_cmp_q (x, y);
+ if (res1 != 0 || mpfr_erangeflag_p () == 0)
+ {
+ printf ("Error for mpfr_cmp_q (NaN, 17)\n");
+ printf ("Return value: expected 0, got %d\n", res1);
+ printf ("Erange flag: expected set, got %d\n", mpfr_erangeflag_p ());
+ exit (1);
+ }
+
for(p=pmin ; p < pmax ; p++)
{
mpfr_set_prec (x, p);
@@ -308,6 +336,20 @@ test_cmp_f (mpfr_prec_t pmin, mpfr_prec_t pmax, int nmax)
mpfr_init (x);
mpfr_init2 (z, pmax+GMP_NUMB_BITS);
mpf_init2 (y, MPFR_PREC_MIN);
+
+ /* check the erange flag when x is NaN */
+ mpfr_set_nan (x);
+ mpf_set_ui (y, 17);
+ mpfr_clear_erangeflag ();
+ res1 = mpfr_cmp_f (x, y);
+ if (res1 != 0 || mpfr_erangeflag_p () == 0)
+ {
+ printf ("Error for mpfr_cmp_f (NaN, 17)\n");
+ printf ("Return value: expected 0, got %d\n", res1);
+ printf ("Erange flag: expected set, got %d\n", mpfr_erangeflag_p ());
+ exit (1);
+ }
+
for(p=pmin ; p < pmax ; p+=3)
{
mpfr_set_prec (x, p);