summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-06-10 23:56:37 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-06-10 23:56:37 +0000
commita86d68496ddfbc04cceee186b731ee579efb2887 (patch)
treecdbcc3ab8f3e0b833d49b22c94132f9b7e2cca80 /tests
parentc9d9b43d7c5994c470726579f8c471e2a12a44c2 (diff)
downloadmpfr-a86d68496ddfbc04cceee186b731ee579efb2887.tar.gz
[tests/trandom.c] The use of mpfr_rands yielded a compilation failure
of trandom.c with --with-gmp-build; it should have been __gmp_rands or RANDS. But let's do better by using a new gmp_randstate_t as done in bug20100914(). (merged changeset r9553 from the trunk) git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/3.1@9554 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r--tests/trandom.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/tests/trandom.c b/tests/trandom.c
index 9f8017686..9edfb9061 100644
--- a/tests/trandom.c
+++ b/tests/trandom.c
@@ -26,7 +26,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#include "mpfr-test.h"
static void
-test_urandomb (long nbtests, mpfr_prec_t prec, int verbose, char *s)
+test_urandomb (long nbtests, mpfr_prec_t prec, int verbose)
{
mpfr_t x;
int *tab, size_tab, k, sh, xn;
@@ -59,15 +59,6 @@ test_urandomb (long nbtests, mpfr_prec_t prec, int verbose, char *s)
tab[(int)(size_tab * d)]++;
}
- if (s != NULL && mpfr_cmp_str (x, s, 2, MPFR_RNDN) != 0)
- {
- printf ("Error in test_urandomb:\n");
- printf ("Expected %s\n", s);
- printf ("Got ");
- mpfr_dump (x);
- exit (1);
- }
-
/* coverage test */
emin = mpfr_get_emin ();
set_emin (1); /* the generated number in [0,1[ is not in the exponent
@@ -178,11 +169,11 @@ main (int argc, char *argv[])
else
prec = atol(argv[2]);
- test_urandomb (nbtests, prec, verbose, NULL);
+ test_urandomb (nbtests, prec, verbose);
if (argc == 1) /* check also small precision */
{
- test_urandomb (nbtests, 2, 0, NULL);
+ test_urandomb (nbtests, 2, 0);
}
bug20100914 ();
@@ -191,9 +182,34 @@ main (int argc, char *argv[])
/* Get a non-zero fixed-point number whose first 32 bits are 0 with the
default GMP PRNG. This corresponds to the case cnt == 0 && k != 0 in
src/urandomb.c with the 32-bit ABI. */
- gmp_randseed_ui (mpfr_rands, 4518);
- test_urandomb (575123, 40, 0,
- "0.1010111100000000000000000000000000000000E-32");
+ {
+ gmp_randstate_t s;
+ mpfr_t x;
+ char *str = "0.1010111100000000000000000000000000000000E-32";
+ int k;
+
+ gmp_randinit_default (s);
+ gmp_randseed_ui (s, 4518);
+ mpfr_init2 (x, 40);
+
+ for (k = 0; k < 575123; k++)
+ {
+ mpfr_urandomb (x, s);
+ MPFR_ASSERTN (MPFR_IS_FP (x));
+ }
+
+ if (mpfr_cmp_str (x, str, 2, MPFR_RNDN) != 0)
+ {
+ printf ("Error in test_urandomb:\n");
+ printf ("Expected %s\n", str);
+ printf ("Got ");
+ mpfr_dump (x);
+ exit (1);
+ }
+
+ mpfr_clear (x);
+ gmp_randclear (s);
+ }
#endif
tests_end_mpfr ();