diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-06-10 14:25:57 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-06-10 14:25:57 +0000 |
commit | 0c7bb6432a0783269c6598629c8449b8079befc6 (patch) | |
tree | 0b4ba491c96bcbced64991a37ba5766e78029667 | |
parent | 06ea5b7bde855e951cd679bf141530eee6618a6d (diff) | |
download | mpfr-0c7bb6432a0783269c6598629c8449b8079befc6.tar.gz |
[tests/trandom.c] Improved latest change, as some other test already
assume a fixed PRNG with GMP >= 4.2.0 (now the value of the last
random number of the test is checked).
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@9551 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | tests/trandom.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/tests/trandom.c b/tests/trandom.c index b8521c7d5..a86d77a91 100644 --- a/tests/trandom.c +++ b/tests/trandom.c @@ -22,10 +22,8 @@ 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) +test_urandomb (long nbtests, mpfr_prec_t prec, int verbose, char *s) { mpfr_t x; int *tab, size_tab, k, sh, xn; @@ -55,12 +53,19 @@ 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)]++; } + 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 @@ -171,35 +176,30 @@ main (int argc, char *argv[]) else prec = atol(argv[2]); - test_urandomb (nbtests, prec, verbose); + test_urandomb (nbtests, prec, verbose, NULL); if (argc == 1) /* check also small precision */ { - test_urandomb (nbtests, 2, 0); + test_urandomb (nbtests, 2, 0, NULL); } #ifndef MPFR_USE_MINI_GMP - /* since this test assumes a deterministic random generator, and this is not - implemented in mini-gmp, we omit it with mini-gmp */ + + /* Since these tests assume a deterministic random generator, and this + is not implemented in mini-gmp, we omit them with mini-gmp. */ + bug20100914 (); -#endif +#if __MPFR_GMP(4,2,0) /* 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); + test_urandomb (575123, 40, 0, + "0.1010111100000000000000000000000000000000E-32"); +#endif - 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; |