summaryrefslogtreecommitdiff
path: root/tests/trint.c
diff options
context:
space:
mode:
authordemengeo <demengeo@280ebfd0-de03-0410-8827-d642c229c3f4>2011-03-04 17:57:53 +0000
committerdemengeo <demengeo@280ebfd0-de03-0410-8827-d642c229c3f4>2011-03-04 17:57:53 +0000
commit88844ed6832d26c7abb283edfd01fffccecc5ee0 (patch)
tree6289243919f05cea692a99d6552b9f4cc5f87f61 /tests/trint.c
parentc9a0153126133f6799d5ac50a7f9f0268ff7672a (diff)
downloadmpfr-88844ed6832d26c7abb283edfd01fffccecc5ee0.tar.gz
Previous extented coverage test in trint.c now self generate tests in and compare values
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@7525 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/trint.c')
-rw-r--r--tests/trint.c49
1 files changed, 30 insertions, 19 deletions
diff --git a/tests/trint.c b/tests/trint.c
index 6f05b8f60..a1ee0cb94 100644
--- a/tests/trint.c
+++ b/tests/trint.c
@@ -229,19 +229,32 @@ coverage_03032011 (void)
{
mpfr_t in, out, cmp;
int status;
+ int precIn;
+ char strData[(GMP_NUMB_BITS * 4)+256];
- mpfr_init2 (in, GMP_NUMB_BITS * 3);
+ precIn = GMP_NUMB_BITS * 4;
+
+ mpfr_init2 (in, precIn);
mpfr_init2 (out, GMP_NUMB_BITS);
mpfr_init2 (cmp, GMP_NUMB_BITS);
- mpfr_set_str_binary (in, "0.1E194");
- mpfr_set_str_binary (in,
- "0.1000000000000000000000000000000000000000000000000000000000000000"
- "0000000000000000000000000000000000000000000000000000000000000000"
- "0000000000000000000000000000000000000000000000000000000000000001E194");
+ /* cmp = "0.1EprecIn+2" */
+ status = snprintf (strData, 257, "0.1E%d", precIn+2);
+ if (status == -1)
+ {
+ return;
+ }
+ mpfr_set_str_binary (cmp, strData);
+
+ /* in = "0.10...01EprecIn+2" use all (precIn) mantisa bits */
+ memset ((void *)strData, '0', precIn+2);
+ strData[1] = '.';
+ strData[2] = '1';
+ snprintf (&strData[precIn+1], 255, "1E%d", precIn+2);
+ mpfr_set_str_binary (in, strData);
+
status = mpfr_rint (out, in, MPFR_RNDN);
- mpfr_set_str_binary (cmp, "0.1E194");
- if ((mpfr_cmp (out, cmp) != 0) || (status != -1))
+ if ((mpfr_cmp (out, cmp) != 0) || (status >= 0))
{
printf("mpfr_rint error :\n status is %d instead of 0\n", status);
printf(" out value is ");
@@ -254,19 +267,17 @@ coverage_03032011 (void)
mpfr_clear (cmp);
mpfr_clear (out);
- mpfr_init2 (out, (GMP_NUMB_BITS * 2) - 1);
- mpfr_init2 (cmp, (GMP_NUMB_BITS * 2) - 1);
- mpfr_set_str_binary (in, "0.1E194");
- mpfr_set_str_binary (in,
- "0.1111111111111111111111111111111111111111111111111111111111111101"
- "1111111111111111111111111111111111111111111111111111111111111101"
- "1111111111111111111111111111111111111111111111111111111111111101E194");
+ mpfr_init2 (out, GMP_NUMB_BITS);
+ mpfr_init2 (cmp, GMP_NUMB_BITS);
+
+ /* cmp = "0.10...01EprecIn+2" use all (GMP_NUMB_BITS) mantisa bits */
+ strcpy (&strData[GMP_NUMB_BITS+1], &strData[precIn+1]);
+ mpfr_set_str_binary (cmp, strData);
+
+ ((mp_limb_t *)MPFR_MANT(in))[2] = MPFR_LIMB_HIGHBIT;
status = mpfr_rint (out, in, MPFR_RNDN);
- mpfr_set_str_binary (cmp,
- "0.1111111111111111111111111111111111111111111111111111111111111101"
- "111111111111111111111111111111111111111111111111111111111111111E194");
- if ((mpfr_cmp (out, cmp) != 0) || (status != 1))
+ if ((mpfr_cmp (out, cmp) != 0) || (status <= 0))
{
printf("mpfr_rint error :\n status is %d instead of 0\n", status);
printf(" out value is\n");