summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2011-05-12 12:36:13 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2011-05-12 12:36:13 +0000
commit96e7f3fffaee46d9ce896161b7a54402d47afc4d (patch)
treebbff542658098085e2e7c803c091ab886781a325 /tests
parenta76828f172de1b273e921937941a0cc7b2ccf201 (diff)
downloadmpfr-96e7f3fffaee46d9ce896161b7a54402d47afc4d.tar.gz
Fixed printf's calls: support the case where mpfr_prec_t is not a long
(or unsigned long). [merged changeset r7643 from the exp-int branch] git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@7686 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r--tests/tadd1sp.c50
-rw-r--r--tests/tcheck.c4
-rw-r--r--tests/tcmp2.c24
-rw-r--r--tests/tconst_pi.c6
-rw-r--r--tests/tgmpop.c3
-rw-r--r--tests/tpow_z.c5
-rw-r--r--tests/tset_sj.c4
-rw-r--r--tests/tsqr.c6
-rw-r--r--tests/tsqrt.c2
-rw-r--r--tests/tsub.c6
-rw-r--r--tests/tsub1sp.c56
-rw-r--r--tests/turandom.c2
12 files changed, 94 insertions, 74 deletions
diff --git a/tests/tadd1sp.c b/tests/tadd1sp.c
index ce7f2aef7..1fd0c85a5 100644
--- a/tests/tadd1sp.c
+++ b/tests/tadd1sp.c
@@ -73,29 +73,33 @@ main (void)
return 0;
}
-#define STD_ERROR \
- {\
- printf("ERROR: for %s and p=%lu and i=%d:\nB=",\
- mpfr_print_rnd_mode ((mpfr_rnd_t) r), p, i);\
- mpfr_print_binary(b);\
- printf("\nC="); mpfr_print_binary(c);\
- printf("\nadd1 : "); mpfr_print_binary(a1);\
- printf("\nadd1sp: "); mpfr_print_binary(a2);\
- putchar('\n');\
- exit(1);\
- }
-
-#define STD_ERROR2 \
- {\
- printf("ERROR: Wrong inexact flag for %s and p=%lu and i=%d:\nB=",\
- mpfr_print_rnd_mode ((mpfr_rnd_t) r), p, i);\
- mpfr_print_binary(b);\
- printf("\nC="); mpfr_print_binary(c);\
- printf("\nA="); mpfr_print_binary(a1);\
- printf("\nAdd1: %d. Add1sp: %d\n", \
- inexact1, inexact2); \
- exit(1);\
- }
+#define STD_ERROR \
+ do \
+ { \
+ printf("ERROR: for %s and p=%lu and i=%d:\nB=", \
+ mpfr_print_rnd_mode ((mpfr_rnd_t) r), (unsigned long) p, i); \
+ mpfr_print_binary(b); \
+ printf("\nC="); mpfr_print_binary(c); \
+ printf("\nadd1 : "); mpfr_print_binary(a1); \
+ printf("\nadd1sp: "); mpfr_print_binary(a2); \
+ putchar('\n'); \
+ exit(1); \
+ } \
+ while (0)
+
+#define STD_ERROR2 \
+ do \
+ { \
+ printf("ERROR: Wrong inexact flag for %s and p=%lu and i=%d:\nB=", \
+ mpfr_print_rnd_mode ((mpfr_rnd_t) r), (unsigned long) p, i); \
+ mpfr_print_binary(b); \
+ printf("\nC="); mpfr_print_binary(c); \
+ printf("\nA="); mpfr_print_binary(a1); \
+ printf("\nAdd1: %d. Add1sp: %d\n", \
+ inexact1, inexact2); \
+ exit(1); \
+ } \
+ while (0)
#define SET_PREC(_p) \
{ \
diff --git a/tests/tcheck.c b/tests/tcheck.c
index 9b45cfb64..ca226c770 100644
--- a/tests/tcheck.c
+++ b/tests/tcheck.c
@@ -25,7 +25,9 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#include "mpfr-test.h"
-#define ERROR(s) printf("mpfr_check failed " s " Prec=%lu\n", pr), exit(1)
+#define ERROR(s) \
+ (printf ("mpfr_check failed " s " Prec=%lu\n", (unsigned long) pr), \
+ exit(1))
int
main (void)
diff --git a/tests/tcmp2.c b/tests/tcmp2.c
index 4e9dd9f32..687f7ac45 100644
--- a/tests/tcmp2.c
+++ b/tests/tcmp2.c
@@ -69,7 +69,7 @@ worst_cases (void)
mpfr_out_str (stdout, 2, 0, x, MPFR_RNDN);
printf ("\ny=");
mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
- printf ("\ngot %lu instead of 1\n", l);
+ printf ("\ngot %lu instead of 1\n", (unsigned long) l);
exit (1);
}
@@ -81,7 +81,7 @@ worst_cases (void)
mpfr_out_str (stdout, 2, 0, x, MPFR_RNDN);
printf ("\ny=");
mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
- printf ("\ngot %lu instead of 0\n", l);
+ printf ("\ngot %lu instead of 0\n", (unsigned long) l);
exit (1);
}
}
@@ -113,7 +113,8 @@ worst_cases (void)
mpfr_out_str (stdout, 2, 0, x, MPFR_RNDN);
printf ("\ny=");
mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
- printf ("\ngot %lu instead of %u\n", l, expected);
+ printf ("\ngot %lu instead of %u\n",
+ (unsigned long) l, expected);
exit (1);
}
set_bit (x, i + j + k + 2, 0);
@@ -127,7 +128,8 @@ worst_cases (void)
mpfr_out_str (stdout, 2, 0, x, MPFR_RNDN);
printf ("\ny=");
mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
- printf ("\ngot %lu instead of %u\n", l, expected);
+ printf ("\ngot %lu instead of %u\n",
+ (unsigned long) l, expected);
exit (1);
}
}
@@ -173,7 +175,7 @@ tcmp2 (double x, double y, int i)
mpfr_out_str (stdout, 2, 0, xx, MPFR_RNDN);
printf ("\ny=");
mpfr_out_str (stdout, 2, 0, yy, MPFR_RNDN);
- printf ("\ngot %lu instead of %d\n", j, i);
+ printf ("\ngot %lu instead of %d\n", (unsigned long) j, i);
exit (1);
}
mpfr_clear(xx); mpfr_clear(yy);
@@ -202,7 +204,7 @@ special (void)
printf ("y=");
mpfr_print_binary (y);
puts ("");
- printf ("got %lu, expected 1\n", j);
+ printf ("got %lu, expected 1\n", (unsigned long) j);
exit (1);
}
@@ -215,7 +217,7 @@ special (void)
printf ("Error in mpfr_cmp2:\n");
printf ("x="); mpfr_print_binary(x); puts ("");
printf ("y="); mpfr_print_binary(y); puts ("");
- printf ("got %lu, expected 32\n", j);
+ printf ("got %lu, expected 32\n", (unsigned long) j);
exit (1);
}
@@ -228,7 +230,7 @@ special (void)
printf ("Error in mpfr_cmp2:\n");
printf ("x="); mpfr_print_binary(x); puts ("");
printf ("y="); mpfr_print_binary(y); puts ("");
- printf ("got %lu, expected 164\n", j);
+ printf ("got %lu, expected 164\n", (unsigned long) j);
exit (1);
}
@@ -242,7 +244,7 @@ special (void)
printf ("Error in mpfr_cmp2:\n");
printf ("x="); mpfr_print_binary(x); puts ("");
printf ("y="); mpfr_print_binary(y); puts ("");
- printf ("got %lu, expected 127\n", j);
+ printf ("got %lu, expected 127\n", (unsigned long) j);
exit (1);
}
@@ -256,7 +258,7 @@ special (void)
printf ("Error in mpfr_cmp2:\n");
printf ("x="); mpfr_print_binary(x); puts ("");
printf ("y="); mpfr_print_binary(y); puts ("");
- printf ("got %lu, expected 63\n", j);
+ printf ("got %lu, expected 63\n", (unsigned long) j);
exit (1);
}
@@ -270,7 +272,7 @@ special (void)
printf ("Error in mpfr_cmp2:\n");
printf ("x="); mpfr_print_binary(x); puts ("");
printf ("y="); mpfr_print_binary(y); puts ("");
- printf ("got %lu, expected 63\n", j);
+ printf ("got %lu, expected 63\n", (unsigned long) j);
exit (1);
}
diff --git a/tests/tconst_pi.c b/tests/tconst_pi.c
index 471ddaa95..78cbdf34e 100644
--- a/tests/tconst_pi.c
+++ b/tests/tconst_pi.c
@@ -87,13 +87,15 @@ bug20091030 (void)
inex = mpfr_const_pi (x, MPFR_RNDU);
if (inex < 0)
{
- printf ("Error, inex < 0 for RNDU (prec=%lu)\n", p);
+ printf ("Error, inex < 0 for RNDU (prec=%lu)\n",
+ (unsigned long) p);
exit (1);
}
inex = mpfr_const_pi (x, MPFR_RNDD);
if (inex > 0)
{
- printf ("Error, inex > 0 for RNDD (prec=%lu)\n", p);
+ printf ("Error, inex > 0 for RNDD (prec=%lu)\n",
+ (unsigned long) p);
exit (1);
}
}
diff --git a/tests/tgmpop.c b/tests/tgmpop.c
index c96d0bf8e..a7a5f6120 100644
--- a/tests/tgmpop.c
+++ b/tests/tgmpop.c
@@ -751,7 +751,8 @@ test_specialq (mpfr_prec_t p0, mpfr_prec_t p1, unsigned int N,
/* We should have fra <= qr <= frb */
if ( (mpfr_cmp(fra, frq) > 0) || (mpfr_cmp (frq, frb) > 0))
{
- printf("Range error for prec=%lu and %s", prec, op);
+ printf("Range error for prec=%lu and %s",
+ (unsigned long) prec, op);
printf ("\nq1="); mpq_out_str(stdout, 2, q1);
printf ("\nq2="); mpq_out_str(stdout, 2, q2);
printf ("\nfr_dn="); mpfr_print_binary (fra);
diff --git a/tests/tpow_z.c b/tests/tpow_z.c
index e6abe2f5d..af4d48a97 100644
--- a/tests/tpow_z.c
+++ b/tests/tpow_z.c
@@ -172,7 +172,7 @@ check_integer (mpfr_prec_t begin, mpfr_prec_t end, unsigned long max)
if (mpfr_cmp (y1, y2) != 0)
{
printf ("Error for p = %lu, z = %lu, rnd = %s and x = ",
- p, n, mpfr_print_rnd_mode (rnd));
+ (unsigned long) p, n, mpfr_print_rnd_mode (rnd));
mpfr_dump (x);
printf ("Ypowsi = "); mpfr_dump (y1);
printf ("Ypowz = "); mpfr_dump (y2);
@@ -181,7 +181,8 @@ check_integer (mpfr_prec_t begin, mpfr_prec_t end, unsigned long max)
if (res1 != res2)
{
printf ("Wrong inexact flags for p = %lu, z = %lu, rnd = %s"
- " and x = ", p, n, mpfr_print_rnd_mode (rnd));
+ " and x = ", (unsigned long) p, n,
+ mpfr_print_rnd_mode (rnd));
mpfr_dump (x);
printf ("Ypowsi(inex = %2d) = ", res1); mpfr_dump (y1);
printf ("Ypowz (inex = %2d) = ", res2); mpfr_dump (y2);
diff --git a/tests/tset_sj.c b/tests/tset_sj.c
index a7ba200c7..0068d9388 100644
--- a/tests/tset_sj.c
+++ b/tests/tset_sj.c
@@ -86,7 +86,7 @@ check_set_uj (mpfr_prec_t pmin, mpfr_prec_t pmax, int N)
if (mpfr_cmp (x, y))
{
printf ("ERROR for mpfr_set_uj and j=%lu and p=%lu\n",
- (unsigned long) limb, p);
+ (unsigned long) limb, (unsigned long) p);
printf ("X="); mpfr_dump (x);
printf ("Y="); mpfr_dump (y);
exit (1);
@@ -95,7 +95,7 @@ check_set_uj (mpfr_prec_t pmin, mpfr_prec_t pmax, int N)
{
printf ("ERROR for inexact(set_uj): j=%lu p=%lu\n"
"Inexact1= %d Inexact2= %d\n",
- (unsigned long) limb, p, inex1, inex2);
+ (unsigned long) limb, (unsigned long) p, inex1, inex2);
exit (1);
}
}
diff --git a/tests/tsqr.c b/tests/tsqr.c
index bb5d8b572..096848eee 100644
--- a/tests/tsqr.c
+++ b/tests/tsqr.c
@@ -38,7 +38,8 @@ static void
error1 (mpfr_rnd_t rnd, mpfr_prec_t prec,
mpfr_t in, mpfr_t outmul, mpfr_t outsqr)
{
- printf("ERROR: for %s and prec=%lu\nINPUT=", mpfr_print_rnd_mode(rnd), prec);
+ printf("ERROR: for %s and prec=%lu\nINPUT=", mpfr_print_rnd_mode(rnd),
+ (unsigned long) prec);
mpfr_dump(in);
printf("OutputMul="); mpfr_dump(outmul);
printf("OutputSqr="); mpfr_dump(outsqr);
@@ -49,7 +50,8 @@ static void
error2 (mpfr_rnd_t rnd, mpfr_prec_t prec, mpfr_t in, mpfr_t out,
int inexactmul, int inexactsqr)
{
- printf("ERROR: for %s and prec=%lu\nINPUT=", mpfr_print_rnd_mode(rnd), prec);
+ printf("ERROR: for %s and prec=%lu\nINPUT=", mpfr_print_rnd_mode(rnd),
+ (unsigned long) prec);
mpfr_dump(in);
printf("Output="); mpfr_dump(out);
printf("InexactMul= %d InexactSqr= %d\n", inexactmul, inexactsqr);
diff --git a/tests/tsqrt.c b/tests/tsqrt.c
index 56b01596e..21187db8e 100644
--- a/tests/tsqrt.c
+++ b/tests/tsqrt.c
@@ -120,7 +120,7 @@ check_diverse (const char *as, mpfr_prec_t p, const char *qs)
if (mpfr_cmp_str1 (q, qs))
{
printf ("mpfr_sqrt failed for a=%s, prec=%lu, rnd_mode=%s\n",
- as, p, mpfr_print_rnd_mode (MPFR_RNDN));
+ as, (unsigned long) p, mpfr_print_rnd_mode (MPFR_RNDN));
printf ("expected sqrt is %s, got ", qs);
mpfr_out_str (stdout, 10, 0, q, MPFR_RNDN);
printf ("\n");
diff --git a/tests/tsub.c b/tests/tsub.c
index 8527f01fc..b6a46ed73 100644
--- a/tests/tsub.c
+++ b/tests/tsub.c
@@ -581,17 +581,17 @@ check_rounding (void)
if (mpfr_cmp_ui_2exp (a, 1, p) != 0)
{
printf ("Wrong result in check_rounding\n");
- printf ("p=%lu k=%ld l=%ld\n", p, k, l);
+ printf ("p=%lu k=%ld l=%ld\n", (unsigned long) p, k, l);
printf ("b="); mpfr_print_binary (b); puts ("");
printf ("c="); mpfr_print_binary (c); puts ("");
- printf ("Expected 2^%lu\n", p);
+ printf ("Expected 2^%lu\n", (unsigned long) p);
printf ("Got "); mpfr_print_binary (a); puts ("");
exit (1);
}
if (i >= 0)
{
printf ("Wrong ternary value in check_rounding\n");
- printf ("p=%lu k=%ld l=%ld\n", p, k, l);
+ printf ("p=%lu k=%ld l=%ld\n", (unsigned long) p, k, l);
printf ("b="); mpfr_print_binary (b); puts ("");
printf ("c="); mpfr_print_binary (c); puts ("");
printf ("a="); mpfr_print_binary (a); puts ("");
diff --git a/tests/tsub1sp.c b/tests/tsub1sp.c
index 5fbb91d43..8a5c1dee5 100644
--- a/tests/tsub1sp.c
+++ b/tests/tsub1sp.c
@@ -43,29 +43,33 @@ main (void)
return 0;
}
-#define STD_ERROR \
- {\
- printf("ERROR: for %s and p=%lu and i=%d:\nY=",\
- mpfr_print_rnd_mode ((mpfr_rnd_t) r), p, i);\
- mpfr_print_binary(y);\
- printf("\nZ="); mpfr_print_binary(z);\
- printf("\nReal: "); mpfr_print_binary(x2);\
- printf("\nGot : "); mpfr_print_binary(x);\
- putchar('\n');\
- exit(1);\
- }
-
-#define STD_ERROR2 \
- {\
- printf("ERROR: for %s and p=%lu and i=%d:\nY=",\
- mpfr_print_rnd_mode ((mpfr_rnd_t) r), p, i);\
- mpfr_print_binary(y);\
- printf("\nZ="); mpfr_print_binary(z);\
- printf("\nR="); mpfr_print_binary(x);\
- printf("\nWrong inexact flag. Real: %d. Got: %d\n", \
- inexact1, inexact2); \
- exit(1);\
- }
+#define STD_ERROR \
+ do \
+ { \
+ printf("ERROR: for %s and p=%lu and i=%d:\nY=", \
+ mpfr_print_rnd_mode ((mpfr_rnd_t) r), (unsigned long) p, i); \
+ mpfr_print_binary(y); \
+ printf("\nZ="); mpfr_print_binary(z); \
+ printf("\nReal: "); mpfr_print_binary(x2); \
+ printf("\nGot : "); mpfr_print_binary(x); \
+ putchar('\n'); \
+ exit(1); \
+ } \
+ while (0)
+
+#define STD_ERROR2 \
+ do \
+ { \
+ printf("ERROR: for %s and p=%lu and i=%d:\nY=", \
+ mpfr_print_rnd_mode ((mpfr_rnd_t) r), (unsigned long) p, i); \
+ mpfr_print_binary(y); \
+ printf("\nZ="); mpfr_print_binary(z); \
+ printf("\nR="); mpfr_print_binary(x); \
+ printf("\nWrong inexact flag. Real: %d. Got: %d\n", \
+ inexact1, inexact2); \
+ exit(1); \
+ } \
+ while (0)
static void
check_random (mpfr_prec_t p)
@@ -120,7 +124,8 @@ check_special (void)
mpfr_sub1sp (x, y, y, (mpfr_rnd_t) r);
if (mpfr_cmp_ui(x, 0))
{
- printf("Error for x-x with p=%lu. Expected 0. Got:", p);
+ printf("Error for x-x with p=%lu. Expected 0. Got:",
+ (unsigned long) p);
mpfr_print_binary(x);
exit(1);
}
@@ -129,7 +134,8 @@ check_special (void)
mpfr_sub1sp(x, y, z, (mpfr_rnd_t) r);
if (mpfr_cmp_ui(x, 0))
{
- printf("Error for x-y with y=x and p=%lu. Expected 0. Got:", p);
+ printf("Error for x-y with y=x and p=%lu. Expected 0. Got:",
+ (unsigned long) p);
mpfr_print_binary(x);
exit(1);
}
diff --git a/tests/turandom.c b/tests/turandom.c
index 79c6f3af9..199b54b3e 100644
--- a/tests/turandom.c
+++ b/tests/turandom.c
@@ -221,7 +221,7 @@ main (int argc, char *argv[])
{
printf ("Warning. Cannot compute the bit frequency: the given bit "
"index (= %ld) is not less than the precision (= %ld).\n",
- bit_index, prec);
+ bit_index, (long) prec);
bit_index = -1;
}
}