summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2007-11-23 19:02:46 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2007-11-23 19:02:46 +0000
commit9bdb1c5bda35b8767aa1616f79e29f7b768b8985 (patch)
tree647ad495fa9e5a01aaff4c42d84b54f117567f8d /tests
parent13bd07f7888bc3cc42a63326e4fe68c44e1350a1 (diff)
downloadmpfr-9bdb1c5bda35b8767aa1616f79e29f7b768b8985.tar.gz
tests/tprintf.c:
* Non-standard headers should be included after the standard headers (when possible). * The setlocale function is used only if <locale.h> has been included. * Use tests_start_mpfr / tests_end_mpfr; this shows a bug: tests_free(): attempt to free bad pointer 0x1801200 git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@4996 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r--tests/tprintf.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/tests/tprintf.c b/tests/tprintf.c
index 1f1688033..76272903e 100644
--- a/tests/tprintf.c
+++ b/tests/tprintf.c
@@ -21,12 +21,13 @@ MA 02110-1301, USA. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <gmp.h>
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
+#include <gmp.h>
+
#include "mpfr-test.h"
const int buf_size = 1024;
@@ -210,8 +211,8 @@ floating_point ()
if (strcmp (buffer, "1.8954855934746127e+12") != 0)
{
fprintf (stderr, "Error in mpfr_sprintf(s, \"%%.RDe\", x)\n");
- fprintf (stderr,
- "expected: 1.8954855934746127e+12\ngot: %s\n",
+ fprintf (stderr,
+ "expected: 1.8954855934746127e+12\ngot: %s\n",
buffer);
exit (1);
}
@@ -293,9 +294,9 @@ mixed ()
mpfr_sprintf (buffer, "%Zi, %R*e", mpz, rnd, x);
if (strcmp (buffer, "10610209857723, -1.2345678875e+07") != 0)
{
- fprintf (stderr,
+ fprintf (stderr,
"Error in mpfr_sprintf (s, \"%%Zi, %%R*e\", mpz, rnd, x);\n");
- fprintf (stderr,
+ fprintf (stderr,
"expected: 10610209857723, -1.2345678875e+07\ngot: %s\n",
buffer);
exit (1);
@@ -310,7 +311,7 @@ mixed ()
mpfr_sprintf (buffer, "%.0R*f, %Qx", GMP_RNDZ, x, mpq);
if (strcmp (buffer, "-12345678, 1e240/45b352") != 0)
{
- fprintf (stderr,
+ fprintf (stderr,
"Error in mpfr_sprintf (s, \"%%R*e, %%Qx\", GMP_RNDZ, x, mpq)\n");
fprintf (stderr, "expected: -12345678, 1e240/45b352\ngot: %s\n",
buffer);
@@ -319,7 +320,7 @@ mixed ()
mpfr_sprintf (buffer, "%i, %.*Rf, %Ff", i, 12, x, mpf);
if (strcmp (buffer, "121, -12345678.875000000000, 1.290323") != 0)
{
- fprintf (stderr,
+ fprintf (stderr,
"Error in mpfr_sprintf (s, \"%%i, %%.*Rf, %%Ff\", i, 12, x, mpf)\n");
fprintf (stderr, \
"expected: 121, -12345678.875000000000, 1.290323\ngot: %s\n",
@@ -329,7 +330,7 @@ mixed ()
mpfr_sprintf (buffer, "%.*Zi, %R*e, %Lf", 20, mpz, rnd, x, d);
if (strcmp (buffer, "00000010610209857723, -1.2345678875e+07, 0.032258") != 0)
{
- fprintf (stderr,
+ fprintf (stderr,
"Error in mpfr_sprintf (s,\"%%.*Zi, %%R*e, %%Lf\", 20, mpz, GMP_RNDD, x, d)\n");
fprintf (stderr, \
"expected: 00000010610209857723, -1.2345678875e+07, 0.032258\ngot: %s\n",
@@ -339,7 +340,7 @@ mixed ()
mpf_clear (mpf);
mpq_clear (mpq);
- mpz_clear (mpz);
+ mpz_clear (mpz);
mpfr_clear (x);
return 0;
}
@@ -347,9 +348,12 @@ mixed ()
int
main (int argc, char **argv)
{
-#ifdef HAVE_SETLOCALE
- /* currently, we just check with 'C' locale */
char *locale;
+
+ tests_start_mpfr ();
+
+#ifdef HAVE_LOCALE_H && HAVE_SETLOCALE
+ /* currently, we just check with 'C' locale */
locale = setlocale (LC_NUMERIC, "C");
#endif
@@ -358,8 +362,10 @@ main (int argc, char **argv)
floating_point ();
mixed ();
-#ifdef HAVE_SETLOCALE
+#ifdef HAVE_LOCALE_H && HAVE_SETLOCALE
setlocale (LC_NUMERIC, locale);
#endif
+
+ tests_end_mpfr ();
return 0;
}