summaryrefslogtreecommitdiff
path: root/tests/tcos.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2007-06-20 10:55:52 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2007-06-20 10:55:52 +0000
commit7a2cc0a442b57d66960f3906c184615f54d6e09b (patch)
treebc6932a37543db9ad835ce1323fd31289b69088f /tests/tcos.c
parentb852d11e9220d71483ed9578eac8525e6e4ac5c1 (diff)
downloadmpfr-7a2cc0a442b57d66960f3906c184615f54d6e09b.tar.gz
tcos.c: added tests for x very small and emax = 0 (some of them
currently fail). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@4546 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tcos.c')
-rw-r--r--tests/tcos.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/tcos.c b/tests/tcos.c
index a71410fa2..796e73a58 100644
--- a/tests/tcos.c
+++ b/tests/tcos.c
@@ -156,6 +156,77 @@ special_overflow (void)
mpfr_clear (y);
}
+static void
+overflowed_cos0 (void)
+{
+ mpfr_t x, y;
+ int i, inex, rnd, err = 0;
+
+ mpfr_init2 (x, 8);
+ mpfr_init2 (y, 8);
+ mpfr_set_str (y, "0.11111111E0", 2, GMP_RNDN);
+ set_emax (0); /* 1 is not representable. */
+
+ for (i = -1; i <= 1; i++)
+ RND_LOOP (rnd)
+ {
+ mpfr_set_si_2exp (x, i, -512 * ABS (i), GMP_RNDN);
+ mpfr_clear_flags ();
+ inex = mpfr_cos (x, x, rnd);
+ if (!mpfr_overflow_p ())
+ {
+ printf ("Error in overflowed_cos0 (i = %d, rnd = %s):\n"
+ " The overflow flag is not set.\n",
+ i, mpfr_print_rnd_mode (rnd));
+ err = 1;
+ }
+ if (rnd == GMP_RNDZ || rnd == GMP_RNDD)
+ {
+ if (inex > 0)
+ {
+ printf ("Error in overflowed_cos0 (i = %d, rnd = %s):\n"
+ " The inexact value must be negative.\n",
+ i, mpfr_print_rnd_mode (rnd));
+ err = 1;
+ }
+ if (! mpfr_equal_p (x, y))
+ {
+ printf ("Error in overflowed_cos0 (i = %d, rnd = %s):\n"
+ " Got ", i, mpfr_print_rnd_mode (rnd));
+ /* Do not use mpfr_out_str in base 16 (bug in r4545). */
+ mpfr_print_binary (x);
+ printf (" instead of 0.11111111E0.\n");
+ err = 1;
+ }
+ }
+ else
+ {
+ if (inex < 0)
+ {
+ printf ("Error in overflowed_cos0 (i = %d, rnd = %s):\n"
+ " The inexact value must be positive.\n",
+ i, mpfr_print_rnd_mode (rnd));
+ err = 1;
+ }
+ if (! (mpfr_inf_p (x) && MPFR_SIGN (x) > 0))
+ {
+ printf ("Error in overflowed_cos0 (i = %d, rnd = %s):\n"
+ " Got ", i, mpfr_print_rnd_mode (rnd));
+ /* Do not use mpfr_out_str in base 16 (bug in r4545). */
+ mpfr_print_binary (x);
+ printf (" instead of +Inf.\n");
+ err = 1;
+ }
+ }
+ }
+
+ if (err)
+ exit (1);
+ set_emax (MPFR_EMAX_MAX);
+ mpfr_clear (x);
+ mpfr_clear (y);
+}
+
int
main (int argc, char *argv[])
{
@@ -255,6 +326,7 @@ main (int argc, char *argv[])
check53 ("1.00591265847407274059", "0.53531755997839769456", GMP_RNDN);
+ overflowed_cos0 ();
test_generic (2, 100, 15);
mpfr_clear (x);