summaryrefslogtreecommitdiff
path: root/tests/tsin.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2002-10-18 14:53:53 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2002-10-18 14:53:53 +0000
commit4253cfb674e2c944845306602aa24421ae81a86b (patch)
tree2cfc02d4efa44f142b9a142f44dfb4e1a0f1ccfd /tests/tsin.c
parentf4c7b1d8fd86fbc41f0eb0a7e08e9ed82fbd9097 (diff)
downloadmpfr-4253cfb674e2c944845306602aa24421ae81a86b.tar.gz
Added test showing bug in sign detection.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2066 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tsin.c')
-rw-r--r--tests/tsin.c48
1 files changed, 45 insertions, 3 deletions
diff --git a/tests/tsin.c b/tests/tsin.c
index d0df6b9c8..5e04aee8a 100644
--- a/tests/tsin.c
+++ b/tests/tsin.c
@@ -27,9 +27,7 @@ MA 02111-1307, USA. */
#include "mpfr-impl.h"
#include "mpfr-test.h"
-void check53 _PROTO ((double, double, mp_rnd_t));
-
-void
+static void
check53 (double x, double sin_x, mp_rnd_t rnd_mode)
{
mpfr_t xx, s;
@@ -50,6 +48,49 @@ check53 (double x, double sin_x, mp_rnd_t rnd_mode)
mpfr_clear (s);
}
+static void
+test_sign (void)
+{
+ mpfr_t pid, piu, x, y;
+ int p, k;
+
+ mpfr_init2 (pid, 4096);
+ mpfr_const_pi (pid, GMP_RNDD);
+ mpfr_init2 (piu, 4096);
+ mpfr_const_pi (piu, GMP_RNDU);
+ mpfr_init (x);
+ mpfr_init2 (y, 2);
+ for (p = 8; p <= 128; p++)
+ for (k = 2; k <= 22; k += 2)
+ {
+ mpfr_set_prec (x, p);
+ mpfr_mul_ui (x, pid, k, GMP_RNDD);
+ mpfr_sin (y, x, GMP_RNDN);
+ if (MPFR_SIGN(y) > 0)
+ {
+ fprintf (stderr,
+ "Error in test_sign for sin(%dpi-epsilon), prec = %d"
+ " for argument.\nResult should have been negative.\n",
+ k, p);
+ exit (1);
+ }
+ mpfr_mul_ui (x, piu, k, GMP_RNDU);
+ mpfr_sin (y, x, GMP_RNDN);
+ if (MPFR_SIGN(y) < 0)
+ {
+ fprintf (stderr,
+ "Error in test_sign for sin(%dpi+epsilon), prec = %d"
+ " for argument.\nResult should have been positive.\n",
+ k, p);
+ exit (1);
+ }
+ }
+ mpfr_clear (pid);
+ mpfr_clear (piu);
+ mpfr_clear (x);
+ mpfr_clear (y);
+}
+
#define TEST_FUNCTION mpfr_sin
#include "tgeneric.c"
@@ -101,6 +142,7 @@ main (int argc, char *argv[])
mpfr_clear (x);
test_generic (2, 100, 80);
+ test_sign ();
tests_end_mpfr ();
return 0;