summaryrefslogtreecommitdiff
path: root/tests/tacos.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2004-01-22 22:30:52 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2004-01-22 22:30:52 +0000
commit031deac645662aea8a72a5ed0c0bf148e609e681 (patch)
tree07c68b885a0c39a228ca4b0f7f901a9117f85a9f /tests/tacos.c
parent039c1c0135bac8353d17020543fe8b27f3b1937e (diff)
downloadmpfr-031deac645662aea8a72a5ed0c0bf148e609e681.tar.gz
added several hard-coded tests (and fixed bugs found)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2644 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tacos.c')
-rw-r--r--tests/tacos.c82
1 files changed, 81 insertions, 1 deletions
diff --git a/tests/tacos.c b/tests/tacos.c
index 62b372ba9..aaa3a1f1a 100644
--- a/tests/tacos.c
+++ b/tests/tacos.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_acos.
-Copyright 2001, 2002, 2003 Free Software Foundation.
+Copyright 2001, 2002, 2003, 2004 Free Software Foundation.
Contributed by Mathieu Dutour.
This file is part of the MPFR Library.
@@ -28,13 +28,47 @@ MA 02111-1307, USA. */
#define TEST_FUNCTION mpfr_acos
#include "tgeneric.c"
+static void
+special (void)
+{
+ mpfr_t x, y;
+
+ mpfr_init2 (x, 32);
+ mpfr_init2 (y, 32);
+
+ mpfr_set_str_binary (x, "0.10001000001001011000100001E-6");
+ mpfr_acos (y, x, GMP_RNDN);
+ mpfr_set_str_binary (x, "1.10001111111111110001110110001");
+ if (mpfr_cmp (x, y))
+ {
+ printf ("Error in mpfr_acos (1)\n");
+ exit (1);
+ }
+
+ mpfr_set_str_binary (x, "-0.01101011110111100111010011001011");
+ mpfr_acos (y, x, GMP_RNDZ);
+ mpfr_set_str_binary (x, "10.0000000101111000011101000101");
+ if (mpfr_cmp (x, y))
+ {
+ printf ("Error in mpfr_acos (2)\n");
+ mpfr_print_binary (y); printf ("\n");
+ exit (1);
+ }
+
+ mpfr_clear (y);
+ mpfr_clear (x);
+}
+
int
main (void)
{
mpfr_t x, y;
+ mp_rnd_t r;
tests_start_mpfr ();
+ special ();
+
mpfr_init (x);
mpfr_init (y);
@@ -54,6 +88,52 @@ main (void)
exit (1);
}
+ mpfr_set_si (x, -2, GMP_RNDN);
+ mpfr_acos (y, x, GMP_RNDN);
+ if (mpfr_nan_p(y) == 0)
+ {
+ printf ("Error: acos(-2) != NaN\n");
+ exit (1);
+ }
+
+ /* acos (1) = 0 */
+ mpfr_set_ui (x, 1, GMP_RNDN);
+ mpfr_acos (y, x, GMP_RNDN);
+ if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
+ {
+ printf ("Error: acos(1) != +0.0\n");
+ exit (1);
+ }
+
+ /* acos (0) = Pi/2 */
+ for (r = 0; r < 4; r++)
+ {
+ mpfr_set_ui (x, 0, GMP_RNDN); /* exact */
+ mpfr_acos (y, x, r);
+ mpfr_const_pi (x, r);
+ mpfr_div_2exp (x, x, 1, GMP_RNDN); /* exact */
+ if (mpfr_cmp (x, y))
+ {
+ printf ("Error: acos(0) != Pi/2 for rnd=%s\n",
+ mpfr_print_rnd_mode (r));
+ exit (1);
+ }
+ }
+
+ /* acos (-1) = Pi */
+ for (r = 0; r < 4; r++)
+ {
+ mpfr_set_si (x, -1, GMP_RNDN); /* exact */
+ mpfr_acos (y, x, r);
+ mpfr_const_pi (x, r);
+ if (mpfr_cmp (x, y))
+ {
+ printf ("Error: acos(1) != Pi for rnd=%s\n",
+ mpfr_print_rnd_mode (r));
+ exit (1);
+ }
+ }
+
test_generic (2, 100, 7);
mpfr_clear (x);