diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-06-10 13:59:09 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-06-10 13:59:09 +0000 |
commit | 06ea5b7bde855e951cd679bf141530eee6618a6d (patch) | |
tree | 748e1f09655b4e33a6d191e88ecff2811c7bbc95 | |
parent | adea850c27f42c01568e3b6c96d059f36f7783d7 (diff) | |
download | mpfr-06ea5b7bde855e951cd679bf141530eee6618a6d.tar.gz |
[tests/trandom.c]
* 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 (fixed in r8762) with the 32-bit ABI.
* Output a warning (with a fatal error when the MPFR_COV_CHECK macro
is defined) if one doesn't get such a number, probably because the
GMP PRNG has changed.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@9550 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | tests/trandom.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/trandom.c b/tests/trandom.c index 7acd6bc35..b8521c7d5 100644 --- a/tests/trandom.c +++ b/tests/trandom.c @@ -22,6 +22,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #include "mpfr-test.h" +static mpfr_exp_t smallest_exp = 0; static void test_urandomb (long nbtests, mpfr_prec_t prec, int verbose) @@ -54,6 +55,8 @@ test_urandomb (long nbtests, mpfr_prec_t prec, int verbose) mpfr_print_binary (x); puts (""); exit (1); } + if (MPFR_NOTZERO(x) && MPFR_GET_EXP(x) < smallest_exp) + smallest_exp = MPFR_GET_EXP(x); d = mpfr_get_d1 (x); av += d; var += d*d; tab[(int)(size_tab * d)]++; } @@ -181,6 +184,23 @@ main (int argc, char *argv[]) bug20100914 (); #endif + /* 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 (fixed in r8762) with the 32-bit ABI. */ + gmp_randseed_ui (mpfr_rands, 4518); + test_urandomb (575123, 40, 0); + + if (smallest_exp > -32) + { + printf ("Warning! The minimum exponent is %d, which is > -32.\n", + (int) smallest_exp); + printf ("Has the default PRNG changed?\n"); + /* Make this fatal only when coverage is checked. */ +#ifdef MPFR_COV_CHECK + exit (1); +#endif + } + tests_end_mpfr (); return 0; } |