summaryrefslogtreecommitdiff
path: root/tests/tprintf.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2012-03-08 13:54:43 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2012-03-08 13:54:43 +0000
commit3b4f7f69ecc8fc6a619ef321d22984f731d95b3e (patch)
treece0c86a5009a09557548d4bf79af5b2a929d22cd /tests/tprintf.c
parent52ea024c4058665ec0596e0154a1ee03249f1dea (diff)
downloadmpfr-3b4f7f69ecc8fc6a619ef321d22984f731d95b3e.tar.gz
[tests/tprintf.c] Corrected the test with MPFR_CHECK_LARGEMEM=1 again,
and improved it in case _MPFR_PREC_FORMAT == 2, where MPFR_PREC_MAX is INT_MAX minus some small constant (see r8035). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@8079 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tprintf.c')
-rw-r--r--tests/tprintf.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/tests/tprintf.c b/tests/tprintf.c
index aade07e12..7f238d72e 100644
--- a/tests/tprintf.c
+++ b/tests/tprintf.c
@@ -64,7 +64,7 @@ check (const char *fmt, mpfr_t x)
{
if (mpfr_printf (fmt, x) == -1)
{
- fprintf (stderr, "Error in mpfr_printf(\"%s\", ...)\n", fmt);
+ fprintf (stderr, "Error 1 in mpfr_printf(\"%s\", ...)\n", fmt);
exit (1);
}
@@ -79,7 +79,7 @@ check_vprintf (const char *fmt, ...)
va_start (ap, fmt);
if (mpfr_vprintf (fmt, ap) == -1)
{
- fprintf (stderr, "Error in mpfr_vprintf(\"%s\", ...)\n", fmt);
+ fprintf (stderr, "Error 2 in mpfr_vprintf(\"%s\", ...)\n", fmt);
va_end (ap);
exit (1);
@@ -97,7 +97,7 @@ check_vprintf_failure (const char *fmt, ...)
if (mpfr_vprintf (fmt, ap) != -1)
{
putchar ('\n');
- fprintf (stderr, "Error in mpfr_vprintf(\"%s\", ...)\n", fmt);
+ fprintf (stderr, "Error 3 in mpfr_vprintf(\"%s\", ...)\n", fmt);
va_end (ap);
exit (1);
@@ -153,6 +153,10 @@ check_invalid_format (void)
check_vprintf_failure ("%Rx", i);
}
+/* The goal of this test is to check cases where more INT_MAX characters
+ are output, in which case, it should be a failure, because like C's
+ *printf functions, the return type is int and the returned value must
+ be either the number of characters printed or a negative value. */
static void
check_long_string (void)
{
@@ -166,8 +170,7 @@ check_long_string (void)
MPFR: Can't reallocate memory (old_size=4096 new_size=2147487744)
The implementation might be improved to use less memory and avoid
this problem. In the mean time, let's choose a smaller precision,
- but with r8077 on an x86_64 machine with a 32-bit ABI (-m32), this
- currently fails with: Error in mpfr_vprintf("%Rb", ...) */
+ but this will generally have the effect to disable the test. */
if (sizeof (void *) == 4)
large_prec /= 2;
@@ -180,8 +183,11 @@ check_long_string (void)
mpfr_set_ui (x, 1, MPFR_RNDN);
mpfr_nextabove (x);
- check_vprintf_failure ("%Rb", x);
- check_vprintf_failure ("%RA %RA %Ra %Ra", x, x, x, x);
+ if (large_prec >= INT_MAX - 512)
+ {
+ check_vprintf_failure ("%Rb %512d", x, 1);
+ check_vprintf_failure ("%RA %RA %Ra %Ra %512d", x, x, x, x, 1);
+ }
mpfr_clear (x);
}