summaryrefslogtreecommitdiff
path: root/tests/terf.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2011-03-15 15:10:40 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2011-03-15 15:10:40 +0000
commitecfeeedd9ef1fb331c9d24eec90fa41b3a80c746 (patch)
treefdd15fe123d5e09056e8b11bf4e89bc8dcc724f3 /tests/terf.c
parent3a593cc9f636de8f6d698e0f60d38e145d041a97 (diff)
downloadmpfr-ecfeeedd9ef1fb331c9d24eec90fa41b3a80c746.tar.gz
[tests/terf.c] Added some tests of the flags (no failure in them,
thanks to the mpfr_cmp_si (x, -27282) in erfc.c, for 1b). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@7572 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/terf.c')
-rw-r--r--tests/terf.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/terf.c b/tests/terf.c
index ed6056175..7736ec866 100644
--- a/tests/terf.c
+++ b/tests/terf.c
@@ -414,18 +414,44 @@ static void
large_arg (void)
{
mpfr_t x, y;
+ unsigned int flags;
mpfr_init2 (x, 88);
mpfr_init2 (y, 98);
mpfr_set_si_2exp (x, -1, 173, MPFR_RNDN);
+ mpfr_clear_flags ();
mpfr_erfc (y, x, MPFR_RNDN);
+ flags = __gmpfr_flags;
if (mpfr_cmp_ui (y, 2) != 0)
{
printf ("mpfr_erfc failed for large x (1)\n");
exit (1);
}
+ if (flags != MPFR_FLAGS_INEXACT)
+ {
+ printf ("mpfr_erfc sets incorrect flags for large x (1)\n");
+ printf ("Expected %u, got %u\n",
+ (unsigned int) MPFR_FLAGS_INEXACT, flags);
+ exit (1);
+ }
+ mpfr_set_si_2exp (x, -1, mpfr_get_emax () - 3, MPFR_RNDN);
+ mpfr_clear_flags ();
+ mpfr_erfc (y, x, MPFR_RNDN);
+ flags = __gmpfr_flags;
+ if (mpfr_cmp_ui (y, 2) != 0)
+ {
+ printf ("mpfr_erfc failed for large x (1b)\n");
+ exit (1);
+ }
+ if (flags != MPFR_FLAGS_INEXACT)
+ {
+ printf ("mpfr_erfc sets incorrect flags for large x (1b)\n");
+ printf ("Expected %u, got %u\n",
+ (unsigned int) MPFR_FLAGS_INEXACT, flags);
+ exit (1);
+ }
mpfr_set_prec (x, 33);
mpfr_set_prec (y, 43);
@@ -462,7 +488,9 @@ large_arg (void)
mpfr_set_prec (x, 2);
mpfr_set_prec (y, 21);
mpfr_set_str_binary (x, "-1.0e3");
+ mpfr_clear_flags ();
mpfr_erfc (y, x, MPFR_RNDZ);
+ flags = __gmpfr_flags;
mpfr_set_prec (x, 21);
mpfr_set_str_binary (x, "1.11111111111111111111");
if (mpfr_cmp (x, y) != 0)
@@ -470,11 +498,20 @@ large_arg (void)
printf ("mpfr_erfc failed for large x (4)\n");
exit (1);
}
+ if (flags != MPFR_FLAGS_INEXACT)
+ {
+ printf ("mpfr_erfc sets incorrect flags for large x (4)\n");
+ printf ("Expected %u, got %u\n",
+ (unsigned int) MPFR_FLAGS_INEXACT, flags);
+ exit (1);
+ }
mpfr_set_prec (x, 2);
mpfr_set_prec (y, 31);
mpfr_set_str_binary (x, "-1.0e3");
+ mpfr_clear_flags ();
mpfr_erfc (y, x, MPFR_RNDZ);
+ flags = __gmpfr_flags;
mpfr_set_prec (x, 31);
mpfr_set_str_binary (x, "1.111111111111111111111111111111");
if (mpfr_cmp (x, y) != 0)
@@ -484,6 +521,13 @@ large_arg (void)
printf ("got "); mpfr_dump (y);
exit (1);
}
+ if (flags != MPFR_FLAGS_INEXACT)
+ {
+ printf ("mpfr_erfc sets incorrect flags for large x (5)\n");
+ printf ("Expected %u, got %u\n",
+ (unsigned int) MPFR_FLAGS_INEXACT, flags);
+ exit (1);
+ }
/* Reported by Christopher Creutzig on 2007-07-10. */
mpfr_set_prec (x, 53);